5.4 Listing Directory Contents
5.4.1 The ls command
To determine the contents of a directory, use the ls  (list) command. This command will display a listing of all files and directories within the current directory or specified directories. If no pathname is given as an argument, ls will display the contents of the current directory. The ls  command will list any subdirectories and files that are in the current working directory if a pathname is specified. It will also default to a wide listing display. There are many options that can be used with the ls command which makes it one of the more flexible and useful UNIX commands. 
Command Format:
ls [-option(s)] [pathname[s]]

Figure shows some examples using the ls command with various options assuming your current directory is /home/user2. Refer to the Class File Tree Structure while reviewing the examples. Example 1 is the basic ls command by itself with no options or directory specified. It returns a listing of all directories and files in the current directory. Note that you cannot tell whether the listed item is a directory or file unless the name indicates it. Example 2 specifies a relative pathname dir1 which is a subdirectory of /home/users. Only files and directories in dir1 will be listed. Example 3 specifies an absolute pathname of /var/mail which is in another part of the directory tree. Only files and directories from /var/mail will be listed.

Interactive Media Activity (Flash, 95 kB)
  The ls command

In this media activity, you are logged in as user2 and your current working directory is: /home/user2/dir1. Refer to the Class File Tree Structure by clicking the 'tree' button located on the Menu Bar and type the commands that would accomplish the requested objectives. 
Note: Be sure to press enter after each one. Click on step 1 to begin.