Moving and Renaming Directories and Files
- Linux File System Structure
- Navigating the Linux File System
- Creating Directories and Files
- Moving and Renaming Directories and Files
- Deleting or Removing Directories and Files
- links or shortcuts in linux
Now that we know how to create directories and files we need to be able to rename them and move them.
In Linux the command to move and rename is the same !
command to rename and move directories and files
NAME
mv – move (rename) files
SYNOPSIS
mv [OPTION]… [-T] SOURCE DEST
mv [OPTION]… SOURCE… DIRECTORY
mv [OPTION]… -t DIRECTORY SOURCE…
Lets rename the directory “directory3″ to “directory5″. Call the command mv and first specify the current directory name and then the new directory name :
$ mv directory3 directory5
Now lets check if the directory was renamed:
$ ls directory5
Lets move the directory “directory1″ to the directory “level1″. To move directories call the command mv and first specify the current directory location and then the new directory location :
$ mv directory1 level1/
You may be thinking but that is the same command as renaming a file. There is one difference. “level1/” is followed by a “/”. The “/” signifies that its a location and the path is inside the directory.
Lets see that it happened:
$ ls level1 directory1 level2 level2_2
Now that you know how to move and rename directories and files have some fun and move things around in the /tmp directory.


