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
Software Requirements and Conventions Used
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.- 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:$ - 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:$ - 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
For more information regarding the Relative vs Absolute path visit our bash scripting tutorial.
student@linuxconfig:$ pwd
/home/student
student@linuxconfig:$ - 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 onlycd bin
(without preceding "bin" with "/") has the following effect:student@linuxconfig:$ pwd
and you go to
/usr
student@linuxconfig:$ cd bin
student@linuxconfig:$ pwd
/usr/bin
student@linuxconfig:$/usr/bin
rather than/usr/local/bin
or/bin
. - 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:$ - The relative pathname of the current working directory is called
.
(the full stop). Therefore typing:student@linuxconfig:$ pwd
does not change the current working directory.
/usr/bin
student@linuxconfig:$ cd .
student@linuxconfig:$ pwd
/usr/bin
student@linuxconfig:$