RHCSA RHCSA Essential Command-Line Tools 3 — Questions and Answers
Question 1: What does the pipe symbol '|' do in a shell command?
- Sends stdout of the left command to stdin of the right command (Correct answer)
- Runs two commands simultaneously in the background
- Redirects output to a file
- Appends output of left command to right command's output file
Correct answer: Sends stdout of the left command to stdin of the right command
The pipe operator connects the standard output of one command to the standard input of the next.
Question 2: Which command would you use to count the number of unique lines in a sorted file?
- uniq -c (Correct answer)
- sort -u
- wc -l
- diff -u
Correct answer: uniq -c
uniq -c prefixes each unique line with its count of occurrences after the file has been sorted.
Question 3: Which find command locates all regular files larger than 100MB under /home?
- find /home -type f -size +100M (Correct answer)
- find /home -type f -size 100M
- find /home -size +100M
- find /home -f -larger 100M
Correct answer: find /home -type f -size +100M
find uses -type f for regular files and -size +100M for files strictly larger than 100 megabytes.
Question 4: What does 'ls -lh' add over 'ls -l'?
- Displays file sizes in human-readable format (KB, MB, GB) (Correct answer)
- Shows hidden files
- Lists files sorted by size
- Displays inode numbers
Correct answer: Displays file sizes in human-readable format (KB, MB, GB)
The -h flag makes sizes human-readable by using units like K, M, and G instead of raw bytes.
Question 5: Which command displays the full path of the currently active shell executable?
- which bash (Correct answer)
- echo $SHELL
- type shell
- where bash
Correct answer: which bash
which searches PATH directories and prints the full path of the named executable.
Question 6: What is the purpose of the 'tee' command?
- Reads from stdin and writes to both stdout and a file simultaneously (Correct answer)
- Duplicates a file
- Appends output of two commands together
- Displays last lines of a file like tail
Correct answer: Reads from stdin and writes to both stdout and a file simultaneously
tee splits the output stream so it goes to both the terminal (stdout) and a specified file at the same time.
Question 7: Which command shows the manual page for the 'cp' command?
- man cp (Correct answer)
- help cp
- info --cp
- cp --manual
Correct answer: man cp
man displays the manual (man page) for any command available on the system.
What does the pipe symbol '|' do in a shell command?