Difficulty: Easy
Correct Answer: who | tee user.lst
Explanation:
Introduction / Context:
The UNIX/Linux shell provides simple but powerful tools to capture command output to files. Sometimes you want to both see the output on screen and save it for later review. The tee utility is designed exactly for this purpose, splitting the output stream so that it is written to a file and echoed to the terminal at the same time.
Given Data / Assumptions:
Concept / Approach:
The pipeline operator | sends the standard output of the command on the left to the command on the right. The tee program reads from standard input, writes the same data to a file, and passes it through to standard output, so the terminal still shows it. Redirection operators like > and >> only write to files and do not mirror to the screen by default.
Step-by-Step Solution:
Verification / Alternative check:
Compare with who > user.lst (no terminal display) and who >> user.lst (appends, still no terminal display). Only tee duplicates output to both destinations simultaneously.
Why Other Options Are Wrong:
who > user.lst: saves but does not display on screen. who >> user.lst: appends but also hides output. who < user.lste: attempts input redirection from a likely non-existent file; unrelated to capturing output. None of the above: incorrect because the tee solution exists.
Common Pitfalls:
Forgetting that > truncates existing files; using >> unintentionally grows logs; assuming redirection shows output on screen. Use tee -a for safe appends.
Final Answer:
who | tee user.lst
Discussion & Comments