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.


Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>