RHCSA Exam Flashcards
Which of the following commands enables you to redirect standard output as well as standard error to a file?
a. 1&2> file
b. > file 2>&1
c. >1&2 file
d. 1>2& file
B.
You first must redirect the standard output to a file, and then 2>&1 is used
to specify that errors are to be treated the same way.
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 and C.
/etc/profile is the file that is processed for all users who are starting a
login shell. A user-specific version exists as well, with the name ~/.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?
a. An internal command is preventing the startup of the script.
b. Users are not allowed to run scripts.
c. The directory that contains the script is not in the PATH.
d. The script does not have appropriate permissions.
C.
On Linux, the current directory is not set in the PATH variable.
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?
a. ls > less
b. ls»_space; less
c. ls >| less
d. ls | less
D.
A pipe is used to process the output of the first command and use it as input
of the second com
A user wants to remove her complete history. Which of the following
approaches would do that?
a. Remove the ~/.bash_history file and type history -c.
b. Type history -c.
c. Remove the ~/.bash_history file.
d. Type history -c and close the current shell.
A.
The command history -c removes the in-memory state from the history
file of current history. Remove ~/.bash_history also to make sure that all his-
tory is removed. As an alternative to removing the .bash_history file, the user
can type history -c, followed by history -w.
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.
Ctrl-X is not a valid history command.
For which of the following items can Bash completion be used?
a. Commands
b. Files
c. Variables
d. All of the above
D.
Bash completion works for commands, files, variables and other names if
configuration for that has been added (like hostnames for the SSH command).
Which of the following commands enables you to replace every occurrence of
old with new in a text file that is opened with vi?
a. :%s/old/new/g
b. :%r/old/new/
c. :s/old/new/g
d. r:/old/new
A.
You need the command :%s/old/new/g to replace all instances of old with
new. % means that it must be applied on the entire file. s stands for substitute.
The g option is used to apply the command to not only the first occurrence in
a line (which is the default behavior) but all occurrences in the line.
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?
a. Put the message in /etc/issue.
b. Put the message in /etc/motd.
c. Put the message in /etc/profile.
d. Put the message in /etc/bashrc.
B.
The /etc/motd file contains messages that are displayed after user login on a
terminal session. If you want to show a message before users log in, edit the
/etc/issue file
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?
a. Type updatedb to update the mandb database.
b. Type makewhatis to update the mandb database.
c. Type mandb to update the mandb database.
d. Use man -K, no
C.
The man -k command uses a database to find the keywords you are looking for.
On RHEL 8, this database is updated with the mandb command. On older ver-
sions of RHEL (prior to RHEL 7), the makewhatis command was used instead.
Under which directory would you expect to find nonessential program
files?
a. /boot
b. /bin
c. /sbin
d. /usr
D.
Program files that are not required to boot a system are typically stored in a
subdirectory below the /usr directory. In old versions of RHEL, essential bina-
ries and system binaries were stored in /bin and /sbin, but on modern versions
of RHEL, these directories are a symbolic link to /usr/bin and /usr/sbin.
Under which directory would you expect to find log files?
a. /proc
b. /run
c. /var
d. /usr
C.
The /var directory is used on Linux to store files that may grow unexpectedly.
Which of the following directories would typically not be mounted on its own
dedicated device?
a. /etc
b. /boot
c. /home
d. /usr
A.
The /etc/ directory contains configuration files that are needed while
your server boots. Putting /etc on a dedicated device would make your server
unbootable.
Which of the following commands would give the most accurate overview of
mounted disk devices (without showing much information about mounted
system devices as well)?
a. mount
b. mount -a
c. df -hT
d. du -h
C.
The df -h command shows mounted devices and the amount of disk space
currently in use on these devices. The -T option helps in recognizing real file
systems (as opposed to kernel interfaces) because it shows the file system type
as well.
Which command enables you to show all files in the current directory so that
the newest files are listed last?
a. ls -lRt
b. ls -lrt
c. ls -alrt
d. ls -alr
C.
The option -a shows hidden files, -l gives a long listing, -t sorts on modifi-
cation time, which by default shows newest files first, and -r reverts the sorting
so that newest files are shown last.