How to move a file?

QuestionsQuestions8 SkillsProBasic Files OperationsOct, 25 2025
092

To move a file, you can use the mv command followed by the source file and the destination directory. The syntax is as follows:

mv source_file destination_directory/

For example, if you want to move a file named document.txt to a directory called backup, you would run:

mv document.txt backup/

In this command:

  • document.txt is the file you want to move (the source).
  • backup/ is the directory where you want to move the file (the destination).

If the destination directory does not exist, you can create it first using the mkdir command:

mkdir backup

After moving the file, you can verify that it has been moved by listing the contents of the destination directory:

ls backup

You should see document.txt listed in the output.

0 Comments

no data
Be the first to share your comment!