How to move and rename file in Linux

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

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How to check kernel version of your linux server

Type command below to check the version of your kernel :   uname -r   The system will return...

How to kill process in Linux

Log in to your server as root and find the process PID your want to kill. You can do that by...