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
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
| Operator | Effect | Example |
|---|---|---|
> | Redirect stdout — overwrite | echo "hello" > file.txt |
>> | Redirect stdout — append | echo "more" >> file.txt |
2> | Redirect stderr only | ls /bad 2> err.txt |
&> | Redirect both stdout and stderr | cmd &> all.log |
2>&1 | Merge stderr into stdout stream | cmd > out.txt 2>&1 |
< | Redirect stdin from file | mail root < msg.txt |
| | Pipe stdout to next command | ps 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
Switching users
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
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
Hard links vs symbolic links
Hard link
- Shares the same inode as original
- Must be on the same filesystem
- Survives deletion of original file
- Cannot link directories
- No indication it is a link in
ls
Symbolic (soft) link
- Separate inode — a pointer only
- Can span different filesystems
- Breaks if original is deleted
- Can link directories
- Shows
ltype inls -loutput
Archives and compression
Memory mnemonic — create · extract · table · file · zgzip · jbzip2 · Jxz · verbose · Cdirectory
Vim essential commands
| Key / command | Action |
|---|---|
i | Enter insert mode (before cursor position) |
a | Enter insert mode (after cursor position) |
o | Open new line below and enter insert mode |
Esc | Return to normal mode from any mode |
:w | Write (save) current file |
:q | Quit vim |
:wq or ZZ | Save and quit |
:q! | Quit without saving (force) |
dd | Delete (cut) current line |
yy | Yank (copy) current line |
p | Paste after cursor / below line |
/pattern | Search forward for pattern |
n / N | Jump to next / previous search match |
:%s/old/new/g | Global find and replace (all lines, all occurrences) |
u | Undo last action |
Ctrl+r | Redo |
gg | Go to first line |
G | Go to last line |
:set number | Show line numbers |
Text processing tools
grep and regular expressions
| Regex | Meaning | Example |
|---|---|---|
. | Any single character | h.t matches hat, hit, hot |
* | Zero or more of preceding | ab*c matches ac, abc, abbc |
^ | Start of line | ^root lines starting with root |
$ | End of line | bash$ lines ending with bash |
[abc] | Character class | [aeiou] any vowel |
[^abc] | Negated class | [^0-9] non-digit |
\b | Word boundary (ERE) | \broot\b the word root only |
+ | One or more (ERE with -E) | ab+c abc, abbc (not ac) |
Essential text-processing commands
File permissions
Understanding rwx permissions
| Permission | Octal value | On a file | On a directory |
|---|---|---|---|
r — read | 4 | Read file contents | List contents with ls |
w — write | 2 | Modify or overwrite file | Create or delete files inside |
x — execute | 1 | Run as executable | Enter with cd, traverse |
chmod — changing permissions
chown and chgrp — ownership
Only root can change file ownership. Regular users can only change the group to one they belong to.
Special permission bits
| Bit | Octal prefix | Effect | Example |
|---|---|---|---|
| SUID | 4xxx (e.g., 4755) | File runs with owner's UID regardless of who executes it | /usr/bin/passwd |
| SGID | 2xxx (e.g., 2755) | Files created in dir inherit dir's group; script runs as group | Shared project dir |
| Sticky | 1xxx (e.g., 1777) | Only file owner or root can delete the file in a shared dir | /tmp |
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
| Octal | Symbolic | Typical use |
|---|---|---|
777 | rwxrwxrwx | Avoid — world writable and executable |
755 | rwxr-xr-x | Standard scripts, web directories |
750 | rwxr-x--- | Scripts accessible only to group |
700 | rwx------ | Private executables, home dirs |
664 | rw-rw-r-- | Shared group-editable files |
644 | rw-r--r-- | Standard config files, web assets |
640 | rw-r----- | Sensitive config files |
600 | rw------- | Required SSH private keys, secrets |
400 | r-------- | Read-only archived files |
Cheat sheet
Most-tested commands — quick reference
ls -lahcp -r src/ dst/mkdir -p a/b/crm -rf dir/tar -czf out.tar.gz dir/tar -xzf file.tar.gztar -tzf file.tar.gzgrep -r "text" /etc/grep -i "text" filegrep -v "skip" filechmod 755 script.shchmod 644 file.txtchown user:grp fileln -s /src /destln source linkcmd > f.log 2>&1echo "txt" >> filetail -f /var/log/messagessed -i 's/a/b/g' filecut -d: -f1 /etc/passwdssh-copy-id user@hostman -k keywordsu -:%s/old/new/gPermission quick-calc cheat
| r | w | x | Sum | Result |
|---|---|---|---|---|
| 4 | 2 | 1 | 7 | rwx — full access |
| 4 | 0 | 1 | 5 | r-x — read and execute |
| 4 | 2 | 0 | 6 | rw- — read and write |
| 4 | 0 | 0 | 4 | r-- — read only |
| 0 | 0 | 0 | 0 | --- — 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?
-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?
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.