Pathnames types in Linux systems

Share this post to your friends !

This entry is part 2 of 2 in the series Linux commands: Part 2 - Navigation

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.

Absolute 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 /home/trungdung/Desktop/writebash.com.

pathnames-types-in-linux-systems-01 Pathnames types in Linux systems
Absolute pathnames in Linux system.

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 Pathnames

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.

pathnames-types-in-linux-systems-02 Pathnames types in Linux systems
Relative pathnames in Linux system.

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 pathname directory.

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.

Conclusion

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.

Continue reading the series«« Previous part: Command to change directory in Linux
If you liked this article, then please subscribe to our YouTube Channel for more video tutorials. You can also find us on Twitter and Facebook.


Share this post to your friends !
If you appreciate what we share in this blog, you can support us by:
  1. Stay connected to: Facebook | Twitter | Google Plus | YouTube
  2. Subscribe email to recieve new posts from us: Sign up now.
  3. Start your own blog with SSD VPS - Free Let's Encrypt SSL ($2.5/month).
  4. Become a Supporter - Make a contribution via PayPal.
  5. Support us by purchasing Ribbon Lite Child theme being using on this website.

We are thankful for your support.

single post bottom banner
«« »»

Got something to say? Join the discussion

Please keep in mind that all comments are subject to our Comment Policy. Your email address will not be published.
This site uses Akismet to reduce spam. Learn how your comment data is processed.