I would like to move a directory one level up into the root directory. I’ve all html files located in /home/apache2/www/html directory, and I’d like to move /home/apache2/www/html to one level up at /home/apache2/www/. How can I accomplish this over the ssh session?
You need to use mv command that moves one or more files or directories from one place to another. You must have have write permission for the directories which the file will move between. The syntax is as follows to move /home/apache2/www/html directory up one level at /home/apache2/www/ directory. Open a command-line terminal (select Applications > Accessories > Terminal), and then type (for remote system use ssh for login):
$ mv /home/apache2/www/html/ /home/apache2/www/
$ mv /home/apache2/www/html/ ..
Please note that Unix / Linux uses the special name .. to refer to the parent directory of a particular directory. In this example move /usb/archives/data/ directory to up one level using the mv command as follows:
$ cd /usb/archives/data/
$ mv -v data/ ..
- -v : Cause mv to be verbose, showing files after they are moved.
How Do I Move Multiple Directories Up One Level?
The syntax is as follows to moves each file named by a source operand to a destination file in the existing directory named by the directory operand:
$ mv dir1 dir2 ..
In this example move both /home/vivek/projects/foo/ /home/vivek/projects/bar/ directories up one level:
$ mv /home/vivek/projects/foo /home/vivek/projects/bar ..
You can move files using the same syntax. In this example move movie-cd1.avi movie-cd2.avi files up one level:
$ mv /home/vivek/Downloads/movie-cd1.avi /home/vivek/Downloads/movie-cd2.avi ..
How Do I Move All Directories Up One Level?
Use the following syntax to move all directories and files in /home/vivek/data/sales/ to /home/vivek/data/:
$ mv -v /home/vivek/data/sales/ ..
$ cd /home/vivek/data/sales/
$ mv -v sales/ ..
How Do I Move All *.pl or *.c Files Up One Level?
Use the following syntax to move all *.pl (perl files) or *.c (C program files) up one level:
$ mv -v /home/vivek/projects/*.pl ..
$ mv -v /home/vivek/projects/*.c ..