The reason behind
ls -a showing
.. has nothing to do with utility and everything to do with Unix (and Linux) filesystems.
Everything is a file.
Directories are really files that contain lists of files. "Inside" any given directory, because that is the perspective of the user, if not exactly the perspective of the filesystem, there are two special files.
- The first, called
., is a reference to the current working directory. This is used by people almost every day, when they do things like running a command in the current directory via
- The second, called
.. is a reference to the CWDs parent directory. Like
.. is used every day by everyone who desires to change directories to the parent directory via
The system call
getdents(), which is the workhorse on the system side of
ls, simply enumerates all files in a directory. (remember: everything is a file. devices, directories, sockets, etc. so they all show up)
From the utility side of things, the author(s) of the
ls command have provided a number of options, and combinations of options, that allow us to filter out certain pieces or types of information, for example @Gilles commented above that
ls -A will show all dotfile, with the exceptions of
... All of these options could be considered post-processing options. They affect what is displayed by
ls, not what is found by
There's really no reason to explicitly list
.., by default, since we all know they are there, what they are for, and when to use them.
It can definitely be helpful to be able to have some option to see them though, when you're troubleshooting strange permissions problems.
Check out the manpage for
getdents()¹. It explains a bit more about how it works, and includes the source code for a sample program that you can compile with
gcc -Wall, which lists all the files in a directory.
1. At least, the Ubuntu manpage for
getdents() seems to have the sample code.