gnuBy Rand Whitehall

In the Linux command line shell, moving around from directory to directory, adding new directories, and deleting old directories is easy once you know the proper commands. Again, with Linux, you are limited only by your brain! If you know all the commands, then you weild great power. But if you know only a few commands, it’s like you are standing in the airport in Tokyo and want to know where the bathroom is, but only know how to say hi and bye in Japanese.

Let’s get to it. Open a shell (or terminal) and type each line below followed by enter:

cd

pwd

You should be in your home directory, which is the same name as your username. So if your username is barney22, your home directory should be /home/barney22.

Now, let’s create a new directory to play with. (Remember, when learning the command line in Linux, always play with new directories and files you create to practice with. Never practice with important files and directories.) Type this:

mkdir doggy [enter]

ls [enter]

Now you should see your new directory called doggy in the ls output. Great! Now what? Let’s change the name. Type:

mv doggy doggyDo [enter]

ls [enter]

And you should see the directory name has been changed from doggy to doggyDo. Great! Hmmm… Now let’s go into the doggyDo directory and create a text file.

cd doggyDo [enter]

touch shibaken.txt [enter]

ls [enter]

Now, you should be in your doggyDo directory and see the new text file you created with the touch command. If for some reason you got lost somewhere along the line, go “home” by typing this:

cd [enter]

A cd command with no destination will take you home every time.

Now, let’s say you want to move the doggyDo directory into another directory. Let’s create another directory first, like this:

cd [enter]

mkdir doggyDocs [enter]

Now let’s move the doggyDo directory into the doggyDocs directory like this:

mv doggyDo doggyDocs [enter]

ls [enter]

You should see the doggyDocs directory now, but not the doggyDo directory because it is inside doggyDocs.

cd doggyDocs [enter]

ls [enter]

You should see your doggyDo directory there inside doggyDocs.

I hope you learned a lot about creating and moving directories around in the Linux command line. If this was a bit confusing, then just go through it again slowly. With a little practice your fingers will know what to do as soon as you think of it!

Rand writes about web design, Linux, men’s health and more. Please check out his DE safety razor site for shaving info and tips and the latest on the Merkur Futur safety razor. It’s a great resource for those who are passionate about a quality, close shave.