0
0
Bash Scriptingscripting~5 mins

Silent input with read -s (passwords) in Bash Scripting - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the -s option do in the read command in bash?
The -s option makes the input silent, so what you type is not shown on the screen. This is useful for entering passwords.
Click to reveal answer
beginner
How can you prompt a user to enter a password silently in bash?
Use read -s -p "Enter password: " password. The -p shows the prompt, and -s hides the input.
Click to reveal answer
beginner
Why is silent input important when asking for passwords?
Silent input prevents others from seeing your password on the screen, protecting your privacy and security.
Click to reveal answer
intermediate
What happens if you use read -s without -p?
The input will be silent, but no prompt message will be shown. The user might not know what to type.
Click to reveal answer
beginner
How can you make sure the user pressed Enter after typing a silent password?
The read command waits for Enter by default, so after typing the password silently, pressing Enter submits the input.
Click to reveal answer
What does the -s option do in the bash read command?
ASaves the input to a file
BShows the input typed by the user
CHides the input typed by the user
DSkips the input prompt
Which command correctly prompts for a password silently with a message?
Aread -s -p "Password: " password
Bread -p "Password: " -s password
Cread password -s -p "Password: "
Dread password -p -s "Password: "
What will happen if you use read -s password without -p?
AInput will be visible and prompt shown
BInput will be silent but no prompt shown
CInput will be silent and prompt shown
DCommand will fail
Why is it important to use silent input for passwords?
ATo encrypt the password automatically
BTo speed up typing
CTo save password to a file
DTo prevent password from showing on screen
After typing a password silently with read -s, how does the user submit the input?
APress Enter key
BPress Ctrl+C
CType 'submit'
DInput submits automatically after 5 seconds
Explain how to use the read command to get a password silently from a user in bash.
Think about hiding input and showing a prompt.
You got /4 concepts.
    Why should you use silent input when asking for passwords in scripts?
    Consider what happens if someone looks at your screen.
    You got /4 concepts.