CentOS mv Command: Move Files & Directories

In CentOS system, you can use the mv command to move files. The basic syntax of this command is as follows:

mv [source] [destination]

In this case, source refers to the path of the file or directory that needs to be moved, while destination is the target path where the file or directory should be moved to.

For instance, to move the file example.txt from the current directory to the /home/user/documents directory, you can use the following command:

mv example.txt /home/user/documents

Note that if there is already a file with the same name in the destination path, the mv command will overwrite that file. If you want to avoid overwriting, you can use the -i option to prompt whether to overwrite the file.

mv -i example.txt /home/user/documents

Additionally, if you want to move multiple files at the same time, you can list them in the source parameter and specify the last parameter as the target path.

mv file1 file2 file3 /home/user/documents
bannerAds