There’s a Lot in the Dot: Filesystem Permissions and Pathnames (Part 1)

Beginning with a brief tour of the filesystem, we take you deep into the dot (.) of your directory listing so you can get the most from your CLI.

Linux filesystem permissions and pathnames can cause lots of confusion. Users type long pathnames when a short one would do as well, and set wide-open access permissions when a more-secure setting would be easy if the concepts were more clear.

This article and the next take a unique approach: understanding the dot (.) that you’ve probably seen in directory listings.

Don’t need the introductory stuff? Skip to part two. Need more background? Check out the Wizard Boot Camp series.

What’s “in” a directory

Linux filesystems hold files and other objects (e.g. symbolic links, devices like disks, and directories) grouped into directories (known as folders on other operating systems). It’s important to understand that a directory doesn’t actually contain the objects; it holds references to those objects. The references are called hard links.

To access something in the filesystem, a program looks into a directory using a system call. From there, it finds the link to the actual object on the disk (or whatever device the object is stored on). Then it locates the object through its index number, as we’ll see soon.

Each directory has at least two names. One of those names is a dot (.). Every directory on the filesystem has a name (a hard link) of dot.

Most GUI filesystem browsers don’t show these dot entries. You can see them with the ls utility and its -a (“all”) option.

By default, if you don’t specify something to list, ls lists its current directory. You can also specify a directory, like ls /bin or ls .. (to list the dot-dot entry). Adding the -i or --inode option shows the index numbers. This directory has a parent and “grandparent” directory, as we’ll see later. And pwd shows the directory’s absolute pathname:

$ # Listing I (child directory)
$ ls
bin  foo
$ ls -a
.  ..  bin  foo
$ ls -ai
5423 .   58 ..   5425 bin   5424 foo
$ ls -ai .
5423 .   58 ..   5425 bin   5424 foo
$ pwd

Notice that ls -a and ls -a . give the same result. Both list the directory named dot — the current directory. If your ls shows slashes after the names of some entries, it’s been aliased to use the option -F. For example:

$ ls -aF
./  ../  bin/  foo

The listings show the directory’s four entries (hard links): ., .., bin and foo. The first three are links to directories, and the fourth is a plain file. Each entry has its index number; for instance, this directory’s index number (listed before its dot entry) is 5423.

If you list various directories around the filesystem, you’ll see that every directory has an entry named .. They also have .. (two dots), which is a link to that directory’s parent — in other words, the directory that contains the directory. Let’s list the parent directory in two ways: by telling ls to list .., then by changing the shell’s current directory to .. and listing the current directory:

$ # Listing II (parent directory)
$ ls -ai ..
 58 .   2 ..   5423 jpeek
$ cd ..
$ ls -ai
 58 .   2 ..   5423 jpeek
$ pwd

Please compare Listing II with Listing I. What do they have in common?

  • Both listings show a hard link with index number 5423. In Listing I (the child directory), that entry is named . (dot). In Listing II (the parent), the link to the same directory (index 5423) is named jpeek.
  • Both also have an entry for index number 58. In the child directory, it’s named .. (dot dot), and in the parent it’s named . (dot).

So, the same directory can be referred to in more than one way:

  • When you’re in the directory itself (when it’s your current directory), you can call it . (dot).
  • When you’re in its parent directory, you call it by its given name (for example, jpeek).

To find the parent of any directory, you can always open .. (dot dot). The filesystem’s tree structure, tied together with .. and . entries, is built automatically each time you create a new directory.

One directory in the filesystem is special because it’s its own parent. That’s the root directory. Let’s list it now (for clarity, we’ll omit a lot of the entries):

$ # Listing III (root directory)
$ ls -ai ..
 2 .   2 ..   58 home
$ cd ..
$ ls -ai
 2 .   2 ..   58 home
$ pwd

So, if you’re currently in the root directory and you type cd .., you’ll stay where you are.

I-number confusion

Each filesystem has its own set of index numbers. So, as you’re looking around with ls -ai, remember that there may be more than one link with, say, number 5423. You’ll also find inconsistencies where filesystems are mounted. For example, at the root directory of a system where /home is mounted on root:

$ pwd
$ ls -ia
 2 .   2 ..   24577 home
$ ls -ia home
 123 .   123 ..

Of course, listing a bunch of directory entries doesn’t do you much good — except to see what’s in the filesystem. If you were searching for filesystem corruption, you could check these things yourself. (That’s one of the things done by fsck, the filesystem consistency checking program.) What’s more useful is to use this knowledge so you can specify filesystem objects that you want to access. To do that, you use pathnames and, sometimes, the current directory. The next column covers pathnames in detail.

Let’s wrap up by looking at a diagram of a simplified filesystem, Figure One. Click for a larger view. (Opening in a separate window or tab may be easier.)

Figure 1: Simplified filesystem diagram
Figure 1: Simplified filesystem diagram

To make things simpler, the diagram omits details such as the system of nodes and indirection that handles metadata (like file access permissions and link counts) and the pointers to the actual disk blocks. This diagram is to help you follow where the links point.

For instance, in any directory, opening . (dot) opens the directory itself; that’s what’s meant by the arrow starting at . pointing to the directory. As another example, you can see that the entry named jpeek from directory 58 points to directory 5423, as does the entry named . in directory 5423 and the .. entry in directory 5425. All three of those entries refer to the same directory.

If this seems even a bit fuzzy, please look through the diagram and open a terminal window to try things on your own filesystem. Then you’ll be ready for part two on pathnames and permissions.

Comments on "There’s a Lot in the Dot: Filesystem Permissions and Pathnames (Part 1)"



This post is really for the Linux Magazine people.

This article, as well as many others, is very interesting, and I would like to print a copy.

But, for some reason, the Linux Magazine people do not offer a way to obtain a printer friendly version without the advertising and with an expanded line width. At least it is not obvious to me how to do this.

Why is this?

Take a look at HPCWIRE magazine, there, one can find great articles as well but print them in a user friendly manner.


A. R. Rossi


Yeah that sucks. How about cutting/pasting/editing in your favourite word processing program.

I\’ve had a firefox plugin before called nuke (something), that let\’s you remove parts of the page – not sure if that would work with print.

Or try printing selection, probably depends on OS and browser.

We have problem of selinux connected directory and files with permission of . in permission granted. After disabling selinux, we are unable to change this permission to default. Due to this reason, we tried to enable selinux again and changed permission with relabel command. It worked.

hi, why is there a dot in ls permission? fe: lrwxrwxrwx. – what does this dot mean? Thx a lot.

I appreciate you sharing this blog post.

Greetings from Ohio! I’m bored to tears at work so I decided to check out your site on my iphone during lunch break. I enjoy the knowledge you present here and can’t wait to take a look when I get home. I’m amazed at how quick your blog loaded on my cell phone .. I’m not even using WIFI, just 3G .. Anyways, very good blog!

What i don’t realize is in truth how you’re now not actually a lot more neatly-favored than you might be right now. You’re very intelligent. You already know therefore considerably in relation to this subject, produced me for my part believe it from a lot of numerous angles. Its like men and women are not involved unless it is one thing to do with Lady gaga! Your own stuffs nice. All the time maintain it up!

I just could not leave your site before suggesting that I actually enjoyed the usual information a person supply in your guests? Is gonna be back ceaselessly to inspect new posts

I like this web blog very much so much fantastic information.

I truly appreciate this post. I’ve been looking all over for this! Thank goodness I found it on Bing. You’ve made my day! Thanks again

This is a very good tips especially to those new to blogosphere, brief and accurate information… Thanks for sharing this one. A must read article.

Hey there, I think your site might be having browser compatibility issues. When I look at your website in Chrome, it looks fine but when opening in Internet Explorer, it has some overlapping. I just wanted to give you a quick heads up! Other then that, fantastic blog!

Just beneath, are many absolutely not associated internet sites to ours, nevertheless, they may be certainly really worth going over.

I am constantly browsing online for ideas that can aid me. Thx!

I love the efforts you have put in this, thank you for all the great posts.

The information and facts mentioned in the report are several of the most beneficial obtainable.

Here are some links to websites that we link to simply because we assume they’re worth visiting.

Wow, great blog.Thanks Again. Cool.

Here is a superb Weblog You might Locate Fascinating that we encourage you to visit.

Hi my loved one! I wish to say that this post is awesome, great written and come with approximately all important infos. I’d like to look more posts like this .

Very nice post. I just stumbled upon your weblog and wanted to say that I have
really enjoyed surfing around your blog posts. After all
I’ll be subscribing to your rss feed and I hope you write again very soon!

Although sites we backlink to below are considerably not connected to ours, we really feel they are truly really worth a go as a result of, so possess a look.

Here is a superb Weblog You might Obtain Interesting that we encourage you to visit.

That will be the end of this report. Right here you?ll discover some web-sites that we assume you?ll enjoy, just click the hyperlinks.

The time to read or go to the subject material or sites we’ve linked to beneath.

One of our guests not too long ago proposed the following website.

Usually I don’t read post on blogs, but I would like to say that this write-up very compelled me to take a look at and do so! Your writing style has been amazed me. Thank you, very nice article.

Check below, are some entirely unrelated web-sites to ours, even so, they are most trustworthy sources that we use.

Oh my goodness! Impressive article dude! Thanks a lot, However I am just having troubles with your RSS.
I don’t know why I cannot sign up to it. Is there anybody else
having identical RSS problems? Anybody that knows the solution are you able to kindly respond?

My web blog :: DeanNBoehner

Here are some of the web-sites we suggest for our visitors.

Here is a good Weblog You might Come across Exciting that we encourage you to visit.

Just beneath, are many absolutely not connected sites to ours, on the other hand, they are surely really worth going over.

The data talked about inside the post are a few of the best accessible.

One of our visitors not too long ago encouraged the following website.

I have been surfing online greater than 2 hours today, yet I never found any
interesting article like yours. It is actually pretty worth enough for me.

I think, if all site owners and bloggers made good content as
you may did, the web will be a lot more useful than in the past.

Also visit my web page ElzaDMention

We prefer to honor several other internet sites around the net, even if they aren?t linked to us, by linking to them. Underneath are some webpages really worth checking out.

The time to study or go to the subject material or sites we have linked to beneath.

Always a massive fan of linking to bloggers that I really like but do not get a lot of link adore from.

Here are some hyperlinks to websites that we link to mainly because we assume they’re worth visiting.

Below you will uncover the link to some websites that we assume you’ll want to visit.

Very couple of web-sites that take place to be comprehensive beneath, from our point of view are undoubtedly effectively worth checking out.

Leave a Reply