Domain 1 · Essential tools

Understand and use
essential tools

Hands-on reference for the RHCSA EX200 exam. Covers shell commands, I/O redirection, file operations, text processing, permissions, and more.

11objectives
6topic areas
6quiz questions
100%hands-on exam

Objectives

What the exam tests

  • Access a shell prompt and issue commands with correct syntax
  • Use input/output redirection (>, >>, |, 2>, etc.)
  • Use grep and regular expressions to analyze text
  • Access remote systems using SSH
  • Log in and switch users in multiuser targets
  • Archive, compress, unpack, and uncompress files using tar, gzip, bzip2
  • Create and edit text files using vi/vim
  • Create, delete, copy, and move files and directories
  • Create hard and soft (symbolic) links
  • List, set, and change standard file permissions (ugo/rwx)
  • Locate, read, and use system documentation (man, info, /usr/share/doc)

Coverage weight by topic

Shell & I/O
High
File operations
Very high
Permissions
Very high
Text tools
High
SSH / login
Medium
Archives
Medium

All exam tasks are hands-on in a live RHEL environment — there are no multiple-choice questions. Syntax precision is critical.

Shell and I/O redirection

I/O redirection operators

OperatorEffectExample
>Redirect stdout — overwriteecho "hello" > file.txt
>>Redirect stdout — appendecho "more" >> file.txt
2>Redirect stderr onlyls /bad 2> err.txt
&>Redirect both stdout and stderrcmd &> all.log
2>&1Merge stderr into stdout streamcmd > out.txt 2>&1
<Redirect stdin from filemail root < msg.txt
|Pipe stdout to next commandps aux | grep httpd

Read each exam task carefully — >> (append) vs > (overwrite) is a common trap that will fail the task silently.

SSH access and key management

# Connect to a remote host ssh user@hostname ssh -p 2222 user@hostname # non-default port # Generate an RSA key pair ssh-keygen -t rsa -b 4096 # Copy public key to remote host (enables key-based auth) ssh-copy-id user@hostname # Run a single command on a remote host without interactive login ssh user@host "df -h"

Switching users

su - # switch to root with full login environment su - username # switch to another user with their login env sudo command # run a single command as root sudo -i # open an interactive root shell via sudo

The - (dash) in su - loads the target user's full login environment including PATH. Without it, you inherit the current user's environment — always use the dash.

System documentation

man ls # manual page for ls man -k keyword # search man page names (same as apropos) man 5 passwd # open section 5 of man page (file formats) info coreutils # GNU info pages (more detailed than man) ls --help # built-in brief help for most commands ls /usr/share/doc/ # extended documentation installed by packages

On the exam, man -k is essential when you know what you want to do but not the exact command name.

Files and directories

File and directory operations

# Create files and directories touch file.txt mkdir dir1 mkdir -p a/b/c # create nested directory tree # Copy cp file1 file2 cp -r dir1/ dir2/ # recursive — copies entire directory cp -p file1 file2 # preserve timestamps and permissions # Move / rename mv oldname.txt newname.txt mv file.txt /tmp/ # Delete rm file.txt rm -rf dir/ # force-remove directory tree (be careful!) # List ls -lah # long format, all files, human-readable sizes ls -lt # sorted by modification time (newest first) ls -ltr # oldest first (reversed)

Hard links vs symbolic links

Archives and compression

# Create compressed archives tar -czf archive.tar.gz dir/ # gzip (most common) tar -cjf archive.tar.bz2 dir/ # bzip2 (better ratio, slower) tar -cJf archive.tar.xz dir/ # xz (best ratio, slowest) # Extract archives tar -xzf archive.tar.gz # extract gzip tar -xjf archive.tar.bz2 # extract bzip2 tar -xf archive.tar.xz # auto-detect compression tar -xzf archive.tar.gz -C /tmp/ # extract to specific directory # List contents without extracting tar -tzf archive.tar.gz

Memory mnemonic — create · extract · table · file · zgzip · jbzip2 · Jxz · verbose · Cdirectory

Vim essential commands

Key / commandAction
iEnter insert mode (before cursor position)
aEnter insert mode (after cursor position)
oOpen new line below and enter insert mode
EscReturn to normal mode from any mode
:wWrite (save) current file
:qQuit vim
:wq or ZZSave and quit
:q!Quit without saving (force)
ddDelete (cut) current line
yyYank (copy) current line
pPaste after cursor / below line
/patternSearch forward for pattern
n / NJump to next / previous search match
:%s/old/new/gGlobal find and replace (all lines, all occurrences)
uUndo last action
Ctrl+rRedo
ggGo to first line
GGo to last line
:set numberShow line numbers

Text processing tools

grep and regular expressions

# Basic grep usage grep "pattern" file.txt grep -i "pattern" file.txt # case-insensitive grep -r "pattern" /etc/ # recursive through directory grep -v "pattern" file.txt # invert — lines NOT matching grep -n "pattern" file.txt # show line numbers grep -c "pattern" file.txt # count matching lines (not text) grep -l "pattern" /etc/* # list filenames only grep -E "pat1|pat2" file # extended regex — OR grep -ri "PermitRoot" /etc/ # recursive + case-insensitive (common exam task)
RegexMeaningExample
.Any single characterh.t matches hat, hit, hot
*Zero or more of precedingab*c matches ac, abc, abbc
^Start of line^root lines starting with root
$End of linebash$ lines ending with bash
[abc]Character class[aeiou] any vowel
[^abc]Negated class[^0-9] non-digit
\bWord boundary (ERE)\broot\b the word root only
+One or more (ERE with -E)ab+c abc, abbc (not ac)

Essential text-processing commands

# View and paginate cat file.txt less file.txt # q=quit /=search G=end g=top head -n 20 file.txt # first 20 lines tail -n 20 file.txt # last 20 lines tail -f /var/log/messages # follow live log output (Ctrl+C to stop) # Sort and deduplicate sort file.txt sort -r file.txt # reverse sort sort -n numbers.txt # numeric sort sort -k2 file.txt # sort by second field sort file.txt | uniq # remove duplicate adjacent lines sort file.txt | uniq -c # count occurrences # Count, cut, and transform wc -l file.txt # count lines wc -w file.txt # count words cut -d: -f1 /etc/passwd # field 1, colon delimiter cut -d: -f1,7 /etc/passwd # fields 1 and 7 # Stream editor — sed sed 's/old/new/g' file.txt # replace all on stdout sed -i 's/old/new/g' file.txt # edit file in place sed -i '/^#/d' file.txt # delete comment lines sed -n '5,10p' file.txt # print lines 5-10

File permissions

Understanding rwx permissions

# ls -l output anatomy: -rwxr-xr-- 2 alice devs 4096 Apr 9 10:00 script.sh │└─┬─┘└─┬─┘└─┬─┘ │ owner group others └── file type: - file d dir l symlink c char b block
PermissionOctal valueOn a fileOn a directory
r — read4Read file contentsList contents with ls
w — write2Modify or overwrite fileCreate or delete files inside
x — execute1Run as executableEnter with cd, traverse

chmod — changing permissions

# Symbolic mode (u=user g=group o=others a=all) chmod u+x script.sh # add execute to owner chmod g-w file.txt # remove write from group chmod o=r file.txt # set others to read only chmod a+r file.txt # add read for all (a = ugo) chmod ug+rw,o-rwx shared.txt # multiple changes at once # Octal mode — most common on exam chmod 755 script.sh # rwxr-xr-x (public script) chmod 644 config.txt # rw-r--r-- (config file) chmod 700 private/ # rwx------ (private directory) chmod 600 ~/.ssh/id_rsa # rw------- (SSH key requirement) # Recursive — apply to all files in a tree chmod -R 755 /var/www/html/

chown and chgrp — ownership

chown alice file.txt # change owner to alice chown alice:devs file.txt # change owner AND group chown :devs file.txt # change group only chgrp devs file.txt # change group (alternative) chown -R alice:devs /project/ # recursive ownership change

Only root can change file ownership. Regular users can only change the group to one they belong to.

Special permission bits

BitOctal prefixEffectExample
SUID4xxx (e.g., 4755)File runs with owner's UID regardless of who executes it/usr/bin/passwd
SGID2xxx (e.g., 2755)Files created in dir inherit dir's group; script runs as groupShared project dir
Sticky1xxx (e.g., 1777)Only file owner or root can delete the file in a shared dir/tmp
chmod u+s /usr/bin/myapp # set SUID chmod g+s /shared/dir # set SGID chmod +t /tmp/shared/ # set sticky bit chmod 4755 /usr/bin/myapp # SUID + rwxr-xr-x in one step

SUID and SGID appear as s in place of x in ls -l. Sticky appears as t in the others execute position.

Common octal permission combinations

OctalSymbolicTypical use
777rwxrwxrwxAvoid — world writable and executable
755rwxr-xr-xStandard scripts, web directories
750rwxr-x---Scripts accessible only to group
700rwx------Private executables, home dirs
664rw-rw-r--Shared group-editable files
644rw-r--r--Standard config files, web assets
640rw-r-----Sensitive config files
600rw-------Required SSH private keys, secrets
400r--------Read-only archived files

Cheat sheet

Most-tested commands — quick reference

List with details
ls -lah
Copy recursively
cp -r src/ dst/
Create nested dirs
mkdir -p a/b/c
Force-remove tree
rm -rf dir/
Tar create + gzip
tar -czf out.tar.gz dir/
Tar extract
tar -xzf file.tar.gz
Tar list contents
tar -tzf file.tar.gz
Grep recursive
grep -r "text" /etc/
Grep case-insensitive
grep -i "text" file
Grep invert match
grep -v "skip" file
Octal 755
chmod 755 script.sh
Octal 644
chmod 644 file.txt
Change owner+group
chown user:grp file
Symbolic link
ln -s /src /dest
Hard link
ln source link
Redirect + merge stderr
cmd > f.log 2>&1
Append to file
echo "txt" >> file
Follow log live
tail -f /var/log/messages
Sed in-place replace
sed -i 's/a/b/g' file
Cut field from file
cut -d: -f1 /etc/passwd
Copy SSH public key
ssh-copy-id user@host
Man keyword search
man -k keyword
Switch to root
su -
Vim global replace
:%s/old/new/g

Permission quick-calc cheat

rwxSumResult
4217rwx — full access
4015r-x — read and execute
4206rw- — read and write
4004r-- — read only
0000--- — no access

Combine three octal digits: owner | group | others. Example: 755 = owner(7=rwx) + group(5=r-x) + others(5=r-x)

Practice quiz

Question 1 of 6

Which command creates a gzip-compressed tar archive of a directory named data/ saved as backup.tar.gz?

The -c flag creates, -z applies gzip compression, and -f names the output file. Option A uses -x (extract). Option D uses -j which is bzip2, not gzip.

Question 2 of 6

You need to redirect both stdout and stderr from a command to a single file output.log. Which is correct?

cmd > output.log 2>&1 first redirects stdout to the file, then merges stderr into stdout. The order matters — reversing them sends stderr to the terminal, not the file. Equivalent shorthand: cmd &> output.log.

Question 3 of 6

What octal chmod value sets rwxr-xr-x?

rwx = 4+2+1 = 7, r-x = 4+0+1 = 5, r-x = 5. Result: 755. This is the standard permission for public scripts and web server directories.

Question 4 of 6

Which command creates a symbolic link named current pointing to /opt/app-v2/?

ln -s target linkname creates a symbolic link. Without -s, Option A creates a hard link — which cannot link directories and cannot span filesystems. The cp and link commands do not support -s for this purpose.

Question 5 of 6

You want to search all files under /etc for the string "PermitRootLogin" (case-insensitive). Which command is correct?

-r recurses into all subdirectories and -i makes the search case-insensitive. Option B misses subdirectories. Option C searches for a file named "PermitRootLogin", not for content containing that string.

Question 6 of 6

Which vim command substitutes every occurrence of "foo" with "bar" on all lines of the current file?

:%s/foo/bar/g — the % address means "all lines", s is substitute, and the trailing g flag means all occurrences on each line. Without %, it only affects the current line. Without g, only the first match per line is replaced.