Which command will send the output of the 'who' command to a text file?

Prepare for the LPI Linux Essentials Exam. Study with flashcards and multiple choice questions, each with hints and explanations. Get exam-ready!

The command that correctly sends the output of the 'who' command to a text file is by using the redirection operator '>'. When you use the command 'who > who.txt', it instructs the shell to run the 'who' command and then redirect its output into a file named 'who.txt'. If the file does not already exist, it will be created. If it does exist, its contents will be overwritten with the new output from the 'who' command.

Using '>>' instead, as noted in another choice, would append the output to the file instead of overwriting it. Therefore, while both options involving redirection deal with sending output to a file, only the first one will replace the existing content.

The options that include 'output who > who.txt' and 'who -o > who.txt' are incorrect due to improper syntax. The 'output' command does not exist in many shell environments, and the 'who' command does not recognize an '-o' option for output control. Thus, a correctly formatted command would use just 'who' with the appropriate redirection operator.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy