Home > Articles

Learning About Commands

  • Print
  • + Share This
This chapter is from the book

This chapter is from the book

In Chapter 2, "The Basics," you started learning about some basic system commands. You covered a lot, but even so, much was left out. The ls command is an incredibly rich, powerful tool, with far more options than were provided in Chapter 2. So how can you learn more about that command or others that pique your interest? And how can you discover commands if you don't even know their names? That's where this chapter comes in. Here you will find out how to learn more about the commands you already know, those you know you don't know, and even those that you don't know that you don't know!

Let's start with the two 800-pound gorillas—man and info—and move from there to some smaller, more precise commands that actually use much of the data collected by man. By the time you're finished, you'll be ready to start learning about the huge variety of tools available to you in your shell environment.

Find Out About Commands with man

man ls

Want to find out about a Linux command? Why, it's easy! Let's say you want to find out more about the ls command. Enter man ls , and the man (short for manual) page appears, chock full of info about the various facets of ls. Try the same thing for some of the other commands you've examined in this book. You'll find man pages for (almost) all of them.

Still, as useful as man pages are, they still have problems. You have to know the name of a command to really use them (although there are ways around that particular issue), and they're sometimes out of date and missing the latest features of a command. They don't always exist for every command, which can be annoying. But worst of all, even if you find one that describes a command in which you're interested and it's up to date, you might still have a big problem: It might be next to useless.

The same developers who write the programs usually (but not always) write the man pages. Most of the developers who write applications included with a Linux distribution are excellent programmers, but not always effective writers or explainers of their own work. They know how things work, but they too often forget that users don't know the things that the developers find obvious and intuitive.

With all of those problems, however, man pages are still a good resource for Linux users at all levels of experience. If you're going to use Linux on the command line, you need to learn how to use and read man pages.

As stated before, using this command isn't hard. Just enter man , followed by the command about which you want to learn more.

$ man ls
LS(1)     User Commands     LS(1)
  ls - list directory contents
  ls [OPTION]... [FILE]...
  List information about the FILEs (the current
  directory by default).
  Sort entries alphabetically if none of -cftuSUX
  nor --sort.
  Mandatory arguments to long options are mandatory
  for short options too.
  -a, --all
    do not hide entries starting with .
  -A, --almost-all
    do not list implied . and ..
[Listing condensed due to length]

The list of data man provides in this case is quite extensive—over 200 lines worth, in fact. Of course, not all commands provide that much, and some provide far more. Your job is to read the various sections provided in a man page, which usually (but not always) consist of the following:

  • NAME —The name of the command and a brief description
  • SYNOPSIS —The basic format of the command
  • DESCRIPTION —A longer overview of the command's purpose
  • OPTIONS —The real meat and potatoes of man: The various options for the command, along with short explanations of each one
  • FILES —Other files used by the command
  • AUTHOR —Who wrote the command, along with contact information
  • BUGS —Known bugs and how to report new ones
  • COPYRIGHT —This one's obvious: Information about copyright
  • SEE ALSO —Other, related commands

Moving around in a man page isn't that hard. To move down a line at a time, use the down arrow; to move up a line at a time, use the up arrow. To jump down a page, press the spacebar or f (for forward); to jump up a page, press b (for backward). When you reach the end of a man page, man might quit itself, depositing you back on the shell; it might, however, simply stop at the end without quitting, in which case you should press q to quit the program. In fact, you can press q at any time to exit man if you're not finding the information you want.

It can be hard to find a particular item in a man page, so sometimes you need to do a little searching. To search on a man page after it's open, type / , followed by your search term, and then press Enter. If your term exists, you'll jump to it; to jump to the next occurrence of the term, press Enter again (or n), and keep pressing Enter (or n) to jump down the screen to each occurrence; to go backward, press Shift+n.

  • + Share This
  • 🔖 Save To Your Account