Page 166 - DCAP602_NETWORK_OPERATING_SYSTEMS_I
P. 166
Network Operating Systems-I
notes file Listings
The ls command, used to view lists of files in any directory to which a user has execute permission,
has many interesting options. For example:
$ ls -liah *
22684 -rw-r--r-- 1 bluher users 952 Dec 28 18:43 .profile
19942 -rw-r--r-- 1 scalish users 30 Jan 3 20:00 test2.out
925 -rwxr-xr-x 1 scalish users 378 Sep 2 2002 test.sh
The listing above shows 8 columns:
1. The first column indicates the inode of the file, because we used the -i option. The remaining
columns are normally displayed with the -l option.
2. The second column shows the file type and file access permissions.
3. The third shows the number of links, including directories.
4. The fourth and fifth columns show the owner and the group owner of the files. Here, the
owner “bluher” belongs to the group “users”.
5. The sixth column displays the file size with the units displayed, rather than the default
number of bytes, because we used the -h option.
6. The seventh column shows the date, which looks like three columns consisting of the
month, day and year or time of day.
7. The eighth column has the filenames. Use of -a in the option list causes the list of hidden
files, like .profile, to be included in the listing.
Here are some of the most commonly used ls flags:
-a Lists all files, including hidden ones.
-l Displays the file list in long format, including file details like size, time stamp, and owner.
-F Adds a slash after the name for directories, an asterisk for executables, and an at sign (@) for
linked files.
-r Reverses the sort order (alphabetic or time).
-t Sorts the list by the time each file was created.
-R will the subdirectories recursively, which means it will show all the directories and files within
the specified directory.
-s will also show you the size of the files (in blocks, not bytes)
-h will show the size in “human readable format” (i.e. 4K, 16M, 1G etc). Of course you must use
this option in conjunction with the -s option.
160 LoveLy professionaL university