
Book IX
Chapter 9
Linux Commands
761
Command Shell Basics
For normal Linux users, the command shell prompt character is a dollar sign
($). If you see a hash mark (#) as the prompt character, it means you’re
logged on as root. Whenever you see a hash prompt, you should be extra
careful about what you do because you can easily get yourself into trouble
by deleting important files or otherwise corrupting the system.
Editing commands
Most of the time, you just type commands using the keyboard. If you make
a mistake, you just type the command again, being careful not to repeat the
mistake. However, Linux shells have several built-in editing features that can
simplify the task of correcting a mistaken command or entering a sequence
of similar commands:
✦ If you want to repeat a command that you’ve used recently, press the
up-arrow key. This action recalls your most recently executed com-
mands. You can press Enter to execute a command as is, or you can edit
the command before you execute it.
✦ The shell has a handy auto-complete feature that can finish partially
spelled directory, file, or command names. Just type part of the name
and then press the Tab key. If you’ve typed enough for the shell to figure
out what you mean, the shell finishes the name for you. Otherwise, it
just beeps, in which case you can type a few more letters and try again.
In some cases, the shell displays a list of items that match what you’ve
typed so far to help you know what to type next.
Wildcards
Wildcards are one of the most powerful features of command shells. With
wildcards, you can process all the files that match a particular naming pat-
tern with a single command. For example, suppose that you have a folder
with 500 files in it, and you want to delete all the files that contain the letters
Y2K and end with .doc, which happens to be 50 files. If you try to do this in
GNOME, you’ll spend ten minutes picking these files out from the list. From a
shell, you can delete them all with the single command rm *Y2K*.doc.
You can use two basic wildcard characters. An asterisk (*) stands for any
number of characters, including zero, while an exclamation mark (!) stands
for just one character. Thus, !Text.doc matches files with names like
aText.doc, xText.doc, and 4Text.doc, but not abcText.doc or just
Text.doc. However, *Text.doc would match any of the names I mentioned.
71_625873-bk09ch09.indd 76171_625873-bk09ch09.indd 761 9/21/10 10:48 PM9/21/10 10:48 PM