Learn Linux 02: Navigation




The first thing we need to learn (besides how to type) is how to navigate the file system on our Linux system. This chapter will introduce the following commands:

  • pwd - Print the name of the current working directory
  • cd - Change directory
  • ls - List directory content

Understanding The File System Tree

Like Windows, a Unix-like operating system such as Linux organizes its files in what is called a hierarchical directory structure. This means they are organized in a tree-like pattern of directories (sometimes called folders in other systems), which may contain files and other directories. The first directory in the file system is called the root directory. The root directory contains files and subdirectories, which contain more files and subdirectories, and so on.

Note that unlike Windows, which has a separate file system tree for each storage device, Unix-like systems such as Linux always have a single file system tree, regardless of how many drives or storage devices are attached to the computer. Storage devices are attached (or more correctly, mounted) at various points on the tree according to the whims of the system administrator, the person (or people) responsible for the maintenance of the system.

Also unlike Windows, Linux is case sensitive. This means that Desktop is different from desktop, which is different from DeskTop. Each of these would represent a different file or directory name.

The Current Working Directory

The current working directory is the directory in which the user is currently working in. By default, when you log into your Linux system, your current working directory is set to your home directory. To display the current working directory, we use the pwd (print working directory) command.

[user@linux ~]$ pwd

Listing The Contents Of A Directory

To list the files and directories in the current working directory or other directories, we use the ls command.

[user@linux ~]$ ls
Desktop Documents Music Pictures Public Templates Videos

Changing The Current Working Directory

To change our current working directory, we use the cd command. To do this, type cd followed by the pathname of the desired working directory. A pathname is the route we take along the branches of the tree to get to the directory we want. There are two different ways to specify a pathname: absolute pathnames and relative pathnames.

An absolute pathname begins with the root directory and follows the tree branch by branch until the path to the desired directory or file is completed.

[user@linux ~]$ cd /usr/bin
[user@linux bin]$ pwd

Where an absolute pathname starts from the root directory and leads to its destination, a relative pathname starts from the working directory. To do this, it uses a couple of special notations to represent relative positions in the file system tree. These special notations are . (dot) and .. (dot dot).

The . notation refers to the working directory, and the .. notation refers to the working directory’s parent directory. Here is how it works. Let’s change the working directory to /usr/bin again.

[user@linux ~]$ cd /usr/bin
[user@linux bin]$ pwd

Now let’s say that we wanted to change the working directory to the parent of /usr/bin, which is /usr.

[user@linux bin]$ cd ..
[user@linux usr]$ pwd

Now let’s change the directory to /usr/bin again.

[user@linux usr]$ cd ./bin
[user@linux bin]$ pwd

Now, there is something important to point out here. In almost all cases, we can omit the ./ part because it is implied. Typing the following does the same thing.

[user@linux usr]$ cd bin

Here is a list of helpful shortcuts:

  • cd - Changes the working directory to your home directory
  • cd - - Changes the working directory to the previous working directory
  • cd ~user_name - Changes the working directory to the home directory of user_name


In this chapter we learned what the file system tree is and how to navigate the file system on our Linux system.