Bash List Files in a Long Listing Format


Example

The ls command's -l option prints a specified directory's contents in a long listing format. If no directory is specified then, by default, the contents of the current directory are listed.

ls -l /etc

Example Output:

total 1204
drwxr-xr-x  3 root root    4096 Apr 21 03:44 acpi
-rw-r--r--  1 root root    3028 Apr 21 03:38 adduser.conf
drwxr-xr-x  2 root root    4096 Jun 11 20:42 alternatives
...

The output first displays total, which indicates the total size in blocks of all the files in the listed directory. It then displays eight columns of information for each file in the listed directory. Below are the details for each column in the output:

Column No.ExampleDescription
1.1dFile type (see table below)
1.2rwxr-xr-xPermission string
23Number of hard links
3rootOwner name
4rootOwner group
54096File size in bytes
6Apr 21 03:44Modification time
7acpiFile name

File Type

The file type can be one of any of the following characters.

CharacterFile Type
-Regular file
bBlock special file
cCharacter special file
CHigh performance ("contiguous data") file
dDirectory
DDoor (special IPC file in Solaris 2.5+ only)
lSymbolic link
MOff-line ("migrated") file (Cray DMF)
nNetwork special file (HP-UX)
pFIFO (named pipe)
PPort (special system file in Solaris 10+ only)
sSocket
?Some other file type