The ls Command

The ls command lists all of the files and subdirectories you have in a given directory.

For example,

stealth% ls
ariel.pubkey.asc        krbauth-problem         server-misc
asn1                    ldap                    sh-lost
bin                     linux                   signatures
ca-admin                logs                    sounds
...

shows some of the files and directories in one user's home directory (the listing has been truncated for brevity's sake).

To look at details about these files and directories, you can use ls -l which shows a long listing:

stealth% ls -l 
total 6100
-rwxr-xr-x  1 ariel         725 Jul 10 15:07 %backup%~
drwxr-xr-x  2 ariel         512 Jun 13 16:19 Mail
drwxr-xr-x  2 ariel         512 Jan  3  1997 News
-rw-r--r--  1 ariel       11476 Jul 15 15:20 Xax500
-rw-------  1 ariel        2273 Jul 25 13:18 ais-off
....

The entries which start with a d, like the Mail and News entries above, are directories. Entries that start with an l are symbolic links. The other entries are files.

The next several letters, rwx and some hyphens, indicates who can read, write, or execute the files. The first three letters show what the owner can do: usually, these are r (read), w (write), and x (execute). They are always shown in the order rwx. If one of them is missing and a hyphen is in its place, e.g. r-x, the permission corresponding to the missing letter has been taken away. In the above example, the owner does not have execute permissions for Xax500 because the x in the first rwx pattern has been replaced with a hyphen.

The next three letters indicate the permissions for the group associated with the file. This group can be seen by using ls -lg:

stealth% ls -lg | more
total 6100
-rwxr-xr-x  1 ariel    root          725 Jul 10 15:07 %backup%~
drwxr-xr-x  2 ariel    staff         512 Jun 13 16:19 Mail
drwxr-xr-x  2 ariel    rad           512 Jan  3  1997 News
-rw-r--r--  1 ariel    root        11476 Jul 15 15:20 Xax500
-rw-------  1 ariel    root         2273 Jul 25 13:18 ais-off
...

In the above example, the members of the staff group cannot write into the Mail directory because the w letter in the second rwx pattern has been replaced by a hyphen.

The next three letters indicate the permissions for everyone else. In the above example, people outside of the root group and the owner cannot read, write, or execute the ais-off file, because all three letters in the third rwx pattern have been replaced by hyphens.

If you want to see information about just one file, you can use ls -l filename:

stealth% ls -l ais-off 
-rw-------  1 ariel        2273 Jul 25 13:18 ais-off

If you want to see the information about one directory, but not the files in it, you need to use ls -ld:

stealth% ls -ld Mail
drwxr-xr-x  2 ariel         512 Jun 13 16:19 Mail

You can see information about symbolic links by using the ls -l command:

stealth% ls -l fileserver-tests
lrwxrwxrwx  1 ariel          32 Jun 16 10:04 fileserver-tests -> /stealth1/ariel/fileserver-tests

And if you want information about the file or directory the link points to, you can use ls -l on that file, or ls -ld if it is a directory:

stealth% ls -ld /stealth1/ariel/fileserver-tests
drwxr-xr-x  5 ariel         512 Jan  3  1997 /stealth1/ariel/fileserver-tests

More information about this command is available using the command man ls.