Quiz 2 Flashcards
Which of the following commands enables you to redirect standard output as well as standard error to a file?
> file 2>&1
You are looking for a variable that is set in a Bash login shell for all users. Which of the following files is the most likely location where this variable is set? (Choose two.)
a. /etc/profile
b. /etc/bashrc
c. ~/.bash_profile
d. ~/.bashrc
a. /etc/profile
and
c. ~/.bash_profile
A user has created a script with the name myscript. He tries to run it using the command myscript, but it is not started. The user has verified that the script permissions are set as executable. Which of the following is the most likely explanation?
The directory that contains the script is not in the PATH.
You need the output of the command ls to be used as input for the less command. Which of the following examples will do that for you?
ls | less
A user wants to remove her complete history. Which of the following approaches would do that?
Remove the ~/.bash_history file and type history -c.
Which of the following is not a valid method to repeat a command from history?
a. Press Ctrl-r and start typing a part of the command.
b. Type ! followed by the first letters in the command.
c. Type ! followed by the number of the command as listed in history.
d. Press Ctrl-x followed by the number in history.
D. Press Ctrl-x followed by the number in history.
For which of the following items can Bash completion be used?
a. Commands
b. Files
c. Variables
d. All of the above
All of the above
Which of the following commands enables you to replace every occurrence of old with new in a text file that is opened with vi?
:%s/old/new/g
Which approach works best if during the login process you want to show a message to all users who have just logged in to a shell session on your server?
Put the message in /etc/motd.
You are using man -k user, but you get the message “nothing appropriate.” Which of the following solutions is most likely to fix this for you?
C. Type mandb to update the mandb database.