How to move and rename file in Linux Print

  • 0

Moving a file on Linux

 

To move a file to another location we use the same method as renaming a file, except the file path should be different:

mv source-file /new/path

 

For example, to move a file from /home/test/testingfile to /var/test2/example/testingfile , you would run the following command:

mv /home/test/testingfile  /var/test2/example/testingfile

 

 

Moving and Renaming files on Linux

 

A file can be renamed during a move process using the mv command. You simply give the target path a different name. When mv moves the file, it will be given a new name:

mv old-filename /new/path/new-filename

 

For example, to move a file named file10.txt to /var/filetest and rename it to file50.txt , you would run the following command:

mv file10.txt /var/filetest/file50.txt


Was this answer helpful?

« Back