← All chapters · Book · Repository
Chapter 2: Documentation and Basic Commands Answers
Red Hat RHCSA 10 Study Companion: Getting Ready for the EX200 Exam by Andrey Markelov (May 2026).
Topics
- Man pages, info pages
- Bash aliases
- Find command and pipes
- Vim tutorial
exercise_01.sh
executable safe: yes#!/bin/bash
# @type: executable
# @requires: none
# @safe: yes
set -euo pipefail
# Exercise 1: Check the man page for the file passwd to find the name of the fifth field and why it has this name.
#
# Task: Use the man command to view the passwd file format documentation
# and identify what the fifth field represents.
man 5 passwd
exercise_02.sh
executable safe: yes#!/bin/bash
# @type: executable
# @requires: none
# @safe: yes
set -euo pipefail
# Exercise 2: Call info info and read tutorial. If missed install info package.
#
# Task: Open the info documentation system's tutorial to learn how to use info pages.
info info
exercise_03.sh
executable safe: yes#!/bin/bash
# @type: executable
# @requires: none
# @safe: yes
set -euo pipefail
# Exercise 3: Find in the bash manual page description of aliases and create an alias lls for ls -lah
#
# Task: Search the bash man page for ALIASES section and create a persistent alias
# for the 'ls -lah' command named 'lls'.
# First, view the bash manual for aliases
# man bash
# Type /ALIASES and press Enter to search
# Create the alias in .bashrc
echo "alias lls='ls -lah'" >> ~/.bashrc
# Apply the changes to the current session
source ~/.bashrc
echo "Alias 'lls' has been created for 'ls -lah'"
exercise_04.sh
executable safe: yes#!/bin/bash
# @type: executable
# @requires: none
# @safe: yes
set -euo pipefail
# Exercise 4: By using a pipe and a find tool, make a command that will display the number
# of files in the /etc directory containing "an" in the name.
#
# Task: Use find to search for files with "an" in their names in /etc directory,
# and count them using wc.
find /etc -type f -name "*an*" 2>/dev/null | wc -l
exercise_05.sh
executable safe: yes#!/bin/bash
# @type: executable
# @requires: none
# @safe: yes
set -euo pipefail
# Exercise 5: Run the command vimtutor and follow the exercises (it will take about 20 minutes).
#
# Task: Launch the interactive Vim tutorial to learn basic Vim text editor commands.
vimtutor
exercise_extra_01.sh
executable safe: yes#!/bin/bash
# @type: executable
# @requires: none
# @safe: yes
set -euo pipefail
# Extra Exercise 1: Use the find command to locate all files in /var/log that were
# modified in the last 24 hours. Sort the results by modification time (newest first).
#
# Task: Find recently modified log files using find with -mtime.
echo "Files in /var/log modified in the last 24 hours (newest first):"
echo ""
find /var/log -type f -mtime -1 2>/dev/null | xargs ls -lt 2>/dev/null | head -20
exercise_extra_02.sh
executable safe: yes#!/bin/bash
# @type: executable
# @requires: none
# @safe: yes
set -euo pipefail
# Extra Exercise 2: Create a command pipeline that reads /etc/passwd, extracts
# all unique shells (field 7), sorts them, and displays how many users use each shell.
#
# Task: Use cut, sort, uniq in a pipeline to analyze shell usage.
echo "Shell usage statistics from /etc/passwd:"
echo ""
cut -d: -f7 /etc/passwd | sort | uniq -c | sort -rn
exercise_extra_03.sh
executable safe: yes#!/bin/bash
# @type: executable
# @requires: none
# @safe: yes
set -euo pipefail
# Extra Exercise 3: Use the head and tail commands together to extract lines 10-20
# from /etc/passwd. Then use sed to achieve the same result.
#
# Task: Extract a range of lines from a file using different methods.
echo "=== Using head and tail ==="
head -20 /etc/passwd | tail -11
echo ""
echo "=== Using sed ==="
sed -n '10,20p' /etc/passwd
echo ""
echo "=== Using awk ==="
awk 'NR>=10 && NR<=20' /etc/passwd