Can I move directories too?

QuestionsQuestions8 SkillsProBasic Files OperationsNov, 24 2025
0131

Yes, you can move directories using the mv command in Linux, just like you would with files. Here’s how:

Command

mv /path/to/source_directory /path/to/destination_directory/

Example

To move a directory named myfolder to another location:

mv myfolder /home/user/documents/

Notes

  • If the destination directory does not exist, myfolder will be renamed to documents in the current directory.
  • If you want to move a directory and its contents, simply use the same mv command without any additional options.

Verify

You can check if the directory has been moved by listing the contents of the destination:

ls /home/user/documents/

This will show the moved directory if the operation was successful.

0 Comments

no data
Be the first to share your comment!