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,
myfolderwill be renamed todocumentsin the current directory. - If you want to move a directory and its contents, simply use the same
mvcommand 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.
