Unit 1: Linux Command Line and User Management - Practice Quiz
1 What is a Linux command-line interface primarily used for?
2 Which key combination commonly switches from a graphical session to a Linux virtual console?
3 Which desktop application provides access to a shell prompt?
4 Which command displays the current working directory in Bash?
mkdir
cd
who
pwd
5 Which command lists files and directories?
cat
pwd
rm
ls
6 Which character represents the root directory in Linux?
/
..
~
.
7 Which command searches a directory hierarchy for files by name?
find
less
A command that displays every file stored in memory and on disk
touch
8 Which command copies a file from one location to another?
mv
mkdir
cp
rm
9 Which wildcard matches any number of characters in a file name?
[]
*
?
A wildcard that matches only hidden files in the current directory
10
What does the tilde (~) usually represent in the Bash shell?
11
Which command displays the manual page for ls?
doc open ls manual
man ls
info --ls
help ls
12
What is the pinfo command used to view?
13
What is commonly stored in /usr/share/doc?
14 Which command creates an empty file if the file does not already exist?
cat
grep
less
touch
15 Which operator redirects command output to a file and overwrites the file?
<
>
|
>>
16 Which program is a command-line text editor commonly available on Linux?
A desktop file manager that can browse folders but cannot edit text
vim
passwd
find
17 What is the main purpose of a Linux group?
18 Which command commonly runs a command with elevated privileges?
history
sudo
date
echo
19 Which command creates a local user account?
A command that creates a home directory without creating a user account
usermod
useradd
userdel
20 Which command changes a user's password in Linux?
passwd
chown
password
useradd
21 A RHEL workstation is displaying the graphical login screen. Which key combination commonly switches to a text-based virtual console on TTY3?
Ctrl+Shift+F3
Ctrl+Alt+Delete
Ctrl+Alt+F3
Alt+Shift+F3
22 A user is working in the GNOME desktop and wants to open a terminal from the Run a Command dialog. Which command should the user enter?
gnome-session
gnome-control-center
gnome-terminal
gnome-shell
23
Which Bash command prints the literal text $HOME/*.txt without expanding either the variable or the wildcard?
echo ${HOME}/*.txt
echo $HOME/*.txt
echo "$HOME/*.txt"
echo '$HOME/*.txt'
24 An application needs a directory for persistent, variable data such as an inventory database. Which location best follows the Linux file system hierarchy?
/var/lib/inventory
/etc/inventory
/usr/bin/inventory
/boot/inventory
25
Which command searches /srv and its subdirectories for regular files whose names end in .conf?
locate /srv -type f '*.conf'
grep /srv -name '*.conf'
find /srv -type f -name '*.conf'
find /srv -type d -name '*.conf'
26
Which command recursively copies the project directory into /backup while preserving permissions, ownership, timestamps, and symbolic links?
mv -p project /backup/
cp -r project /backup/
cp -a project /backup/
install -r project /backup/
27
A directory contains report1.txt, report7.txt, report10.txt, and reportA.txt. Which pattern matches only report1.txt and report7.txt?
report[0-9].txt
report?.txt
report[1-10].txt
report*.txt
28
What output is produced by the Bash command echo {report,summary}{1,2}.txt?
{report,summary}1.txt {report,summary}2.txt
report12.txt summary12.txt
report1.txt report2.txt summary1.txt summary2.txt
report1.txt summary1.txt report2.txt summary2.txt
29
An administrator remembers the useradd command but needs a quick summary of its available options. Which command is most appropriate?
useradd --help
whatis --full useradd
help useradd
info --summary useradd
30
An administrator wants to read the manual page describing the format of the /etc/passwd file rather than the passwd command. Which command should be used?
man 5 passwd
man 7 passwd
man 1 passwd
man 8 passwd
31
Which command opens the GNU Info documentation for the core utilities in the pinfo text-based browser?
pinfo --help-only coreutils
pinfo /etc/coreutils
pinfo --man coreutils
pinfo coreutils
32
A package provides a compressed documentation file at /usr/share/doc/example/README.gz. Which command lets an administrator read it without first creating an uncompressed copy?
cat /usr/share/doc/example/README.gz
tar -r /usr/share/doc/example/README.gz
less /usr/share/doc/example/README.gz
zless /usr/share/doc/example/README.gz
33
Which command creates an empty file named notes.txt if it does not exist, but only updates its timestamps if it already exists?
truncate notes.txt
cat notes.txt
mkdir notes.txt
touch notes.txt
34
Which Bash command writes both standard output and standard error from command to run.log, replacing the file's previous contents?
command > run.log 2>&1
command | run.log 2>&1
command >> run.log 2>&1
command 2> run.log 1>&2
35 After modifying a file in Vim, which command entered in normal mode saves the changes and exits the editor?
:wq
:set
:q!
:edit
36
Which command opens notes.txt in the GNOME graphical text editor while allowing the current shell prompt to remain usable?
vim notes.txt &
gedit notes.txt &
gedit notes.txt &&
nano notes.txt &&
37
Which command creates a local group named developers with the specific group ID 4500?
groupadd -g 4500 developers
groupadd -u 4500 developers
groupmod -g 4500 developers
useradd -g 4500 developers
38
A permitted administrator wants a root login shell with root's environment while keeping the action recorded through sudo. Which command should be used?
login root
sudo -u root
su root -c
sudo -i
39
Which command creates a local user named analyst, explicitly creates a home directory, and sets Bash as the login shell?
usermod -m -s /bin/bash analyst
useradd -d /bin/bash -m analyst
adduser -g /bin/bash analyst
useradd -m -s /bin/bash analyst
40
Which command configures the user alice so that her password must be changed after a maximum of 90 days?
chage -m 90 alice
chage -M 90 alice
usermod -e 90 alice
passwd -n 90 alice
41
A RHEL workstation's graphical session is unresponsive, but the kernel and systemd are still running. Which action provides an independent text login without changing the system's boot target or terminating the graphical session?
Ctrl+Alt+F3, log in on the virtual console, and run exit when finished
systemctl isolate multi-user.target, log in remotely, and restore the graphical target
Alt+F3, enter the root password, and start a new Bash login shell
Ctrl+Alt+Backspace, log in through the display manager, and close the terminal
42 A user opens a new GNOME Terminal window and wants a custom Bash function to be defined automatically. The terminal starts an interactive non-login Bash shell. Which per-user file should normally contain the function?
/etc/profile
~/.bashrc
~/.bash_logout
~/.bash_profile
43
What output is produced by v='a b'; printf '<%s>\n' $v "$v" in Bash?
<$v> then <$v> on separate lines
<a> then <b> then <a b> on separate lines
<a b> then <a b> on separate lines
<a> then <b> then <a> then <b> on separate lines
44 An application must store persistent, host-specific state that changes while the application runs, such as an internal database. Which directory best follows the Linux file system hierarchy?
/usr/share/application
/var/lib/application
/etc/application
/run/application
45
The directory /srv contains a mounted archive file system at /srv/archive. Which command finds regular files beginning with report under /srv without descending into that mounted file system?
find /srv -follow -type f -name 'report*'
find /srv -depth -type f -name 'report*'
find /srv -links 1 -type f -name 'report*'
find /srv -xdev -type f -name 'report*'
46
Files under /data may contain spaces, quotes, or newline characters in their names. Which command safely removes every regular file whose name ends in .tmp?
find /data -type f -name '*.tmp' -exec rm -- {} +
find /data -type f -name '*.tmp' | xargs rm --
rm -- $(find /data -type f -name '*.tmp')
for f in $(find /data -name '*.tmp'); do rm -- $f; done
47
Assume Bash and nullglob are enabled. Which pattern list expands to ordinary names and hidden names while excluding the special entries . and ..?
* .[!.]* ..?*
*.[!.]* ..?*
* .?*
* .*
48
No project1, project2, or project3 directories currently exist. Which single command creates src and doc beneath each of those three directories?
mkdir -p project{1,3}/{src,doc}
mkdir -p project[1-3]/{src,doc}
mkdir -p project{1..3}/{src,doc}
mkdir project{1..3}/{src,doc}
49
Both a command and a configuration-file format are named passwd. Which command opens the manual page describing the /etc/passwd file format rather than the executable?
man -k passwd
man 5 passwd
man 1 passwd
man -f passwd
50
A GNU utility has an Info manual organized as linked nodes, and the administrator wants to navigate those nodes using a text interface. Which command is most appropriate for opening the manual for tar?
whatis tar
man -k tar
apropos tar
pinfo tar
51
The httpd RPM is installed, but its documentation directory name includes an unfamiliar version suffix. Which command reliably lists documentation files installed by that package?
rpm -qlp httpd
dnf provides httpd
rpm -qf httpd
rpm -qd httpd
52 Red Hat Support requests a diagnostic archive containing logs, configuration details, and system information for a support case. Which command is designed to collect that archive on current RHEL systems?
subscription-manager facts
dnf history info
sos report --batch
insights-client --checkin
53
An administrator must continuously monitor /var/log/example.log. The application rotates the log by renaming it and creating a new file with the original name. Which command continues following the new file after rotation?
tail -F /var/log/example.log
cat -n /var/log/example.log
tail -f /var/log/example.log
less +F /var/log/example.log
54
Which Bash command sends both standard output and standard error from producer through tee, so both streams appear on the terminal and are stored in run.log?
producer >run.log 2>&1 | tee
producer 2>run.log | tee run.log
producer 2>&1 | tee run.log
producer | tee run.log 2>&1
55
While editing a file in vi or vim, which ex command deletes every line whose first character is #, without deleting lines containing # elsewhere?
:%s/^#//
:v/^#/d
:g/#/d
:g/^#/d
56
From a graphical terminal, an administrator wants to launch gedit, regain the shell prompt immediately, and suppress both standard output and standard error. Which Bash command has the required redirection order?
gedit notes.txt 2>/dev/null
gedit notes.txt >/dev/null 2>&1 &
gedit notes.txt 2>&1 >/dev/null &
gedit notes.txt >/dev/null 2>&1
57
Group research has GID 2000, and many existing files are owned by that GID. An administrator runs groupmod -g 3000 research. What happens to those existing files?
58
A user is authorized through sudo, does not know the root password, and needs a root login-style shell with root's home directory and login environment. Which command is most appropriate?
sudo -i
su - root
su root
sudo -s
59
Groups analytics and wheel already exist. Which command creates user maya with a home directory, analytics as the primary group, wheel as a supplementary group, and Bash as the login shell?
useradd -m -g analytics -G wheel -s /sbin/nologin maya
useradd -m -g analytics -G wheel -s /bin/bash maya
useradd -m -G analytics -g wheel -s /bin/bash maya
useradd -M -g analytics -G wheel -s /bin/bash maya
60
Which command sets user alice to a maximum password age of 90 days, a warning period of 14 days, and account disabling 7 days after password expiration?
chage -M 90 -w 14 -E 7 alice
chage -I 90 -M 14 -W 7 alice
chage -M 90 -W 14 -I 7 alice
chage -m 90 -W 14 -I 7 alice
Did this save you a night before the exam?
LPU Notes is free, and it stays free. Ads cover part of the server bill. The rest comes out of a student's own pocket: the domain, the storage, and keeping the site up through the weeks everyone needs it at once.
The payment button didn't load. An ad blocker or a filtered network is the usual reason. to try again.
Nothing here is ever locked, and nothing unlocks. Chip in only if it was worth it. What it pays for →