How to move file to different directory?

QuestionsQuestions8 SkillsProBasic Files OperationsNov, 16 2025
090

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.

  1. Current Directory:

    /home/user/
    └── example.txt
  2. 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!

0 Comments

no data
Be the first to share your comment!