Search the Catalog
Learning Debian GNU/Linux

Learning Debian GNU/Linux

By Bill McCarty
1st Edition September 1999
1-56592-705-2, Order Number: 7052
360 pages, $34.95 , Includes CD-ROM


Previous: 4.1 The System Use Cycle Chapter 4
Issuing Linux Commands
Next: 4.3 How Linux Organizes Data
 

4.2 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.

4.2.1 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.

4.2.2 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.

4.2.2.1 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

Section

Description

1

Executable programs and shell commands

2

System calls (provided by the kernel)

3

Library calls (provided by system libraries)

4

Special files (for example, device files)

5

File formats and conventions

6

Games

7

Macro packages and conventions

8

System administration commands

9

Non-standard kernel routines

Figure 4.1: A typical man page

Figure 4.1

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.

4.2.2.2 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.

Figure 4.2: Output of the apropos command

Figure 4.2

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.



Previous: 4.1 The System Use Cycle Learning Debian GNU/Linux Next: 4.3 How Linux Organizes Data
4.1 The System Use Cycle Book Index 4.3 How Linux Organizes Data

Back to: Learning Debian GNU/Linux


oreilly.com Home | O'Reilly Bookstores | How to Order | O'Reilly Contacts
International | About O'Reilly | Affiliated Companies | Privacy Policy

© 2001, O'Reilly & Associates, Inc.