Installation guide
106 Chapter 11. Shell Prompt Basics
Figure 11-4. Sample ls Output for the /etc Directory
Here is a short list of some popular options to use with ls. Remember, you can view the full list by
reading the ls man page (man ls).
• -a — all. Lists all the files in the directory, including the hidden files (.filename). The .. and .
at the top of your list refer to the parent directory and the current directory, respectively.
• -l — long. Lists details about contents, including permissions (modes), owner, group, size, creation
date, whether the file is a link to somewhere else on the system and where its link points.
• -F — file type. Adds a symbol to the end of each listing. These symbols include / to indicate a
directory; @ to indicate a symbolic link to another file; and * to indicate an executable file.
• -r — reverse. Lists the contents of the directory from back to front.
• -R — recursive. This recursive option lists the contents of all directories (below the current direc-
tory) recursively.
• -S — size. Sorts files by their size.
A little later in this chapter, when we introduce you to pipes (see Section 11.10) and I/O redirections2-
managing-io (see Section 11.11.4), you will discover that there are other ways to view the contents of
a directory.
11.6. Locating Files and Directories
There will be times when you know a file or directory exists but you will not know where to find it.
Searching for a file or directory can be easier with the locate command.
With locate, you will see every file or directory whose name contains the search criterion. For
example, if you want to search for all files with the word finger in the name, type:
locate finger
The locate command uses a database to locate files and directories that have the word finger in
the file or directory name. The search results could include a file called finger.txt, a file called
pointerfinger.txt, a directory named fingerthumbnails, and so on.
Tip
To learn more about locate, read the locate man page (type man locate at a shell prompt).