O'Reilly logo

Learning Red Hat Linux by Bill McCarty

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Working with the Linux Command Prompt

To make Linux commands easy to use, they share a simple, common structure. This section describes their common structure and explains how you can obtain helpful information on the commands available to you.

Command Structure

Linux commands share the common form:

               command option(s) argument(s)

The command identifies the command you want Linux to execute. The name of a Linux command almost always consists of lowercase letters and digits. Remember that, unlike Microsoft Windows, Linux is case sensitive; be sure to type each character of a command in the proper case.

Most commands let you specify options or arguments. However, in any given case, you may not need to do so. For example, typing the w command without options and arguments causes Linux to display a list of current users.

Options modify the way that a command works. Most options consist of a single letter, prefixed by a dash. Often, you can specify more than one option; when you do so, you separate each option with a space or tab. For example, the -h option of the w command causes the output of the command to omit the header lines that give the time and the names of the fields. Typing:

[root@desktop /root]# w -h

prints a list of users without the header lines.

Arguments specify filenames or other targets that direct the action of the command. For example, the w command lets you specify a userid as an argument, which causes the command to list only logins that pertain to the specified userid. Typing:

[root@desktop /root]# w root

prints a list of current logins by the root user. Some commands let you specify a series of arguments; you must separate each argument with a space or tab.

Getting Help

Because Linux provides so many commands and because Linux commands provide so many possible options, you can’t expect to recall all of them. To help you, Linux provides the man command and the apropos command, which let you access a help database that describes each command and its options.

Using man

Each Linux command is described by a special file called a manual page. The manual pages are stored in a group of subdirectories comprising a help database. To access this database, you use the man command, which resembles the MS-DOS help command. For example, to get help on using the w command, type:

[root@desktop /root]# man w

Figure 4.1 shows the resulting output, which the command displays one page at a time. Notice the colon prompt, which appears at the bottom left of the screen. To page forward, press the Space key; to page backward, press the b key. To exit the man program, press the q key.

The manual pages are organized according to a common format. At the beginning of a manual page, you’ll find the name of the page and the section of the manual page database from which the page comes, shown in parentheses. For example, the figure shows the manual page named w, which comes from section 1 of the manual page database. Table 4.1 describes the sections of the manual page database; most sections are primarily of interest to programmers. As a user and administrator, you’ll be interested primarily in sections 1 and 8.

Table 4-1. Manual Page Sections




Executable programs and shell commands


System calls (provided by the kernel)


Library calls (provided by system libraries)


Special files (for example, device files)


File formats and conventions




Macro packages and conventions


System administration commands


Non-standard kernel routines

A typical man page

Figure 4-1. A typical man page

Next in the output comes the name and brief description of the command. Then comes a synopsis of the command, which shows the options and arguments that you can specify. Brackets enclose parts of a command that you can choose to include or omit. Next comes a detailed description of the operation of the command, followed by a description of its options.

As you’re learning your way around Linux, you may find it convenient to reserve a virtual console for running the man command. That way, you can enter commands in a separate virtual console, switching between consoles to refresh your recollection of the options and arguments of commands as you type them.

Using apropos

The man command searches the manual pages and displays detailed information about a specified command. The apropos command also searches the manual pages; however, it displays summary information about manual pages that contain a specified keyword. (The search is limited to the short description that appears at the beginning of each manual page). For example, typing the command:

[root@desktop /root]# apropos files

displays a list of manual pages that contain the word files, as shown in Figure 4.2.

Output of the apropos command

Figure 4-2. Output of the apropos command

The apropos command is useful when you don’t recall the name of a Linux command. By typing a related keyword, you can obtain a list of commands and search the list for the command you need.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required