Lesson 5 |
The UNIX Manual and System Administration |
Objective |
Understand the role of UNIX manual pages in system administration and learn to use them effectively. |
UNIX Manual and System Administration
A UNIX system administrator works in diverse environments, managing systems like Ubuntu servers, CentOS clusters, or cloud-based Linux instances. While you may master one environment, new systems (e.g., a different Linux distribution or a BSD variant) can introduce unexpected challenges, such as commands behaving differently. Even in a single environment, the sheer number of commands and options makes memorization impossible. For these reasons, proficiency with the UNIX online manual (accessed via the
man
command) is a critical skill for system administrators. The
man
pages provide detailed documentation, but they have limitations:
- They assume familiarity with the command or program being described.
- They lack a centralized index, requiring searches across multiple entries.
- They focus on specific commands or daemons, not broader procedures (e.g., no
man
page explains how to set up a web server, but you’ll find entries for httpd
or nginx
).
- Navigating
man
pages can feel unintuitive due to their unique structure.
Despite these challenges, mastering a few key commands and understanding the manual’s structure enables effective navigation and use.
How to Use man
Pages
The
man
command is your gateway to UNIX documentation. Here are essential commands and tips for using it effectively:
- View a man page:
man ls
displays the manual for the ls
command.
- Search for a command:
man -k user
lists commands related to "user" (e.g., useradd
, usermod
).
- Access a specific section:
man 1 ls
ensures you get the user command (section 1) for ls
.
- Navigate a man page: Use
/keyword
to search for a term, n
to jump to the next match, and q
to quit.
For example, to learn about the
ls
command’s options, run:
man ls
Scroll to the "Options" section to find details on flags like
-l
(long format) or
-a
(show hidden files).
Man Page Example: ls
Below is a simplified representation of the
man
page structure for the
ls
command:
ls(1) |
Lists directory contents. Use to display files and directories with optional formatting. |
Synopsis |
ls [-lahtr] [file ...] |
Options |
-l : Long format, showing permissions, owner, and size.
-a : Include hidden files (starting with .).
-t : Sort by modification time.
|
Files |
/etc : Directory often listed with ls /etc to view configuration files. |
This example shows how
man
pages provide command details in a structured format.
Organization of the Manual
The UNIX manual is divided into sections, each covering a specific type of information. The most relevant sections for administrators include user commands, system administration commands, and configuration files. While slight variations exist across UNIX systems (e.g., Linux vs. BSD), the structure is consistent.
UNIX Manual Sections
The following table outlines key manual sections for system administrators:
Contents |
Section (BSD) |
Section (System V) |
User commands (e.g., ls , cat ) |
1 |
1 |
System calls (e.g., kernel-level functions) |
2 |
2 |
Library functions (e.g., programming routines) |
3 |
3 |
Special files and devices (e.g., hardware drivers) |
4 |
7 or 9 |
Configuration files (e.g., /etc/passwd ) |
5 |
4 |
Miscellaneous (e.g., protocols, standards) |
7 |
5 |
Admin commands (e.g., useradd , fsck ) |
8 |
1M |
Unix Commands for Account Management
The following commands are commonly used to manage user accounts and groups:
Command |
Description |
useradd |
Adds a new user account. |
usermod |
Modifies user account attributes (e.g., home directory, shell). |
userdel |
Deletes a user account. |
groupadd |
Adds a new group. |
groupmod |
Modifies group attributes (e.g., group name). |
groupdel |
Removes a group. |
For example, to add a new user, you might run:
man useradd
to review options, then execute
useradd -m -s /bin/bash username
to create a user with a home directory and Bash shell.
Structure of a Typical Man Page
Man pages follow a consistent structure:
- Synopsis: Summarizes the command and its options (e.g.,
ls [-la]
).
- Description: Explains the command’s purpose and behavior.
- Options: Details each command-line flag.
- Files: Lists related configuration or data files.
- Examples: (Sometimes) Provides usage examples.
Optional arguments are shown in brackets (e.g.,
[file ...]
in
ls
means the file argument is optional). If multiple versions exist (e.g., BSD vs. System V), both may be documented with their respective paths.
Creating Local Man Pages
Documenting your custom scripts or tools is a best practice in UNIX administration. The standard approach is to create a man
page for each tool. Manual pages are text files named after the command and stored in a man
subdirectory (e.g., wgrep.1
for a wgrep
command in section 1). Basic man pages are plain text, but for a polished look, use the nroff
formatting system. Nroff directives (starting with a period, e.g., .TH
for title) control formatting. To learn, study existing man page source files (e.g., /usr/share/man/man1/ls.1
).
