RHCSA Exam Flashcards

1
Q

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

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

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

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

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.

A

C.

On Linux, the current directory is not set in the PATH variable.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

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&raquo_space; less
c. ls >| less
d. ls | less

A

D.

A pipe is used to process the output of the first command and use it as input
of the second com

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

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

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

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.

A

D.

Ctrl-X is not a valid history command.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

For which of the following items can Bash completion be used?
a. Commands
b. Files
c. Variables
d. All of the above

A

D.

Bash completion works for commands, files, variables and other names if
configuration for that has been added (like hostnames for the SSH command).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

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

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

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.

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

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

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Under which directory would you expect to find nonessential program
files?
a. /boot
b. /bin
c. /sbin
d. /usr

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Under which directory would you expect to find log files?
a. /proc
b. /run
c. /var
d. /usr

A

C.

The /var directory is used on Linux to store files that may grow unexpectedly.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Which of the following directories would typically not be mounted on its own
dedicated device?
a. /etc
b. /boot
c. /home
d. /usr

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

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

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

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

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Which command enables you to copy hidden files as well as regular files from
/home/$USER to the current directory?
a. cp -a /home/$USER .
b. cp -a /home/$USER/* .
c. cp -a /home/$USER/. .
d. cp -a home/$USER. .

A

C.

To copy hidden files as well as regular files, you need to put a . after the
name of the directory the files are in. Answer A copies hidden files as well, but
it creates a subdirectory $USER in the current directory.

17
Q

Which command enables you to rename the file myfile to mynewfile?
a. mv myfile mynewfile
b. rm myfile mynewfile
c. rn myfile mynewfile
d. ren myfile mynewfile

A

A.

The mv command enables you to move files and rename files.

18
Q

Which statement about hard links is not true?
a. Hard links cannot be created to directories.
b. Hard links cannot refer to files on other devices.
c. The inode keeps a hard link counter.
d. If the original hard link is removed, all other hard link

A

D.

In hard links, no difference exists between the first hard link and subse-
quent hard links.

19
Q

Which command creates a symbolic link to the directory /home in the
directory /tmp?
a. ln /tmp /home
b. ln /home /tmp
c. ln -s /home /tmp
d. ln -s /tmp /home

A

C.

The option -s is used to create a symbolic link. While creating a link, you
first have to specify the source, and next you specify the destination.

20
Q

Which tar option enables you to add one single file to a tar archive?
a. -a
b. -A
c. -r
d. -u

A

C.

Use the option -r to add one single file to an archive you have created with tar.