RHCSA RHCSA Essential Command-Line Tools 5 — Questions and Answers
Question 1: Which command extracts a tarball named 'backup.tar.gz' into the current directory?
- tar -xzf backup.tar.gz (Correct answer)
- tar -czf backup.tar.gz
- tar -xjf backup.tar.gz
- gunzip backup.tar.gz | tar -x
Correct answer: tar -xzf backup.tar.gz
tar -xzf extracts (-x) a gzip-compressed (-z) archive from the specified file (-f).
Question 2: What does 'ps aux' show?
- All running processes for all users with detailed info (Correct answer)
- Only processes in the current terminal session
- Background jobs started by the current user
- Process IDs grouped by CPU usage
Correct answer: All running processes for all users with detailed info
ps aux uses BSD-style flags to show all processes (a), user-oriented format (u), and processes not attached to a terminal (x).
Question 3: Which command sends signal 9 (SIGKILL) to a process with PID 1234?
- kill -9 1234 (Correct answer)
- kill -TERM 1234
- killall -9 bash
- pkill -15 1234
Correct answer: kill -9 1234
kill -9 PID sends the SIGKILL signal which immediately terminates the process without cleanup.
Question 4: What does the 'df -h' command display?
- Disk space usage of mounted filesystems in human-readable form (Correct answer)
- Directory sizes recursively in human-readable form
- Disk fragmentation statistics
- Free inodes on each filesystem
Correct answer: Disk space usage of mounted filesystems in human-readable form
df reports filesystem disk space usage, and -h formats sizes with KB/MB/GB units for readability.
Question 5: Which command shows disk usage of the current directory and its subdirectories?
- du -sh * (Correct answer)
- df -h .
- ls -lh
- stat .
Correct answer: du -sh *
du -sh * shows the summarized (-s) human-readable (-h) disk usage of each item in the current directory.
Question 6: How do you redirect both stdout and stderr to a file named 'output.log'?
- command > output.log 2>&1 (Correct answer)
- command 2> output.log 1>&2
- command >> output.log 2>&1
- command > output.log > /dev/stderr
Correct answer: command > output.log 2>&1
> output.log redirects stdout to the file, and 2>&1 redirects stderr (fd 2) to the same destination as stdout (fd 1).
Question 7: What does 'history | grep ssh' display?
- Previously run commands that contain 'ssh' (Correct answer)
- Active SSH connections on the system
- SSH configuration from history files
- All commands run by the ssh user
Correct answer: Previously run commands that contain 'ssh'
history outputs the command history list, and piping it to grep filters lines containing the string 'ssh'.
Which command extracts a tarball named 'backup.tar.gz' into the current directory?