Displaying Permissions and Status (ls-l)

Use the -l with the ls command to display a long listing of files and directories in alphabetical order.

Figure 3–2 Displaying Permissions and Status

The first character on the line indicates the file type. A dash (-) indicates an ordinary file, a d indicates a directory, and other characters can indicate other special file types.

The next nine characters indicate the permissions for the file or directory. The nine characters consist of three groups of three, showing the permissions for the owner, the owner's group, and the world, respectively. The permissions for emptyfile are rw-r--r--, indicating that the owner can read and write this file, everyone can read it, and no one can execute it. The permissions for the directory veggies2 are rwxr-xr-x, indicating that everyone has read and execute permissions, but only the owner can write to it.

In addition to file permissions, the display shows the following information:

Number of links to this file or directory

Name of the owner (user2 in this case)

Name of the group owner (users in this case)

Number of bytes (characters) in the file

Date and time the file or directory was last updated

Name of the file or directory

Use the cd command to move to your home directory, and try the ls-l command.

Now type the following command, where dirname is the name of an actual directory in your file system.

$ ls -ldirname

When you give the name of a directory, the ls-l command prints information on all the files and directories in that directory.