To move files in Linux, you can use the mv command followed by the source file(s) and the destination directory or new filename. Here’s how to do it:
Moving a Single File
To move a single file to a different directory:
mv filename.txt /path/to/destination/
Moving Multiple Files
To move multiple files at once, specify the files followed by the destination directory:
mv file1.txt file2.txt /path/to/destination/
Renaming a File
To rename a file, specify the current filename and the new filename:
mv oldname.txt newname.txt
Example
-
Move a file named
report.txtto a directory calleddocuments:mv report.txt documents/ -
Move all
.jpgfiles to a directory calledimages:mv *.jpg images/ -
Rename
notes.txttoarchive.txt:mv notes.txt archive.txt
Make sure you have the necessary permissions to move the files and that the destination directory exists.
