Can mv move directories recursively?

QuestionsQuestions8 SkillsProBasic Files OperationsSep, 10 2025
0167

Yes, the mv command can move directories recursively in Linux. When you use mv to move a directory, it automatically includes all its contents, including subdirectories and files.

Example:

To move a directory named source_directory to a new location, you would use:

mv source_directory /path/to/destination/

This command moves source_directory along with all its contents to the specified destination.

Important Notes:

  • Unlike the cp command, you do not need to specify a recursive option (like -r) with mv because it inherently moves everything within the directory.
  • If a directory with the same name exists at the destination, it will be overwritten without warning unless you use the -i option for interactive mode:
mv -i source_directory /path/to/destination/

If you have any further questions or need more examples, feel free to ask!

0 Comments

no data
Be the first to share your comment!