Interpreting Linux Directory and File Listings – From the Output of the Linux ls Command
Running the Linux ls command at the Linux command line prompt shows a listing of directories and files.
The following is an example of a listing at the shell prompt of a directory named bin:
- d rwxr-x — 22 root root 4096 May 22 16:14 bin
The name of the directory (bin) appears at the far right.
At the left of this name is the time (16:14). If the directory were not created this year, the year would appear in place of the time. Next at the left is the date (May 22). At the left is the size of the directory, which is 4,096 bytes (4 K).
At the far left is a "d " and this indicates that the item is a directory.
The other items shown above, such as "rwxr-x — 22 root root", are permissions.
The following is a Linux ls command output example of a file named grep.1.gz:
- -rw-r – r– 1 root root 5907 Jul 17 2007 grep.1.gz The name of the file appears at the far right (grep.1.gz).
At the left of the name is the date that the file was created (July 17, 2007). At the left of that is the size of the file, which is 5,907 bytes (approximately 5.9 K).
At the far left is a "- ". This indicates that the item is a file.
The above file was created in 2,007. If the file was created this year, then the time that the file was created, in the form of hh: mm, would appear in place of the year.
When you run ls command and use the -l option, you see a series of characters at the left of each item in the directory listing. The table below shows the meaning of the far left character in a directory listing.
The Leftmost Characters in a Listing from the Output of the Linux ls Command
When using the -l option of the ls command, the – (dash) for file and the d for directory appear most often in the list that is output when the ls command is run.
Remember that directory names have a "d " at the far left of them and files have a "-".
The Linux concepts shown above apply to Slackware , Red Hat, Ubuntu, Fedora, and Debian Linux – and also ALL Linux distributions.