Chapter 2: Using Essential Tools
Mastering the fundamental tools every RHEL administrator needs: documentation, editing, and shell operations.
Key Concepts
Getting Help
| Tool | Purpose | Example |
|---|---|---|
|
Manual pages |
|
|
GNU documentation |
|
|
Quick reference |
|
|
Package documentation |
|
|
Better info reader |
|
Man Page Sections
| Section | Content | Example |
|---|---|---|
1 |
User commands |
|
5 |
File formats |
|
8 |
Admin commands |
|
Hands-On Exercises
Exercise 2.1: Man Page Navigation
# Open man page for passwd command
man passwd
# Navigation:
# /pattern - search forward
# ?pattern - search backward
# n - next match
# N - previous match
# g - go to beginning
# G - go to end
# q - quit
# Search for password-related pages
man -k password
apropos password
# Find the configuration file section
man 5 passwd
Exercise 2.2: Vim Essentials
# Create practice file
vim /tmp/practice.txt
Vim Modes:
| Mode | Enter | Purpose |
|---|---|---|
Normal |
|
Navigation, commands |
Insert |
|
Text entry |
Visual |
|
Selection |
Command |
|
File operations |
Essential Commands:
# Movement
h, j, k, l - left, down, up, right
w, b - word forward/back
0, $ - line start/end
gg, G - file start/end
:n - go to line n
# Editing
i - insert before cursor
a - append after cursor
o - open line below
O - open line above
x - delete character
dd - delete line
yy - yank (copy) line
p - paste after
P - paste before
u - undo
Ctrl+r - redo
# Search/Replace
/pattern - search forward
?pattern - search backward
n, N - next/prev match
:%s/old/new/g - replace all
# File operations
:w - save
:q - quit
:wq - save and quit
:q! - quit without saving
:w filename - save as
Exercise 2.3: I/O Redirection
# tag::io-redirect[]
# Redirect stdout to file
ls -la > files.txt
# Append stdout to file
echo "new line" >> files.txt
# Redirect stderr to file
find / -name "*.conf" 2> errors.txt
# Redirect both stdout and stderr
find / -name "*.conf" > results.txt 2>&1
# Modern syntax (bash 4+)
find / -name "*.conf" &> all.txt
# Discard output
command > /dev/null 2>&1
# Pipe stdout to another command
ls -la | grep "^d"
# Pipe and tee (split output)
ls -la | tee listing.txt | grep "^d"
# tag::io-redirect[]
Exercise 2.4: Shell Variables
# Set variable
MYVAR="hello world"
# Use variable
echo $MYVAR
echo ${MYVAR}
# Export for child processes
export MYVAR
# Unset variable
unset MYVAR
# Environment variables
env # list all
printenv HOME # specific variable
# Important variables
echo $HOME # home directory
echo $PATH # executable search path
echo $USER # current user
echo $SHELL # current shell
echo $PS1 # prompt string
Exercise 2.5: History and Shortcuts
# History operations
history # show history
!n # execute command n
!! # execute last command
!string # execute last command starting with string
# Keyboard shortcuts
Ctrl+a # beginning of line
Ctrl+e # end of line
Ctrl+u # delete to beginning
Ctrl+k # delete to end
Ctrl+w # delete word backward
Ctrl+r # reverse search history
Ctrl+l # clear screen
Ctrl+c # cancel current command
Ctrl+d # exit shell
Diagram: I/O Streams
D2 Source (render with Kroki or d2 CLI)
# I/O Streams in Linux
# Edit this D2 diagram as you learn
direction: right
title: Standard I/O Streams {
shape: text
style.font-size: 24
}
# Input/Output model
process: Process {
shape: rectangle
style.fill: "#e3f2fd"
style.stroke: "#1565c0"
style.stroke-width: 2
}
stdin: stdin (0) {
shape: parallelogram
style.fill: "#c8e6c9"
}
stdout: stdout (1) {
shape: parallelogram
style.fill: "#fff9c4"
}
stderr: stderr (2) {
shape: parallelogram
style.fill: "#ffcdd2"
}
keyboard: Keyboard {
shape: cylinder
style.fill: "#e0e0e0"
}
terminal: Terminal {
shape: cylinder
style.fill: "#e0e0e0"
}
file: File {
shape: document
style.fill: "#f3e5f5"
}
pipe: "| (pipe)" {
shape: hexagon
style.fill: "#b3e5fc"
}
# Connections
keyboard -> stdin: "default input"
stdin -> process
process -> stdout
process -> stderr
stdout -> terminal: "default output"
stderr -> terminal: "default errors"
# Redirection examples
stdout -> file: "> redirect"
stdin <- file: "< redirect"
stdout -> pipe: "to next command"
# Legend
legend: {
label: File Descriptors
style.fill: "#fafafa"
fd0: "0 = stdin (input)"
fd1: "1 = stdout (output)"
fd2: "2 = stderr (errors)"
}
Notes
Add your personal notes here as you work through the chapter.