FLOPPIX Home | FAQ | Download | Labs | ToC | Back |  Next 

Directory listings


The ls command - examples of common options:
The ls command is used to show the contents of a directory. Some of the options of the ls command are:

  1. ls
    List the contents of the current directory
  2. ls   /etc
    List the contents of the /etc directory
  3. ls   -a
    Display all entries in the current directory including those beginning with a period. File and directory names that start with a period are "hidden" files in unix; they do not appear in ordinary directory listings.
  4. ls   -l
    Display a long or detailed listing of the current directory, one line of data for each entry.
  5. ls  -al  /etc
    Display a long listing of the /etc directory including "hidden" files or subdirectories.
  6. ls   -h
    The -h option is the "help" option, this gives a list of all of the options for the ls command and brief explanations.
  7. To get a list of all of the other options of ls, use the man command. [ man ls ]

Some of the fields in a directory listing entry:

There are a number of things that appear in a unix directory listing:

  1. Permissions:
    Users and the system administrator need a way to control the way other users can access files and directories. The standard unix filesystem does this with permissions. Each file has read, write and execute permisssions set for the owner, the group and then all other users.
  2. Links:
    Users can create links to existing files. The filesystem keeps track of the number of links.
  3. Owner and group:
    Unix is a multi-user operating system. For each file and directory, the filesystem keeps track of the file owner and group.
  4. Size in bytes:
  5. Date:
    The unix filesystem actually maintains 3 dates for each file: the last access date, the last modification date (the last date that the file contents were modified) and the last change date (the last date that the file "inode" or directory entry was modified). The date that appears in a standard directory entry is the last modification date.
  6. Filename:

A sample directory entry:
       -rwxrw-r-- 1 xyz staff  12 Mar 7 12:35 runme 


  1. Load floppix and login using your own initials.
  2. In a previous lab, the directory map showed the following directories under /.
    bin, boot, dev, etc, home, lib, mnt, proc, sbin, tmp, usr, var
    Look at the directory listing for the root directory on floppix.
    Are there any directories in the above list that are not present in floppix?
    Are there any top-level directories that are present in floppix and not listed above?
  3. Change to the root directory and try to list the contents of each of the top-level directories.
    Which of these directories are empty? _________________________
    Ordinary users cannot view the contents of some of these directories.
    Which ones? _________________________
    What are the permissions for those directories? _________________________
  4. What is the purpose of the -F option of the ls command. Look this up using the man pages. _________________________
  5. Try running the commands:
       ls   -F   /home
       ls   -F   /bin
    What symbol does the -F option use to identify directories? __________
    What symbol does the -F option use to idenfify executable files? __________

Questions & Answers:

  1. Interpret this directory entry:
    drwxr-xr-- 2 abc users  1024  Mar 7 12:35 ddd
    Answer: The directory entry specifies:

Copyright © L. M. MacEwan
FLOPPIX Home | FAQ | Download | Labs | ToC | Back |  Next