Unit 5 - Practice Quiz
1 Which command is most commonly used to create a new, empty file or to update the modification timestamp of an existing file?
2 Which of the following is a simple, beginner-friendly command-line text editor available on most Linux systems?
3 Which command searches the entire file system for files and directories matching a specific name, size, or modification time?
4
The locate command finds files very quickly because it searches...
5
Which command is used to create a new directory named mydocs?
6
To copy a file named report.txt to report_backup.txt, which command would you use?
7 What command is used to search for lines containing a specific pattern within a text file?
8
Which command would you use to display only the last 10 lines of a file named logfile.log?
9
In the command ls -l > file_list.txt, what does the > character do?
10 Which operator should be used to add the output of a command to the end of a file without deleting its existing content?
11 Which command is used to display basic information about the system's kernel, such as its version and release name?
12 The Linux kernel file itself is typically stored in which directory?
13 What is the recommended command for loading a kernel module and its dependencies?
14 To remove a kernel module from the running kernel, which command would you use?
15 Which command provides a formatted list of all currently loaded modules in the Linux kernel?
16 If you want to see detailed information about a specific kernel module file (like its author, license, and parameters), which command is used?
17
What is the role of the initramfs during the boot process?
18 The very first process started by the Linux kernel, which has a Process ID (PID) of 1, is called:
19 To make a permanent change to the GRUB2 boot menu, such as setting the default OS, which file should you edit?
20
After editing the /etc/default/grub file, what command must be run to apply the changes to the boot loader?
21
You are editing a large configuration file named app.conf using vim. What is the most efficient command to find all occurrences of the string TIMEOUT=30 and replace them with TIMEOUT=60 throughout the entire file?
Esc, then type :%s/TIMEOUT=30/TIMEOUT=60/g and press Enter.
Esc, then type :g/TIMEOUT=30/s//TIMEOUT=60/ and press Enter.
Esc, then type :s/TIMEOUT=30/TIMEOUT=60/ and press Enter.
Esc, then type :/TIMEOUT=30 followed by cw, type TIMEOUT=60, and repeat for each occurrence.
22
You have a log file, access.log, where each line is a record. You want to display only the lines that contain the IP address 192.168.1.50 but do not contain the word POST. Which command would achieve this?
cat access.log | grep '192.168.1.50' -o 'POST'
grep '192.168.1.50' && !grep 'POST' access.log
grep '192.168.1.50' access.log | grep -v 'POST'
grep '192.168.1.50' -v 'POST' access.log
23
A developer needs to find all C source files (*.c) in the /usr/src directory that have been modified in the last 10 days and are larger than 50 kilobytes. Which find command correctly implements this search?
find /usr/src -name '*.c' -mtime -10 -size +50k
find /usr/src -name '*.c' AND -mtime < 10 AND -size > 50k
find /usr/src -file '*.c' -mtime 10 -size 50k
locate /usr/src '*.c' --mtime -10 --size +50k
24
You have a file named data.txt and you create a hard link to it named data_hardlink. You also create a symbolic link to it named data_symlink. What happens if you delete the original file, data.txt?
data_hardlink and data_symlink become unusable.
data_hardlink, but data_symlink becomes a broken link.
data_symlink, but data_hardlink becomes a broken link.
25
You are running a script, backup.sh, that produces important status messages to standard output (stdout) and error messages to standard error (stderr). How can you redirect the status messages to backup.log and the error messages to errors.log in a single command?
./backup.sh > backup.log 2> errors.log
./backup.sh 1> backup.log 2>> backup.log
./backup.sh &> backup.log
./backup.sh > backup.log | tee errors.log
26
You need to permanently increase the GRUB2 boot menu timeout to 15 seconds and set the second menu entry (index 1) as the default boot option. After editing /etc/default/grub, which two lines should be correctly modified?
GRUB_TIMEOUT_STYLE=15 and GRUB_DEFAULT="1"
GRUB_TIMEOUT=15 and GRUB_DEFAULT=1
GRUB_WAIT=15 and GRUB_DEFAULT=2
GRUB_HIDDEN_TIMEOUT=15 and GRUB_DEFAULT_ENTRY=1
27
A new network card requires the e1000e kernel module, but it's not loading on boot. To ensure it loads automatically every time the system starts, what is the recommended method on a modern systemd-based Linux distribution?
modprobe -s e1000e to make it permanent.
/boot/grub/grub.cfg file to add module=e1000e to the kernel line.
insmod e1000e to the /etc/rc.local file.
net.conf in /etc/modules-load.d/ with the line e1000e.
28
You suspect the nouveau graphics driver module is causing system instability. Before unloading it, you want to see detailed information about it, including the file path, license, and any parameters it accepts. Which command provides this specific information?
lsmod | grep nouveau
modinfo nouveau
dmesg | grep nouveau
modprobe -c | grep nouveau
29
A system administrator needs to check the exact kernel command-line parameters that were used to boot the currently running system. Which file in the /proc filesystem contains this information?
/proc/kallsyms
/proc/cmdline
/proc/version
/proc/config.gz
30
After editing /etc/default/grub to change the default kernel boot parameters, the changes do not take effect on reboot. What crucial step was most likely missed?
mount -o remount,rw /boot
systemctl restart grubd.service
grub2-mkconfig -o /boot/grub2/grub.cfg
touch /boot/grub2/grub.cfg
31
You need to extract the usernames (first column) and shells (last column) for all users whose user ID (third column) is greater than 1000 from the /etc/passwd file. Which awk command is best suited for this task?
cat /etc/passwd | awk -F, '1, $7}'
awk 'BEGIN{FS=":"} if(3 > 1000) {print 1, 7}' /etc/passwd
awk -F: '1, $7}' /etc/passwd
awk '{if (1 $NF}' /etc/passwd
32
You want to create a compressed archive of the /var/log directory, naming it logs.tar.bz2. However, you need to exclude the journal subdirectory from the archive. Which tar command accomplishes this?
tar -cjvf logs.tar.bz2 --exclude='/var/log/journal' /var/log
tar -xzvf logs.tar.bz2 /var/log --except=journal
tar -c /var/log | bzip2 --exclude='journal' > logs.tar.bz2
tar -cvf logs.tar.bz2 /var/log --ignore=journal
33
You are looking for a configuration file that you know contains the string ListenAddress, but you can't remember its name or exact location, though you suspect it's somewhere in /etc. Which command is most effective for finding the names of the files containing this string?
grep -lR 'ListenAddress' /etc
cat /etc/* | grep 'ListenAddress'
locate ListenAddress | grep /etc
find /etc -exec grep 'ListenAddress' {} \;
34
You need to programmatically comment out a line containing LogLevel debug in a configuration file /etc/httpd/conf/httpd.conf using a single, non-interactive command. Which sed command would be appropriate for this in-place edit?
sed 's/LogLevel debug/##/' > /etc/httpd/conf/httpd.conf
sed -i 's/^LogLevel debug/#LogLevel debug/' /etc/httpd/conf/httpd.conf
sed -o '/LogLevel debug/d' /etc/httpd/conf/httpd.conf
echo '#LogLevel debug' >> /etc/httpd/conf/httpd.conf
35
What is the primary function of the tee command in a pipeline, as shown in the example: ps aux | tee process_list.txt | grep 'nginx'?
process_list.txt and standard output to grep.
ps aux and writes only lines containing nginx to process_list.txt.
ps aux to process_list.txt and then displays it to the screen.
36
You need to access a Linux system to reset the root password. The standard procedure involves interrupting the boot process to add init=/bin/bash to the kernel parameters. Which key do you typically press at the GRUB2 menu to edit the selected boot entry for a single boot?
F10 to modify boot parameters
e to edit commands
Tab to edit options
c for command-line
37
What is the primary purpose of the initramfs (initial RAM filesystem) in the Linux boot process?
memtest) before the operating system loads.
38
What is the key advantage of using modprobe over insmod to load a kernel module?
modprobe allows you to set module parameters, whereas insmod does not.
modprobe is a newer, faster version of insmod with identical functionality.
modprobe automatically resolves and loads any dependency modules that the requested module requires.
modprobe can load modules that are not located in the standard /lib/modules directory.
39
A system administrator runs the command lsmod and sees the following output snippet:
vboxguest 348160 2 vboxsf
vboxsf 40960 0
What does the number 2 in the vboxguest line signify?
vboxsf module is dependent on vboxguest, and there is one other dependent module.
vboxguest is using two other modules.
40 You have compiled and installed a new custom kernel. To make it bootable, you need to update the bootloader configuration. Which command is most commonly used on modern Linux systems to automatically detect the new kernel and add it to the GRUB menu?
update-grub or grub2-mkconfig -o /boot/grub2/grub.cfg
mkinitrd /boot/initramfs-new.img
grub2-install /dev/sda
efibootmgr -c -d /dev/sda -p 1 -L "New Kernel"
41
You need to modify /etc/config.conf in-place. You want to delete all lines containing the word "DEPRECATED", and on all remaining lines that start with "Listen", you want to change the first occurrence of "80" to "8080". Which sed command correctly and safely accomplishes this in the specified order?
42
You are looking for all files in /var/log that are larger than 10MB, have been modified in the last 2 days, and contain the case-insensitive string "fatal error". For maximum efficiency, you want to minimize the number of processes created and avoid running grep on files that don't match the size and time criteria. Which find command is the most efficient and robust?
43
Given a log file access.log with lines like 1.2.3.4 - - [10/Oct/2000:13:55:36 -0700] "GET /path/file.html HTTP/1.0" 404 2326. You want to count the number of requests for each IP address that resulted in a 404 status code. The final output must be sorted by count in descending order, showing only the top 5 IPs. Which command pipeline is correct?
44
You need to run a command long_running_script.sh. You want to append its standard output to out.log and its standard error to err.log, while simultaneously viewing both stdout and stderr on your terminal in real-time. Which command achieves this?
45
You need to change the kernel's I/O scheduler for the block device /dev/sdb from mq-deadline to kyber for the current session only. You want to use the most direct and fundamental file-based interface provided by the kernel for this task. Which command should you use?
46
A newly compiled kernel module my_driver.ko fails to load using insmod ./my_driver.ko, reporting a "disagrees about version of symbol module_layout" or a similar "invalid format" error with vermagic mismatch in dmesg. What is the most likely cause and the correct way to fix it?
depmod -a to recalculate module dependencies and checksums.
modprobe ./my_driver.ko to resolve dependencies automatically.
47
A kernel module faulty_driver is known to cause instability. You need to prevent it from being loaded automatically by any mechanism (e.g., udev, manual modprobe), but you do not want to remove the module file itself. Which configuration in /etc/modprobe.d/blacklist.conf will be most effective and robust in achieving this?
48
Your system fails to boot after a disk migration, dropping to a dracut emergency shell. The initramfs cannot find the root filesystem, which now has a new UUID. From the emergency shell, how can you temporarily fix the boot process to get the system running without rebooting into a rescue environment?
dracut --regenerate-all --force from the emergency shell to automatically detect the new hardware and rebuild the initramfs in RAM.
insmod and then exit the shell.
/dev/sdb2), exit the shell, and at the dracut> prompt, type mount /dev/sdb2 /sysroot followed by exit.
/dev/sdb2), mount it, chroot into it, update /etc/fstab and GRUB, and regenerate the initramfs.
49
You need to permanently add the iommu=pt kernel parameter to all Linux boot entries and also ensure that any new kernels installed in the future will automatically inherit this parameter. Which sequence of actions is the correct, distribution-agnostic method?
GRUB_CMDLINE_LINUX="iommu=pt" to /etc/environment and run source /etc/environment.
/etc/grub.d/09_custom_params containing echo 'set linux_cmdline_args="iommu=pt"' and make it executable.
/boot/grub/grub.cfg and add iommu=pt to every line that starts with linux or linuxefi.
GRUB_CMDLINE_LINUX variable in /etc/default/grub to include iommu=pt and then run grub2-mkconfig -o /boot/grub2/grub.cfg or update-grub.
50
You are creating a daily incremental backup of /home/user to /mnt/backup/ using rsync. You want to use a directory from the previous day (e.g., /mnt/backup/2023-10-26) as a reference to minimize data transfer by creating hard links for unchanged files. Which rsync command correctly implements this efficient, space-saving strategy?
51
You need to find all symbolic links within /usr/local whose targets resolve to a path outside of the /usr/local directory tree. This includes links pointing to places like /opt/, /home/, or even dangling links. Which command will correctly identify and print only these specific links?
52
You have a file data.txt with three columns: Category Item Value. You want to calculate the sum of Value for each Category and print only the categories whose total sum is greater than 1000. The final output should be formatted as Category,TotalValue. Which awk command correctly performs this analysis?
53
A system update has failed, and you can no longer boot into your graphical environment. You suspect the issue is with the init process. How can you edit the GRUB2 boot entry at startup to bypass the default systemd target and instead boot directly into a root shell for emergency repairs?
init=/bin/bash to the end of the linux or linuxefi line.
quiet splash with systemd.unit=rescue.target on the linux line.
systemd.debug-shell=1 to the linux line.
initrd or initramfs line entirely.
54
You want the e1000e network driver to always load with the InterruptThrottleRate parameter set to 3000 for all cards using this driver. You also want to create an alias so that when a request for the generic eth-driver is made, e1000e is loaded. What should the content of a file in /etc/modprobe.d/ be?
alias eth-driver e1000e
alias eth-driver e1000e
alias e1000e eth-driver
alias eth-driver e1000e
55
A script monitor.sh writes status to stdout and errors to stderr. You need to log stdout to status.log, stderr to errors.log, and also send a complete, interleaved copy of both stdout and stderr to combined.log. Which of the following command structures correctly achieves this complex logging setup?
56
You are debugging a driver and need to view kernel log messages in real-time with the highest possible verbosity, including human-readable timestamps, log level prefixes, and kernel facility information. Which command provides this on a modern systemd-journald based system?
57
You run lsmod and see that module nfsd is listed with a "Used by" count greater than 0. You need to identify exactly which other loaded kernel modules are holding a reference to nfsd (i.e., its dependents). Which of the following is the most direct method to find this information?
58
On a system using dracut to build its initramfs, you need to ensure that a proprietary, out-of-tree kernel module (my_driver.ko) and its firmware file (my_firmware.bin) are included in the initramfs so the system can boot from a device requiring this driver. What is the correct procedure?
/etc/dracut.conf.d/my-driver.conf with the lines add_drivers+=" my_driver " and install_items+=" /path/to/my_firmware.bin ", then run dracut -f.
my_driver.ko to /lib/modules/$(uname -r)/extra/ and my_firmware.bin to /lib/firmware/, then run depmod -a and dracut -f.
force_load="my_driver" to /etc/dracut.conf and reboot.
my_driver.ko in /etc/dracut.conf.d/ and my_firmware.bin in /etc/dracut.conf/, then run dracut -f.
59
You are editing a large file in vim. You want to find every line containing "WARNING" and prepend the current timestamp (e.g., "2023-10-27 10:30:00:") to the beginning of each of those lines. Which vim command sequence is the most direct way to accomplish this for all occurrences in the file?
60
You have two directories, dir_A and dir_B. You want to find all files that exist in dir_A but are missing from dir_B, based on filename only. Which of the following commands is the most efficient for this task, especially if the directories are large?