RHCSA Command-Line Mastery: Efficiency and Data Processing
This guide consolidates advanced command-line techniques that are crucial for RHCSA exam success and real-world system administration efficiency.
Part 1: Recalling and Reusing Commands
1.1 The history Command
Your terminal session maintains a list of previously executed commands. Mastering its use is a major efficiency boost.
| Command | Purpose | Example |
|---|---|---|
history | List all commands in the session’s history. | history |
!n | Execute command number n from the history list. | !170 (runs command #170) |
!! | Execute the last command again. | !! |
!string | Execute the most recent command starting with string. | !touch (runs last touch command) |
Ctrl+R | Reverse-i-search: Interactively search history. Type a keyword. | (reverse-i-search)‘grep’: … |
history | grep string | Search entire history for commands containing string. | history | grep yum |
Part 2: Speed and Automation
2.1 Tab Completion
Press the Tab key to auto-complete commands, file paths, and package names.
- Use Case: Type a partial name and press
Tabto complete it. If multiple options exist, pressTabtwice to see all possibilities. - Examples:
sys+Tab→ Suggestssystemctl,sysctl, etc.cd De+Tab→ Completes tocd Desktop/yum install http+Tab→ Suggestshttpdpackages.
2.2 Creating Command Shortcuts with alias
An alias creates a custom shortcut for a longer command.
- Syntax:
alias shortname='long command with options' - Temporary Alias: Only lasts for the current terminal session.
alias updateall='sudo dnf update -y' alias l='ls -la'
- Permanent Alias: Add the
aliascommand to your~/.bashrcfile.
vim ~/.bashrc # Add line: alias l='ls -la' # Save and quit (:wq). Then run: source ~/.bashrc
- Remove an Alias:
unalias aliasname(e.g.,unalias updateall)
Part 3: Command Chaining and Control Flow
Execute multiple commands on a single line, controlling their execution based on success or failure.
| Operator | Name | Logic | Example |
|---|---|---|---|
; | Semicolon | Runs commands sequentially, regardless of success. | mkdir /testdir; cd /testdir; touch test.txt |
&& | Logical AND | Runs the next command only if the previous one succeeded. | sudo dnf update -y && reboot |
|| | Logical OR | Runs the next command only if the previous one failed. | cd /nonexistent || echo "Directory missing" |
Part 4: Power of the Pipe (|)
The pipe (|) takes the output of one command and uses it as the input for the next. This is the foundation of complex text processing.
- Syntax:
command1 | command2 | command3
Common Pipe Examples:
- Search in a directory listing:
ls -l /etc | grep ssh - Search for errors in logs:
cat /var/log/messages | grep -i error - Find a user account:
cat /etc/passwd | grep john - Monitor logs in real-time:
tail -f /var/log/messages | grep error - Extract and sort data:
cut -d: -f1 /etc/passwd | sortOR awk -F: ‘{print $1}’ /etc/passwd | sort
Part 5: Globbing (Wildcards) for File Operations
Globbing uses wildcard characters to match multiple files/directories, enabling bulk operations.
| Wildcard | Purpose | Example |
|---|---|---|
* | Matches zero or more of any character. | ls *.log (all .log files), rm /var/log/*.log |
? | Matches exactly one of any character. | ls file?.txt (file1.txt, fileA.txt, but not file10.txt) |
[ ] | Matches one character from a set or range. | ls file[1-5].txt (file1.txt, file2.txt, … file5.txt) |
Part 6: Data Extraction and Processing Toolkit
These commands are indispensable for filtering and analyzing system data.
| Command | Primary Purpose | RHCSA-Relevant Example |
|---|---|---|
cut | Extract columns/fields from text. | cut -d: -f1,3 /etc/passwd (get usernames & IDs) |
awk | Powerful pattern scanning & processing. | df -h | awk '{print $1, $5}' (get filesystem & use%) |
sed | Stream editor for filtering/transforming text. | sed -n '1,5p' /etc/passwd (print first 5 lines) |
sort | Sort lines of text. | cut -d: -f1 /etc/passwd | sort (sort usernames) |
head | Display first lines of a file. | head -5 /etc/passwd |
tail | Display last lines of a file. | tail -5 /etc/passwd |
wc | Word, line, and character count. | wc -l /etc/passwd (count users) |
grep | Search for text patterns. | grep "root" /etc/passwd, grep "Failed" /var/log/secure |
find | Find files/dirs based on name, size, etc. | find /etc -name "sshd_config" |
locate | Fast file search using a pre-built database. | locate sshd |
which | Shows the full path of a shell command. | which systemctl → /usr/bin/systemctl |
Summary: The Efficient Administrator’s Workflow
- Don’t Retype: Use
historyandTabcompletion to save time and avoid errors. - Automate Repetition: Create
aliases for frequently used, complex commands. - Build Pipelines: Use
|to chain simple commands (grep,cut,sort) into powerful data processing workflows. - Operate in Bulk: Use globbing (
*,?,[]) to manage many files at once. - Control Execution: Use
;,&&, and||to script multi-step processes directly in the command line.

BasePress comes with three different knowledge base themes to choose from: Default, Modern and Zen. You can change your WordPress Knowledge base theme at any time, navigate to BasePress >Settings >Appearance (Prior to version 2.7.0 this tab was called “Aspect”) and select the theme you want to use from the menu.
In the Basepress Menu, you’ll find a menu item with the name of the theme you’re using. When you click on the name of the theme, a new window opens where you find extra customization tools like color-branding, font or font size, sticky side bar and more. The additional customization tools will depend on the theme you’re using.