A Linux administrator needs to read user input during the execution of a shell script to capture a username that will be used later in the script. Which built-in command should be used to fulfill this requirement most effectively?
You selected this option
Use echo to display a prompt and then capture the user input.
You selected this option
Use source to read the username from a separate file.
You selected this option
Apply grep on the /etc/passwd file to extract a list of usernames.
The read command is specifically designed to accept user input during shell script execution. Using read is the most direct and efficient way to capture user input and store it in a variable for later use. Even though commands like echo and source are useful for outputting messages and evaluating files in the current shell context, they do not fulfill the purpose of reading user input.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What does the 'read' command do in a shell script?
Open an interactive chat with Bash
Can you explain how to use the 'echo' command with user input?
Open an interactive chat with Bash
What is the purpose of the '/etc/passwd' file in Linux?