How to move a folder in Linux using mv command

In Linux, you can use the mv command to move a folder to a new location. The basic syntax is as follows:

mv /path/to/original/folder /path/to/new/location

For example, if you want to move a folder named “example” from the home directory to the /var/ directory, the command would be:

mv ~/example /var/

Please note that the mv command will overwrite any existing files or folders in the destination location with the same name. If you want to rename the folder while moving it, you can simply provide a new name for the folder as the destination.

mv ~/example /var/example_new

Also, you can use the -v option, which will show the files being moved in the terminal.

mv -v ~/example /var/example_new

It’s always good practice to use the -i option, which will prompt you for confirmation before overwriting any existing files.

mv -i ~/example /var/example_new

Please note that you need to have the necessary permissions to move the folder to the new location.

Leave a Comment