[Next] [Previous] [Up] [Top] [Contents]

3.6 Directory Navigation and Control

3.6.5 ls - list directory contents

The command to list your directories and files is ls. With options it can provide information about the size, type of file, permissions, dates of file creation, change and access.


ls [options] [argument]

Common Options

When no argument is used, the listing will be of the current directory. There are many very useful options for the ls command. A listing of many of them follows. When using the command, string the desired options together preceded by "-".

-a lists all files, including those beginning with a dot (.).

-d lists only names of directories, not the files in the directory

-F indicates type of entry with a trailing symbol:

directories /

sockets =

symbolic links @

executables *

-g displays Unix group assigned to the file, requires the -l option (BSD only)

-or- on an SVR4 machine, e.g. Solaris, this option has the opposite effect

-L if the file is a symbolic link, lists the information for the file or directory the link references, not the information for the link itself

-l long listing: lists the mode, link information, owner, size, last modification (time). If the file is a symbolic link, an arrow (-->) precedes the pathname of the linked-to file.

The mode field is given by the -l option and consists of 10 characters. The first character is one of the following:


d directory

- plain file

b block-type special file

c character-type special file

l symbolic link

s socket

The next 9 characters are in 3 sets of 3 characters each. They indicate the file access permissions: the first 3 characters refer to the permissions for the user, the next three for the users in the Unix group assigned to the file, and the last 3 to the permissions for other users on the system. Designations are as follows:

r read permission
w write permission
x execute permission
- no permission

There are a few less commonly used permission designations for special circumstances. These are explained in the man page for ls.


To list the files in a directory:

% ls

demofiles frank linda

To list all files in a directory, including the hidden (dot) files try:

% ls -a

. .cshrc .history .plan .rhosts frank

.. .emacs .login .profile demofiles linda

To get a long listing:

% ls -al

total 24

drwxr-sr-x 5 workshop acs 512 Jun 7 11:12 .

drwxr-xr-x 6 root sys 512 May 29 09:59 ..

-rwxr-xr-x 1 workshop acs 532 May 20 15:31 .cshrc

-rw------- 1 workshop acs 525 May 20 21:29 .emacs

-rw------- 1 workshop acs 622 May 24 12:13 .history

-rwxr-xr-x 1 workshop acs 238 May 14 09:44 .login

-rw-r--r-- 1 workshop acs 273 May 22 23:53 .plan

-rwxr-xr-x 1 workshop acs 413 May 14 09:36 .profile

-rw------- 1 workshop acs 49 May 20 20:23 .rhosts

drwx------ 3 workshop acs 512 May 24 11:18 demofiles

drwx------ 2 workshop acs 512 May 21 10:48 frank

drwx------ 3 workshop acs 512 May 24 10:59 linda

Introduction to Unix - 14 AUG 1996
[Next] [Previous] [Up] [Top] [Contents]