Chapter 6 covers), type ls and press Enter. (This is positively the last time we nag you to press Enter.) This command stands for list, but could the lazy typists who wrote UNIX have used the other two letters? No-o-o-o-o. This command lists all the files in your working directory. (Chapter 6 discusses directories and how to make lots of them.) The ls command just shows the names of the files in alphabetical order, like this:
bin/ budget-02 budget-03 budget-04 daveg draft
jordan Mail/ meg news.junk zac
Linux In some Linux systems, if the directory contains subdirectories, the subdirectory names appear in a different color (if your screen handles colors), which is very handy. In BSD UNIX, subdirectory names also have a slash after them. (Chapter 6 talks about subdirectories, if you’re wondering what we are talking about.)
Let’s see the nitty-gritty details
For more information about your files, use the -l option (long form listing):
ls -l
That’s a small letter l, by the way, not a number one. This option tells ls to display tons of information about your files. Each line looks like this: -rw-r--r-- 1 johnl users 250 Apr 6 09:57 junk3
Later in this chapter, in the section “Who can do what?” we explain all the information in this listing. For now, just notice that the right-hand part of the line shows the size of the file (250 characters, in this example), the date and time the file was last modified, and the filename.
Tip For shell-less Web site owners
A lot of people use UNIX only because they happen to have a Web site that’s physically located on a UNIX machine. If you’re one of these reluctant UNIX just-barely-users, you probably don’t have access to a UNIX shell, but instead only use an FTP program to move files to and from your Web server (see Chapters 19 and 20).Perhaps surprisingly, most of what’s in this chapter still applies to you. All the same rules about filenames and permissions still apply, and most FTP programs have an ls command that works about the same as the shell version.When you’re choosing names for your files, remember that upper- and lowercase are different, so you probably should make them all lowercase. Web servers use the filename to determine the type of material in a file, so HTML Web pages end with l , GIF icons with .gif , JPEG pictures with .jpeg , and so forth. (Unlike some other systems, UNIX systems do not encourage you to abbreviate all the file types to three letters if the name is longer.)
Lots of UNIX commands have options. (They are also called switches because you switch the options on and off by typing or not typing them when you type the command. True geeks call them flags.) Options make commands both more versatile and more confusing. Probably the most widely used option is the -l option for the ls command, which tells ls to display lots of information about each file. When you type a command with one or more options, keep this list of rules handy:
Leave a space after the command name (the command ls , for example) and before the option (the -l part).
Type a hyphen as the first character of the option (-l, for example).
Type a space after the option if you want to type more information on the command line after the option.
If you want to include more than one option, type another space, another hyphen, and the next option. You can usually string multiple options together after one hyphen; for example, -al means that you want option a and option l .
Making files come out of hiding
You may have more files in your directory than you think. UNIX enables you to make things called hidden files, which are just like regular files except that they don’t appear in normal ls listings. Making a hidden file is easy — just start its filename with a period.You can see your hidden files by typing
ls -a
To see all the information about your hidden files, type
ls -al
This command combines the -a and -l options together so that you see the long version of the complete listing of files. You can get the same thing by typing
ls -a -l
but that requires typing an extra character and an extra space, an anathema to lazy UNIX typists.
Tip Making a long listing stop and start when you’re ready
If you have a large number of files, the ls listing may fly right off the top of your screen. If you have this problem, type this line:
ls | more
The vertical bar is called a pipe (we talk more about the pipe in Chapter 7). The | more option after the basic ls command tells UNIX to stop listing information to the screen just before the first file disappears from view. Press the spacebar to see the next screen of filenames.