Pathnames types in Linux systems

by Daniel Pham
Published: Updated:
This entry is part 2 of 2 in the series Linux commands: Part 2 - Navigation

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.

absolute pathnames in linux systemystem
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.

relate pathnames in linux system
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.

(This is an article from my old blog that has been inactive for a long time, I don’t want to throw it away so I will keep it and hope it helps someone).

0 0 votes
Article Rating
Series Navigation«« Previous part: Command to change directory in Linux

You may also like

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments

DevOps Lite is a personal blog specializing in technology with main topics about DevOps, DevSecOps, SRE and System Administrator. Articles are shared for free and contributed to the community.

SUPPORT US

FOLLOW US

Subscribe my Newsletter for new blog posts. Stay updated from your inbox!

© 2021-2024 DevOpsLite.com – All rights reserved.

Please write sources “DevOpsLite.com” when using articles from this website.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More

2
0
Would love your thoughts, please comment.x
()
x

Adblock Detected

Please support us by disabling your AdBlocker extension from your browsers for our website.