Moving and Renaming Directories and Files

This entry is part 4 of 6 in the series Beginner Linux Administrator

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.

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Blogplay
Fabio Milano has written 79 articles for us. Fabio Milano is a certified RHCE, MCP, and CFOI. He runs an IT consulting and services company called RDS Support inc. Website:http://www.rdssupport.com
The information provided is for educational purposes only. All content including links and comments is provided "as is" with no warranty, expressed or implied. Use is at your own risk and you are solely responsible for what you do with it.

No Comments

Leave a reply