To move a file to a different directory in Linux, you can use the mv command. Here’s the general syntax:
mv /path/to/source_file /path/to/destination_directory/
Example:
Suppose you have a file named example.txt in your current directory and you want to move it to a directory called documents.
-
Current Directory:
/home/user/ └── example.txt -
Command to Move:
mv example.txt /home/user/documents/
Explanation:
mv: The command to move files.example.txt: The file you want to move./home/user/documents/: The destination directory where you want to move the file.
Verify the Move:
You can check if the file has been moved by listing the contents of the destination directory:
ls /home/user/documents/
If you have any specific scenarios or questions, feel free to ask!
