WriteBash - In this article, we talk about the pathnames types in Linux systems. Moving on Linux uses pathname, which you will have to do regularly, so understanding it will help you a lot.
On Linux systems, when you move from one directory to another, when you work on files and folders. One thing you must know for sure is the pathnames.
The absolute path is the type of path starting with the root directory, denoted by the first
/. Following it is the directory tree that leads to the file or target folder you want to work with.
In the example image below, you can see that I have displayed the absolute path with both the GUI image and the command line. In this example, I want to go to the writebash.com directory, which contains the hello_world script file. Pathname in this example is
You can see the path to the file hello_world starting with
/, followed by the directories:
- home: home directory of all users on the computer.
- trungdung: my home directory, username on my demo computer is trungdung.
- Desktop: the folder represents my desktop.
- writebash: directory containing hello_world script file.
When displayed on the command line, the directories are serialized with the
/. In a simple way, absolute pathnames are the type of path you have to go from the computer’s root directory, going through each subdirectory until you reach the destination you want.
Relative pathname is another type of pathname, it is different from absolute in the starting feature. While the absolute pathname starts from the root directory and ends at the destination directory, relative pathname starts from the working directory and ends at the destination directory.
Take the example above, when I type the
ls -alcommand to display the content of the writebash.com directory. At that time, the writebash.com folder is the directory I’m working on or is the working directory.
Relative pathname in Linux displayed by 2 symbols below.
Dot (.): The character dot
. refers to the working directory.
In the image above, you can see when I type the
ls -al . command then it still lists the content of the
pathname directory. So with the dot here it is the
Dot Dot (..): The character dot dot
.. refers to the parent directory of the working directory.
In the image above, I type 2 commands
ls -al .. and
cd ... With the
ls command, you can see that it listed the content of the writebash.com directory. As for the
cd command, the command line pointer has moved to the writebash.com directory
So writebash.com in this example is the parent directory of the pathname directory (also the folder I was working on earlier). And the
.. mark is displayed for the writebash.com folder itself in this case.
There are two types of pathnames in Linux that are absolute pathnames and relative pathnames. Absolute pathnames start from the root directory
/ and end with the destination directory/file. Ralative pathnames start from the working directory
. and end with the destination directory/file.
If you appreciate what we share in this blog, you can support us by:
- Stay connected to: Facebook | Twitter | Google Plus | YouTube
- Subscribe email to recieve new posts from us: Sign up now.
- Start your own blog with SSD VPS - Free Let's Encrypt SSL ($2.5/month).
- Become a Supporter - Make a contribution via PayPal.
- Support us by purchasing Ribbon Lite Child theme being using on this website.
We are thankful for your support.