Switching Directories

Now that we have covered the basics of the directory tree, let's look at moving around the tree using the cd (short for change directory) command.

Home Directories

First print the working directory:

$ pwd
/home/ranga

The preceding example should indicate to you that I am in my home directory. Your home directory is the initial directory where you start when you log in to a UNIX machine. The easiest way to determine the location of your home directory is to do the following:

$ cd
$ pwd
/home/ranga

When you issue the cd command without arguments, it changes the current directory to your home directory. After the cd command completes, the pwd command prints the working directory, which happens to be your home directory. ...

Get Sams Teach Yourself Shell Programming in 24 Hours, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.