Feb

23

This article continues from the previous article about using Unix Shell (command line) to operate Unix-like operating systems like Linux Ubuntu. We will see how to use Unix Shell to create, rename, move and delete files and directories.

To create a directory from the command line, type the mkdir command followed by the name of the directory, let’s create a directory called bollocks
mkdir bollocks


Use the mv command to move a file or directory to a different directory, or to rename it in its current directory. To rename the bollocks directory you created to sex_pistols you can use:
mv bollocks sex_pistols

If you wanted to move the sex_pistols directory inside the Desktop directory, you would just specify the Desktop directory as the second argument:
mv sex_pistols Desktop/

The rm command removes files, and rmdir removes directories. Just use the commands followed by the files or directories to remove, respectively:
rm Desktop/sex_pistols/
bodies.mp3
rmdir Desktop/sex_pistols/

You can also remove a directory and all files and directories inside of it by running rm -r followed by the name of the directory.

Notice: Be careful when you recursively delete a directory with this command that you do in fact want to remove all of the files within. Once removed via the command line, there’s no trash bin to retrieve them from.



Similar Posts

Comments

Name (required)

Email (required)

Website

Speak your mind

1 Comment so far

  1. zirvap on May 1, 2008 11:48 am

    very useful article, thanks for posting it out!

Sponsors




Links