Docsity

LFS307 Linux System Practice Exam, Exams of Technology

Toggle sidebar
bg1
LFS307 Linux System Practice Exam
**Question 1.** Which command is used to change the system runlevel to multi‑user mode
without graphical interface on a system using SysV init?
A) systemctl isolate multi-user.target
B) init 3
C) telinit 5
D) shutdown -r now
Answer: B
Explanation: In SysV init, `init 3` switches to runlevel 3, which is multi‑user text mode. `systemctl
isolate` is used with systemd.
**Question 2.** In systemd, which file should you edit to make a change persistent across
reboots for a service’s environment variables?
A) /etc/systemd/system/<service>.service.d/override.conf
B) /etc/init.d/<service>
C) /etc/default/<service>
D) /var/log/<service>.log
Answer: A
Explanation: Adding an `override.conf` under the `.d` directory allows persistent overrides
without modifying the original unit file.
**Question 3.** What does the `nice` value of -10 indicate for a process?
A) The process has lower priority than normal.
B) The process has higher priority than normal.
C) The process will not be scheduled.
D) The process runs with real‑time scheduling.
Answer: B
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51
pf52
pf53
pf54
pf55
pf56
pf57
pf58
pf59
pf5a

Partial preview of the text

Download LFS307 Linux System Practice Exam and more Exams Technology in PDF only on Docsity!

Question 1. Which command is used to change the system runlevel to multi‑user mode without graphical interface on a system using SysV init? A) systemctl isolate multi-user.target B) init 3 C) telinit 5 D) shutdown - r now Answer: B Explanation: In SysV init, init 3 switches to runlevel 3, which is multi‑user text mode. systemctl isolate is used with systemd. Question 2. In systemd, which file should you edit to make a change persistent across reboots for a service’s environment variables? A) /etc/systemd/system/.service.d/override.conf B) /etc/init.d/ C) /etc/default/ D) /var/log/.log Answer: A Explanation: Adding an override.conf under the .d directory allows persistent overrides without modifying the original unit file. Question 3. What does the nice value of - 10 indicate for a process? A) The process has lower priority than normal. B) The process has higher priority than normal. C) The process will not be scheduled. D) The process runs with real‑time scheduling. Answer: B

Explanation: Negative nice values increase scheduling priority, making the process run before others with higher (more positive) nice values. Question 4. Which of the following commands schedules a one‑time job to run at 02:30 AM tomorrow? A) cron 02:30 tomorrow myscript.sh B) at 02:30 tomorrow < myscript.sh C) schedule - t 02:30 tomorrow myscript.sh D) run-parts --time=02:30 tomorrow myscript.sh Answer: B Explanation: at schedules a single execution at a specified time; the command reads the script from stdin or a file. Question 5. To list all enabled systemd units, which option should be used with systemctl? A) systemctl list-units --all B) systemctl list-unit-files --state=enabled C) systemctl status --enabled D) systemctl show --type=service --enabled Answer: B Explanation: list-unit-files shows unit files and their enablement state; --state=enabled filters to enabled units. Question 6. Which package manager command will permanently add a new APT repository to a Debian‑based system? A) apt-get add-repo "deb http://example.com repo" B) echo "deb http://example.com repo" >> /etc/apt/sources.list.d/example.list C) apt-add-repository "deb http://example.com repo"

B) permissive C) enforcing D) audit Answer: C Explanation: RHEL ships with SELinux set to enforcing mode, where policies are actively applied. Question 10. Which command creates a new LVM logical volume named lv_data of size 10 GiB in volume group vg_main? A) lvcreate - L10G - n lv_data vg_main B) vgcreate - L10G - n lv_data vg_main C) lvm create - size 10G lv_data vg_main D) lvadd - size 10G - name lv_data vg_main Answer: A Explanation: lvcreate with -L specifies size, -n names the LV, and the VG name follows. Question 11. In a typical /etc/fstab entry, which field specifies the mount options? A) The second field B) The third field C) The fourth field D) The fifth field Answer: C Explanation: The order is: device, mount point, filesystem type, options, dump, pass. Options are the fourth field. Question 12. Which command displays the current kernel ring buffer, useful for diagnosing boot problems?

A) dmesg B) journalctl - k C) syslogd - c D) bootlogd Answer: A Explanation: dmesg prints the kernel’s message buffer. journalctl - k also works on systemd, but the classic command is dmesg. Question 13. To change the system hostname permanently on a system using systemd, which file should be edited? A) /etc/hostname B) /etc/hosts C) /etc/sysconfig/network D) /etc/systemd/hostname.conf Answer: A Explanation: /etc/hostname contains the static hostname. Editing it and rebooting (or using hostnamectl) makes the change persistent. Question 14. Which command will display the IPv6 address assigned to the eth0 interface? A) ifconfig eth0 | grep inet B) ip - 6 addr show dev eth C) netstat - i eth D) route - 6 show eth Answer: B Explanation: ip - 6 addr show dev eth0 filters for IPv6 addresses on that device. ifconfig can also work but is deprecated.

Explanation: Packets first hit the PREROUTING chain; if they are destined for the local host, they later go to INPUT. Question 18. Which command synchronizes the system clock with an NTP server named time.example.com? A) ntpdate time.example.com B) chronyc - a makestep time.example.com C) timedatectl set-ntp true D) hwclock --systohc time.example.com Answer: A Explanation: ntpdate contacts the given NTP server and sets the system clock immediately. timedatectl enables the NTP service but does not perform a one‑off sync. Question 19. To mount an NFS export located at server:/share to /mnt/share with read‑only access, which option is required? A) ro B) rw C) nolock D) async Answer: A Explanation: The ro mount option forces a read‑only mount. rw would allow writes. Question 20. Which command creates a new user named alice with a home directory and default shell /bin/bash? A) useradd - m - s /bin/bash alice B) adduser alice --create-home --shell /bin/bash C) newuser - d /home/alice - s /bin/bash alice

D) mkuser - home /home/alice - shell /bin/bash alice Answer: A Explanation: On most Linux distributions, useradd - m - s /bin/bash alice creates the account, home directory, and sets the shell. Question 21. What does the chmod 2755 /opt/app command set on the directory? A) Setuid bit, rwx for owner, rx for group and others B) Setgid bit, rwx for owner, rx for group and others C) Sticky bit, rwx for owner, rx for group and others D) No special bits, rwx for owner, rwx for group, r-x for others Answer: B Explanation: The leading 2 sets the setgid bit, which forces newly created files within the directory to inherit its group. Question 22. Which command displays the Access Control List (ACL) entries for the file /var/log/syslog? A) getfacl /var/log/syslog B) aclget /var/log/syslog C) ls - l /var/log/syslog D) stat - c %A /var/log/syslog Answer: A Explanation: getfacl prints the ACL entries associated with a file or directory. Question 23. To limit the maximum number of processes a user bob may spawn, which file should be edited? A) /etc/security/limits.conf B) /etc/sysctl.conf

B) - R

C) - d recurse D) Both A and B Answer: D Explanation: Both -r and -R cause grep to search recursively; -R also follows symbolic links. Question 27. To view the last 100 lines of the system journal for the ssh.service, which command should be used? A) journalctl - u ssh.service - n 100 B) tail - n 100 /var/log/ssh.log C) systemctl status ssh.service --lines= D) dmesg | grep ssh | tail - 100 Answer: A Explanation: journalctl - u ssh.service - n 100 shows the most recent 100 journal entries for that unit. Question 28. Which command extracts a tar.gz archive while preserving file permissions? A) tar - xzf archive.tar.gz --preserve-permissions B) tar --extract --gzip --same-permissions - f archive.tar.gz C) tar - xzvf archive.tar.gz --same-permissions D) tar - xzf archive.tar.gz --same-permissions Answer: D Explanation: The --same-permissions (or --preserve-permissions) option tells tar to restore original mode bits. The v flag is optional for verbosity.

Question 29. When using rsync to copy /home/ to a remote host backup.example.com preserving all attributes and deleting files that no longer exist on the source, which options are required? A) - a --delete B) - r - p --purge C) - avz --remove-source-files D) - c --delete-excluded Answer: A Explanation: -a (archive) preserves permissions, timestamps, symlinks, etc.; --delete removes extraneous files from the destination. Question 30. Which Git command stages all modified and deleted files for the next commit? A) git add. B) git commit - a C) git add - A D) Both A and C Answer: D Explanation: git add . adds new/modified files in the current directory; git add - A stages modifications and deletions throughout the repository. Both achieve the same effect when run at the repo root. Question 31. Which command shows the top five processes consuming the most CPU in real time? A) top - b - n 1 | head - n 12 B) ps aux --sort=-%cpu | head - n 6 C) htop --sort-key=PERCENT_CPU --limit= D) vmstat 1 5

C) podman run - d --port 8080:80 nginx:latest D) docker launch - p 8080:80 nginx:latest Answer: A Explanation: docker run - d - p host:container image creates and starts the container with port mapping. Question 35. Which libvirt command lists all defined virtual machines on the host? A) virsh list --all B) libvirt-list --all C) virt-manager --list D) qemu-img list-vms Answer: A Explanation: virsh list --all shows both running and defined (but stopped) VMs. Question 36. In a Linux system, which file stores the mapping between device UUIDs and their mount points for automatic mounting? A) /etc/fstab B) /etc/mtab C) /etc/blkid.tab D) /run/udisks2/mounts Answer: A Explanation: /etc/fstab can reference devices by UUID, allowing the system to mount them correctly at boot. Question 37. Which command displays the current kernel version and build information? A) uname - a B) cat /proc/version

C) dmesg | grep Linux D) Both A and B Answer: D Explanation: Both uname - a and cat /proc/version provide the kernel version and build details. Question 38. To enable IP forwarding permanently on a Debian‑based system, which line should be added to /etc/sysctl.conf? A) net.ipv4.ip_forward = 1 B) net.ipv4.forwarding = yes C) ip_forward = true D) sysctl.ip_forward = 1 Answer: A Explanation: The sysctl variable net.ipv4.ip_forward set to 1 enables IPv4 forwarding. Question 39. Which tool can be used to create a compressed, incremental backup of /etc to a file named etc-backup.tar.gz? A) tar - czf etc-backup.tar.gz /etc B) rsync - a /etc etc-backup.tar.gz --incremental C) dd if=/etc of=etc-backup.tar.gz bs=4M status=progress D) cp - a /etc etc-backup.tar.gz && gzip etc-backup.tar.gz Answer: A Explanation: tar - czf creates a gzipped archive of the directory. Incremental features require -- listed-incremental, but the basic compressed backup is achieved with option A. Question 40. Which of the following commands will display the current CPU temperature on a system with the lm-sensors package installed?

Question 43. To display the current mount options for the filesystem mounted on /home, which command is appropriate? A) mount | grep ' on /home ' B) findmnt - no OPTIONS /home C) df - h /home D) lsblk - f /home Answer: B Explanation: findmnt - no OPTIONS /home prints only the options column for that mount point. Question 44. Which command sets the default umask for all users on a system using the login.defs file? A) UMASK 027 in /etc/login.defs B) umask 027 in /etc/profile C) setuid 027 in /etc/bashrc D) chmod 027 in /etc/skel Answer: A Explanation: The UMASK variable in /etc/login.defs defines the default umask applied at login for all users. Question 45. Which of the following commands will display the list of active network interfaces and their IP addresses? A) ip addr show B) ifconfig - a C) netstat - i D) Both A and B Answer: D Explanation: Both ip addr show and the older ifconfig - a list interfaces and assigned IPs.

Question 46. To configure a bonded interface using mode 802.3ad (LACP) on a system with nmcli, which command creates the bond? A) nmcli connection add type bond ifname bond0 mode 802.3ad B) nmcli dev add bond bond0 802.3ad C) nmcli con add type ethernet slave-type bond master bond0 ifname eth D) nmcli conn add type bond bond0 mode 802.3ad slave eth0 eth Answer: A Explanation: nmcli connection add type bond ifname bond0 mode 802.3ad creates the bond interface with the specified mode. Question 47. Which file contains the GRUB bootloader configuration that is regenerated by update-grub? A) /etc/default/grub B) /boot/grub/grub.cfg C) /etc/grub.d/40_custom D) /boot/grub/menu.lst Answer: B Explanation: update-grub generates /boot/grgrub.cfg from scripts and /etc/default/grub. Question 48. In a system using systemd, which command will show the dependency tree for the multi-user.target? A) systemctl list-dependencies multi-user.target B) systemctl show - p Wants multi-user.target C) systemd-analyze plot > graph.svg D) systemctl status multi-user.target --show-deps Answer: A

Answer: A Explanation: ls - Z shows SELinux context labels for files. Question 52. Which option to ssh forces the client to use protocol version 2 only? A) - 1 B) - 2 C) - V 2 D) - p 2 Answer: B Explanation: ssh - 2 tells the client to use SSH protocol version 2. Question 53. When using dd to create a raw image of an entire disk /dev/sda to a file disk.img, which block size is generally recommended for speed? A) bs= B) bs=4M C) bs=1K D) bs=64K Answer: B Explanation: Larger block sizes such as 4M reduce the number of read/write calls, improving throughput. Question 54. Which command can be used to view the contents of a journal entry for the cron.service that occurred on a specific date, e.g., 2023‑ 08 ‑15? A) journalctl - u cron.service --since "2023- 08 - 15" --until "2023- 08 - 16" B) journalctl - u cron.service - b 2023- 08 - 15 C) journalctl - u cron.service - d 20230815 D) journalctl - u cron.service - t 2023- 08 - 15

Answer: A Explanation: --since and --until allow specifying date ranges for journal queries. Question 55. Which file contains the list of authorized public keys for the user root on a typical Linux system? A) /root/.ssh/authorized_keys B) /etc/ssh/ssh_known_hosts C) /root/.ssh/known_hosts D) /etc/ssh/authorized_keys/root Answer: A Explanation: User‑specific authorized keys are stored in ~/.ssh/authorized_keys. Question 56. To enable the firewall service permanently on a system using firewalld, which command should be executed? A) systemctl enable firewalld && systemctl start firewalld B) firewall-cmd --set-default-zone=public C) iptables - P INPUT DROP D) ufw enable Answer: A Explanation: Enabling and starting firewalld via systemctl ensures it runs after each boot. Question 57. Which of the following commands will display the amount of free space available on each mounted filesystem? A) df - h B) du - sh * C) lsblk - f D) free - h