Linux Filesystem Navigation Basics

This article explains basic commands for navigation within Linux file system. The diagram below represents (part of) a Linux file system know as Filesystem Hierarchy Standard. A line from one node to a node on its right indicates containment. For example, the student directory is contained within the home directory.

In this tutorial you will learn:

  • How to use pwd command
  • How to use cd command
  • How to navigate to user home directory
  • Difference between relative vs absolute
  • What is a parent directory

Linux FileSystem Hierarchy Standard

Linux FileSystem Hierarchy Standard (FHS)

Software Requirements and Conventions Used

Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Linux distribution agnostic
Software N/A
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non-privileged user

Linux Filesystem Navigation Basics step by step instructions

The below instructions are the absolute minimum a beginner GNU/Linux user needs to master to be able to perform even the simplest tasks on a GNU/Linux command line. Once you learn the basics below, you are ready to move to more advanced command line topics.

  1. When you are working within a shell terminal, you are always operating in a particular directory. To determine which directory you are in, use the pwd command:
    student@linuxconfig:$ pwd /usr/local/bin 
    student@linuxconfig:$ cd 
    student@linuxconfig:$ pwd /home/student 
    student@linuxconfig:$
  2. Your home directory is the directory you are in when you first open the terminal. To go to your home directory from anywhere, just type cd command:
    student@linuxconfig:$ pwd
    /usr/local/bin
    student@linuxconfig:$ cd
    student@linuxconfig:$ pwd
    /home/student
    student@linuxconfig:$
  3. An absolute path name is one beginning with the / character, which signifies the root of the file system tree. Therefore, another way of going to your home directory is:
    student@linuxconfig:/etc$ cd /home/student
    student@linuxconfig:$ pwd
    /home/student
    student@linuxconfig:$

    For more information regarding the Relative vs Absolute path visit our bash scripting tutorial.

  4. A relative path is one which starts with the name of a directory connected to the current directory. For example, if you are in the /usr directory, then typing only cd bin (without preceding “bin” with “/”) has the following effect:
    student@linuxconfig:$ pwd
    /usr
    student@linuxconfig:$ cd bin
    student@linuxconfig:$ pwd
    /usr/bin
    student@linuxconfig:$

    and you go to /usr/bin rather than /usr/local/bin or /bin.

  5. To go to the directory containing the current working directory (also called the parent directory) type:
    student@linuxconfig:$ pwd
    /usr/bin
    student@linuxconfig:$ cd ..
    student@linuxconfig:$ pwd
    /usr
    student@linuxconfig:$
  6. The relative pathname of the current working directory is called . (the full stop). Therefore typing:
    student@linuxconfig:$ pwd
    /usr/bin
    student@linuxconfig:$ cd . 
    student@linuxconfig:$ pwd
    /usr/bin
    student@linuxconfig:$

    does not change the current working directory.



Comments and Discussions
Linux Forum