Part 1: Accessing Built-in Documentation
You don’t need to memorize everything. The key skill is knowing how to find information quickly using the system’s own tools.
1.1 The man Command (Manual Pages)
The primary source of documentation for commands, configuration files, and system calls.
- Syntax:
man [command_name] - Example:
man ls - Navigation:
- Spacebar: Page down.
b: Page up./keyword: Search forward for a keyword (pressnfor next match,Nfor previous).q: Quit the manual.
- Searching for Manuals: If you don’t know the exact command name, use
man -k [keyword]to search the manual descriptions.- Example:
man -k copy
- Example:
1.2 The --help Option
A quick and concise summary of a command’s options. Perfect for when you just need a syntax reminder.
- Syntax:
[command_name] --help - Example:
cp --help
1.3 The help Command for Shell Builtins
Some commands (like cd, echo, alias) are built into the shell itself and don’t have a man page. Use help for these.
- Syntax:
help [command_name] - Example:
help cd - Identify a Command’s Type: Use
type [command]to see if it’s a builtin, alias, or external file.- Example:
type cd→cd is a shell builtin
- Example:
1.4 The info Command
An alternative, often more detailed, documentation system with a hyperlinked structure. Some commands have more comprehensive info pages than man pages.
- Syntax:
info [command_name] - Example:
info ls - Navigation:
n(next),p(previous),q(quit).
Part 2: Viewing File Contents
Different tools are suited for different tasks, from quick peeks to real-time monitoring.
| Command | Purpose | RHCSA Use Case |
|---|---|---|
cat | Concatenate and display entire file content. | Viewing short files like /etc/passwd. |
less | View file content page-by-page. Allows searching. | The best tool for reading long files. |
more | Older version of less (page-by-page, but less features). | Similar to less, but less capable. |
head | Display the first few lines (default: 10). | Checking the beginning of a configuration file. |
tail | Display the last few lines (default: 10). | Checking the most recent entries in a log file. |
tail -f | Follow a file in real-time as new lines are added. | Crucial for monitoring live logs. |
Real-time Log Monitoring with tail -f and grep
This is an essential troubleshooting technique.
- Monitor all system messages:bashtail -f /var/log/messages
- Monitor and filter for specific errors:bashtail -f /var/log/messages | grep -i error
- Monitor SSH authentication attempts:bashtail -f /var/log/secure | grep sshd
- To stop monitoring: Press
Ctrl+C.
Part 3: Using Text Editors
For the RHCSA, you must be proficient in at least one command-line text editor. vim is the most powerful and is highly recommended.
3.1 nano – The Simple Editor
A straightforward, beginner-friendly editor.
- Installation:
sudo dnf install nano -y - Open/Create a file:
nano filename.txt - Key Shortcuts (displayed at the bottom of the screen):
Ctrl+O: Save (Output).Ctrl+X: Exit.Ctrl+W: Search.Ctrl+\: Search and replace.
3.2 vim / vi – The Powerful Editor (RHCSA Default)
vim is the default editor on RHEL and a critical skill for the exam. It has modes, which can be confusing at first but are incredibly efficient.
- Installation:
sudo dnf install vim -y(Often pre-installed). - Open/Create a file:
vim filename.sh
The Three Essential vim Modes
- Normal Mode (when you start): For navigation and commands.
- Press
ito enter Insert Mode. - Press
:to enter Command-Line Mode.
- Press
- Insert Mode: For typing and editing text.
- Press
Escto return to Normal Mode.
- Press
- Command-Line Mode: For saving, quitting, and searching.
- Accessed from Normal Mode by pressing
:.
- Accessed from Normal Mode by pressing
| Task | Command | Mode |
|---|---|---|
| Enter Insert Mode | i | Normal -> Insert |
| Return to Normal Mode | Esc | Insert -> Normal |
| Save (Write) | :w | Command-Line |
| Quit | :q | Command-Line |
| Save and Quit | :wq | Command-Line |
| Quit without Saving | :q! | Command-Line |
| Search | /keyword (then press n/N) | Normal |
Example Workflow for Creating a Script with vim:
# 1. Create and open the file vim backup.sh # 2. Press 'i' to enter Insert Mode. # 3. Type the script: #!/bin/bash tar -czf /root/backup.tar.gz /etc echo "Backup complete." # 4. Press 'Esc' to return to Normal Mode. # 5. Type ':wq' and press Enter to Save and Quit. # 6. Make the script executable and run it. chmod +x backup.sh ./backup.sh
3.3 gedit – The Graphical Editor
A simple GUI text editor, useful if you have a desktop environment.
- Installation:
sudo dnf install gedit -y - Open a file:
gedit filename.txt &(The&runs it in the background). - Shortcuts:
Ctrl+S(Save),Ctrl+Q(Quit).
Summary: The RHCSA Workflow for Help and Editing
- Need a quick command reminder? Use
[command] --help. - Need in-depth documentation? Use
man [command]. - Need to view a short file? Use
cat [file]. - Need to read a long file or log? Use
less [file]. - Need to monitor a live log? Use
tail -f [logfile] | grep [keyword]. - Need to edit a configuration file or script? Use
vim [file].