2.7.8 Practice Questions

Question: Which of the following commands sorts the combined contents of the wordlist1 and wordlist2 files and sends the results to both the screen and a file named sortedwordlist?

Answer: cat /usr/wordlist1 /usr/wordlist2 | sort | tee sortedwordlist

Question: Which of the following describes the effects of the ls -l /usr/bin >> /tmp/list.txt command?

Answer: The contents of the /usr/bin directory are written to a file named /tmp/list.txt. Previous file contents are kept, and the new information is added at the end of the file.

Question:

Answer: ls -s &> ~/Friday

Question: Which of the following commands gives the same results as cat < turbo?

Answer: cat turbo

Question: Which of the following commands sorts the contents of the wordlist1 and wordlist2 files and sends the result to standard output?

Answer: cat /usr/wordlist1 /usr/wordlist2 | sort

Question: Which command operator pipes the output of one command as the input of another command?

Answer: |

Question: Which command reads from standard input (stdin) and writes to both standard output (stdout) and a file?

Answer: tee

Question: Joe, a bash script developer, is trying to debug a shell script named myscript.

Which of the following commands would record the output of the script in a text file?

Answer: myscript >> testfile.txt

Question: Tom, a shell script developer, knows that the date +%A command gives the current local weekday name (Sunday, Monday, Tuesday, …).

Which of the following commands will copy the authentication log file, /var/log/auth.log, to a new file that with a filename that includes the current local weekday name?

Answer: cp /var/log/auth.log ~/auth$(date +%A).log

Question: Which command overcomes the 128 KB shell command size restriction by breaking up long lists of arguments?

Answer: xargs

Donation Page

Support Our Work

Do you appreciate the value this website provides? If so, please consider donating to help keep it running. Your donation will go a long way in helping us continue to provide the same quality of content and services. Every bit helps, and your support is greatly appreciated. Thank you for your generosity.