You took a quick look around your home directory in earlier module. Now it is time to take a more detailed look. And ls is still the command to use.
ls has several options that allow you to view additional information about your files. Among the more commonly used are :
This line breaks down into the following information.
The 1st column shows filetype and access permission for various types of users.
The 1st character of this column is the file type and will indicate one of the following : - (regular file), d (directory), s (symbolic), c (character special), b (block special), p (named pipe). Some Unix systems may have additional file types with the appropriate symbolic character.
The next 9 characters indicate access settings for the file.
The Unix system allows each account owner to create files and own the files created. It also requires a file to be associated with a known group.
When a user's account is created, the user is assigned an unique user id and a group association.
Every user belongs to a default group. Users can belong to any number of additional groups. Files created by a user can be associated to any group recognized by the system but to only one. Normally, this will be default group of the user as identified from the user's entry in the password/account system, but at the user's or system administrator's discretion, a different group association can be implemented.
The group association allows the user (owner) to control specific access to file by that group. And any member of the associated group to have custom access permissions.
However, only one user can own a file and a user does not belong to all groups, so the Unix system provides for another class of file access on the system. This class is referred to as "other". An individual who is not the owner of the file of interest and doesn't not belong to the group associated with the file is an "other".
The 9 access status characters of the 1st column are broken into three groups of three characters indicating access permissions for the owner (user id), the group association (group id), or other (everyone else).
Each user type group is three characters long and controls whether a file can be read (r), written (w), or executed (x). If a particular permission is off, a (-) will appear in the appropriate location.
For example, ls -l fit displays the following :
-rwxr-x--x 1 gilberg staff 12 May 17 08:45 fit
The 1st character "-" is in the filetype column and indicates that this is a regular file. Then next three characters "rwx" indicate that the owner of the file "gilberg" has permission to read the file, write or modify it, and execute it. The next three characters "r-x" indicate that anyone in the group "staff" may read (or copy) the file and execute it but NOT make changes to this file. Finally, the last 3 characters in the 1st column, "--x", indicates that anyone else on the system may execute it but not read or change it.
Curiously, if a file's "group" permission is more restrictive than "other"s permissions and a user other that the owner belongs to the group, the more restrictive permissions will apply to that user.
The next column in the "ls -l" display is the link count. The link count represents the number of filenames assigned to this particular file. When and only when link count becomes zero will the Unix os considers the file deleted and make the storage space available to other users and files. We will discuss linking in detail in a later module.
The next two columns indicate the owner's login name and the associated group name respectively. If you use the -n option rather than -l, you will see the numeric values, the uid and gid, rather than the user and group names.
Column 5 indicates the size of the file in bytes. The next column grouping indicates the date and time the file was last modified. And the last column indicates the file's assigned name for this entry in this directory listing.
ls -d
ls -i
ls -q
ls -b
ls -1
ls -r
ls -lu
ls -lc
ls -t