Unit 1: Linux Command Line and User Management - Practice Quiz

CSE493 — Linux System Administration 60 Questions
0 Correct 0 Wrong 60 Left
0/60

1 What is a Linux command-line interface primarily used for?

Accessing the command line Easy
A. Entering text commands
B. Replacing the operating system kernel whenever a command runs
C. Designing web pages visually
D. Drawing digital images

2 Which key combination commonly switches from a graphical session to a Linux virtual console?

Accessing command line using local console Easy
A. Ctrl+Alt+F3
B. Ctrl+Alt+Delete
C. Ctrl+Shift+S
D. Alt+Tab

3 Which desktop application provides access to a shell prompt?

Accessing command line using desktop Easy
A. Terminal
B. Calculator
C. A graphical settings tool that changes desktop themes and backgrounds
D. File manager

4 Which command displays the current working directory in Bash?

Executing commands using bash shell Easy
A. mkdir
B. cd
C. who
D. pwd

5 Which command lists files and directories?

Managing Files From the Command Line Easy
A. cat
B. pwd
C. rm
D. ls

6 Which character represents the root directory in Linux?

The Linux File System Hierarchy Easy
A. /
B. ..
C. ~
D. .

7 Which command searches a directory hierarchy for files by name?

Locating Files by Name Easy
A. find
B. less
C. A command that displays every file stored in memory and on disk
D. touch

8 Which command copies a file from one location to another?

Managing Files Using Command-Line Tools Easy
A. mv
B. mkdir
C. cp
D. rm

9 Which wildcard matches any number of characters in a file name?

Matching File Names Using Path Name Expansion Easy
A. []
B. *
C. ?
D. A wildcard that matches only hidden files in the current directory

10 What does the tilde (~) usually represent in the Bash shell?

Managing Files with Shell Expansion Easy
A. The root directory
B. The user's home directory
C. The current directory
D. The directory most recently removed by the current user

11 Which command displays the manual page for ls?

Reading Documentation Using man Command Easy
A. doc open ls manual
B. man ls
C. info --ls
D. help ls

12 What is the pinfo command used to view?

Reading Documentation Using pinfo Command Easy
A. All graphical help pages downloaded from the Red Hat website
B. User passwords
C. Info documentation
D. Running processes

13 What is commonly stored in /usr/share/doc?

Reading Documentation in /usr/share/doc Easy
A. Temporary files created by every currently running application
B. Device files
C. User home directories
D. Package documentation

14 Which command creates an empty file if the file does not already exist?

Creating, Viewing, and Editing Text Files Easy
A. cat
B. grep
C. less
D. touch

15 Which operator redirects command output to a file and overwrites the file?

Redirecting Output to a File or Program Easy
A. <
B. >
C. |
D. >>

16 Which program is a command-line text editor commonly available on Linux?

Editing Text Files from the Shell Prompt Easy
A. A desktop file manager that can browse folders but cannot edit text
B. vim
C. passwd
D. find

17 What is the main purpose of a Linux group?

Users and Groups Easy
A. Creating a separate operating system installation for each user
B. Sharing permissions among users
C. Starting the Linux kernel
D. Formatting storage devices

18 Which command commonly runs a command with elevated privileges?

Gaining Superuser Access Easy
A. history
B. sudo
C. date
D. echo

19 Which command creates a local user account?

Managing Local User Accounts Easy
A. A command that creates a home directory without creating a user account
B. usermod
C. useradd
D. userdel

20 Which command changes a user's password in Linux?

Managing User Passwords Easy
A. passwd
B. chown
C. password
D. useradd

21 A RHEL workstation is displaying the graphical login screen. Which key combination commonly switches to a text-based virtual console on TTY3?

Accessing command line using local console Medium
A. Ctrl+Shift+F3
B. Ctrl+Alt+Delete
C. Ctrl+Alt+F3
D. 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?

Accessing command line using desktop Medium
A. gnome-session
B. gnome-control-center
C. gnome-terminal
D. gnome-shell

23 Which Bash command prints the literal text $HOME/*.txt without expanding either the variable or the wildcard?

Executing commands using bash shell Medium
A. echo ${HOME}/*.txt
B. echo $HOME/*.txt
C. echo "$HOME/*.txt"
D. 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?

The Linux File System Hierarchy Medium
A. /var/lib/inventory
B. /etc/inventory
C. /usr/bin/inventory
D. /boot/inventory

25 Which command searches /srv and its subdirectories for regular files whose names end in .conf?

Locating Files by Name Medium
A. locate /srv -type f '*.conf'
B. grep /srv -name '*.conf'
C. find /srv -type f -name '*.conf'
D. find /srv -type d -name '*.conf'

26 Which command recursively copies the project directory into /backup while preserving permissions, ownership, timestamps, and symbolic links?

Managing Files Using Command-Line Tools Medium
A. mv -p project /backup/
B. cp -r project /backup/
C. cp -a project /backup/
D. 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?

Matching File Names Using Path Name Expansion Medium
A. report[0-9].txt
B. report?.txt
C. report[1-10].txt
D. report*.txt

28 What output is produced by the Bash command echo {report,summary}{1,2}.txt?

Managing Files with Shell Expansion Medium
A. {report,summary}1.txt {report,summary}2.txt
B. report12.txt summary12.txt
C. report1.txt report2.txt summary1.txt summary2.txt
D. 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?

Getting Help in Red Hat Enterprise Linux Medium
A. useradd --help
B. whatis --full useradd
C. help useradd
D. 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?

Reading Documentation Using man Command Medium
A. man 5 passwd
B. man 7 passwd
C. man 1 passwd
D. man 8 passwd

31 Which command opens the GNU Info documentation for the core utilities in the pinfo text-based browser?

Reading Documentation Using pinfo Command Medium
A. pinfo --help-only coreutils
B. pinfo /etc/coreutils
C. pinfo --man coreutils
D. 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?

Reading Documentation in /usr/share/doc Medium
A. cat /usr/share/doc/example/README.gz
B. tar -r /usr/share/doc/example/README.gz
C. less /usr/share/doc/example/README.gz
D. 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?

Creating, Viewing, and Editing Text Files Medium
A. truncate notes.txt
B. cat notes.txt
C. mkdir notes.txt
D. 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?

Redirecting Output to a File or Program Medium
A. command > run.log 2>&1
B. command | run.log 2>&1
C. command >> run.log 2>&1
D. 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?

Editing Text Files from the Shell Prompt Medium
A. :wq
B. :set
C. :q!
D. :edit

36 Which command opens notes.txt in the GNOME graphical text editor while allowing the current shell prompt to remain usable?

Editing Text Files with a Graphical Editor Medium
A. vim notes.txt &
B. gedit notes.txt &
C. gedit notes.txt &&
D. nano notes.txt &&

37 Which command creates a local group named developers with the specific group ID 4500?

Managing Local Group Accounts Medium
A. groupadd -g 4500 developers
B. groupadd -u 4500 developers
C. groupmod -g 4500 developers
D. 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?

Gaining Superuser Access Medium
A. login root
B. sudo -u root
C. su root -c
D. sudo -i

39 Which command creates a local user named analyst, explicitly creates a home directory, and sets Bash as the login shell?

Managing Local User Accounts Medium
A. usermod -m -s /bin/bash analyst
B. useradd -d /bin/bash -m analyst
C. adduser -g /bin/bash analyst
D. 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?

Managing User Passwords Medium
A. chage -m 90 alice
B. chage -M 90 alice
C. usermod -e 90 alice
D. 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?

Accessing command line using local console Hard
A. Press Ctrl+Alt+F3, log in on the virtual console, and run exit when finished
B. Run systemctl isolate multi-user.target, log in remotely, and restore the graphical target
C. Press Alt+F3, enter the root password, and start a new Bash login shell
D. Press 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?

Accessing command line using desktop Hard
A. /etc/profile
B. ~/.bashrc
C. ~/.bash_logout
D. ~/.bash_profile

43 What output is produced by v='a b'; printf '<%s>\n' $v "$v" in Bash?

Executing commands using bash shell Hard
A. <$v> then <$v> on separate lines
B. <a> then <b> then <a b> on separate lines
C. <a b> then <a b> on separate lines
D. <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?

The Linux File System Hierarchy Hard
A. /usr/share/application
B. /var/lib/application
C. /etc/application
D. /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?

Locating Files by Name Hard
A. find /srv -follow -type f -name 'report*'
B. find /srv -depth -type f -name 'report*'
C. find /srv -links 1 -type f -name 'report*'
D. 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?

Managing Files Using Command-Line Tools Hard
A. find /data -type f -name '*.tmp' -exec rm -- {} +
B. find /data -type f -name '*.tmp' | xargs rm --
C. rm -- $(find /data -type f -name '*.tmp')
D. 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 ..?

Matching File Names Using Path Name Expansion Hard
A. * .[!.]* ..?*
B. *.[!.]* ..?*
C. * .?*
D. * .*

48 No project1, project2, or project3 directories currently exist. Which single command creates src and doc beneath each of those three directories?

Managing Files with Shell Expansion Hard
A. mkdir -p project{1,3}/{src,doc}
B. mkdir -p project[1-3]/{src,doc}
C. mkdir -p project{1..3}/{src,doc}
D. 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?

Reading Documentation Using man Command Hard
A. man -k passwd
B. man 5 passwd
C. man 1 passwd
D. 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?

Reading Documentation Using pinfo Command Hard
A. whatis tar
B. man -k tar
C. apropos tar
D. 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?

Reading Documentation in /usr/share/doc Hard
A. rpm -qlp httpd
B. dnf provides httpd
C. rpm -qf httpd
D. 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?

Getting Help From Red Hat Hard
A. subscription-manager facts
B. dnf history info
C. sos report --batch
D. 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?

Creating, Viewing, and Editing Text Files Hard
A. tail -F /var/log/example.log
B. cat -n /var/log/example.log
C. tail -f /var/log/example.log
D. 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?

Redirecting Output to a File or Program Hard
A. producer >run.log 2>&1 | tee
B. producer 2>run.log | tee run.log
C. producer 2>&1 | tee run.log
D. 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?

Editing Text Files from the Shell Prompt Hard
A. :%s/^#//
B. :v/^#/d
C. :g/#/d
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?

Editing Text Files with a Graphical Editor Hard
A. gedit notes.txt 2>/dev/null
B. gedit notes.txt >/dev/null 2>&1 &
C. gedit notes.txt 2>&1 >/dev/null &
D. 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?

Managing Local Group Accounts Hard
A. They automatically change from GID 2000 to GID 3000
B. They retain GID 2000 and require a separate ownership update
C. They become owned by the files' respective primary users
D. They lose group permissions until the next user login

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?

Gaining Superuser Access Hard
A. sudo -i
B. su - root
C. su root
D. 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?

Managing Local User Accounts Hard
A. useradd -m -g analytics -G wheel -s /sbin/nologin maya
B. useradd -m -g analytics -G wheel -s /bin/bash maya
C. useradd -m -G analytics -g wheel -s /bin/bash maya
D. 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?

Managing User Passwords Hard
A. chage -M 90 -w 14 -E 7 alice
B. chage -I 90 -M 14 -W 7 alice
C. chage -M 90 -W 14 -I 7 alice
D. chage -m 90 -W 14 -I 7 alice