Chapter 8: Unix and Linux Operating Systems (Set-10)
In a Bash pipeline, if you must ensure a command failure inside the pipe is detected, which shell option is commonly enabled
A noclobber option
B noglob option
C pipefail option
D allexport option
Explanation: set -o pipefail makes a pipeline return a failure status if any command in the pipeline fails. Without it, the pipeline status is usually from the last command only, hiding earlier failures.
If you must prevent accidental overwriting of files using “>” redirection in Bash, which shell option helps
A pipefail option
B noclobber option
C emacs option
D monitor option
Explanation: set -o noclobber prevents overwriting existing files with >. It reduces risk in scripts. You can still override intentionally using >| when you really want to replace a file.
In Linux, which file usually stores the list of filesystem types available for mount operations
A /proc/filesystems
B /proc/mounts
C /etc/fstab
D /etc/filesystems
Explanation: /proc/filesystems lists filesystem types supported by the kernel, including built-in and available modules. It helps confirm whether a filesystem driver is available before mounting a device.
When you need to find which process is holding a deleted log file still open, which command is most direct
A lsblk tool
B df tool
C du tool
D lsof tool
Explanation: lsof shows open file handles. It can reveal processes still writing to deleted files, which can keep disk space used until the process is restarted, a common “disk full” mystery.
If a filesystem shows full but files look deleted, which concept most often explains it
A Broken inode table
B Open deleted files
C Wrong umask value
D Bad PATH order
Explanation: Deleted files still consume space if a process keeps them open. The directory entry is removed, but the inode remains until all file handles close, so restarting the process frees space.
Which command can show open files under a specific mount point to help unmount safely
A ls -D
B df +D
C lsof +D
D du +D
Explanation: lsof +D /mountpoint lists open files under that directory tree. It helps identify which programs are using the filesystem, preventing unmount and enabling targeted shutdown of those processes.
In Linux security, which file permission issue often makes SSH refuse a private key
A Key too small
B Key too open
C Key too new
D Key too old
Explanation: SSH enforces strict permissions on private keys. If the key file is readable by group or others, SSH may reject it to prevent exposure. Permissions like 600 are typically required.
In Linux, which command sets a private key file to owner read/write only
A chmod 644
B chmod 700
C chmod 600
D chmod 755
Explanation: chmod 600 keyfile allows only the owner to read and write the private key. This is the standard secure setting for SSH keys to prevent unauthorized access.
Which file in /etc is commonly used to control name service order like files then DNS
A resolv.conf
B hosts.allow
C sudoers file
D nsswitch.conf
Explanation: /etc/nsswitch.conf defines the order for resolving names, users, and services, such as checking /etc/hosts before DNS. It affects how the system performs lookups and authentication sources.
In systemd, which command shows the dependency tree of a unit to understand startup order
A systemctl list-units
B systemctl list-dependencies
C systemctl get-default
D systemctl daemon-reload
Explanation: systemctl list-dependencies unit shows required and wanted units, revealing startup relationships. It helps troubleshoot why a service starts or fails due to dependent units not being available.
Which systemd feature starts services on demand when a socket receives traffic
A socket activation
B cron scheduling
C job control
D runlevel boot
Explanation: Socket activation allows systemd to listen on a socket and start the service only when needed. It reduces resource usage and can improve boot speed by delaying service startup.
Which command shows which systemd unit file is loaded and from which exact path
A systemctl show
B systemctl list
C systemctl cat
D systemctl start
Explanation: systemctl cat unit displays the unit file contents and drop-in overrides. It helps confirm which configuration is actually in effect when troubleshooting unexpected service behavior.
Which systemd command prints all properties of a service, including ExecStart and environment
A systemctl status
B systemctl show
C systemctl enable
D systemctl isolate
Explanation: systemctl show unit prints detailed properties like ExecStart, user, and restart policy. It is useful for scripting and for diagnosing the exact configuration systemd is using internally.
In Linux permissions, which command sets default ACLs on a directory so new files inherit them
A getfacl -d
B chmod -d
C umask -d
D setfacl -d
Explanation: setfacl -d sets default ACL entries on a directory. These defaults are applied to new files and subdirectories created inside, enabling consistent access rules beyond standard group permissions.
Which behavior is true for standard rwx permissions but not always true for ACL-based permissions
A Supports inheritance
B Only three classes
C Uses file hashes
D Needs kernel reboot
Explanation: Traditional Unix permissions provide only owner, group, and others. ACLs can specify permissions for extra users and groups, offering finer control while still supporting the basic permission model.
If an admin wants to see ACL entries for a file to debug access, which command is correct
A getfacl file
B setfacl file
C chmod acl
D chown acl
Explanation: getfacl prints ACL entries for a file or directory. It helps explain why access is allowed or denied even when standard rwx bits seem correct.
Which command shows the effective umask value for the current shell session
A maskshow command
B chmod -u
C umask command
D stat -u
Explanation: Running umask without arguments prints the current mask. This helps predict default permissions for newly created files and directories, which is important for secure user and service setups.
In Linux process management, what does a “zombie” process usually represent
A Sleeping process
B Exited, not reaped
C Running kernel thread
D High CPU loop
Explanation: A zombie process has finished execution but remains in the process table because its parent has not collected its exit status. It consumes little memory but indicates parent process handling issues.
In ps output, which state letter commonly indicates a zombie process
A R state
B S state
C D state
D Z state
Explanation: In many ps outputs, state “Z” marks a zombie process. It signals the process ended but wasn’t reaped. Fix often involves the parent process, not the zombie itself.
Which tool can show real-time process tree and allow killing processes interactively, if installed
A tar tool
B grep tool
C htop tool
D cat tool
Explanation: htop provides an interactive interface to view processes, CPU and memory usage, and a tree view. It allows selecting and sending signals to processes more easily than top.
In Linux networking, which file lists static TCP/UDP service name to port mappings
A /etc/hosts
B /etc/services
C /etc/ports
D /etc/resolv.conf
Explanation: /etc/services maps service names to port numbers, like ssh 22. It supports readability and legacy tools. Actual listening ports are controlled by services, but names help interpretation.
Which command tests a TCP connection to a port in a simple way for troubleshooting
A ping -z
B ssh -z
C nc -z
D ip -z
Explanation: nc -z host port checks whether a TCP port is reachable without sending data. It is useful to test firewall rules and service availability beyond ICMP ping results.
In Bash, which expansion safely returns an empty string when a variable is unset, preventing errors
A ${VAR:++}
B ${VAR:-}
C ${VAR:==}
D ${VAR:??}
Explanation: ${VAR:-} expands to VAR if set and non-empty, otherwise it expands to an empty string. This helps scripts avoid “unbound variable” problems when optional values are missing.
In Bash, which parameter expansion assigns a default value to a variable if it is unset or empty
A ${VAR:=default}
B ${VAR:-default}
C ${VAR:+default}
D ${VAR:?default}
Explanation: ${VAR:=default} assigns default to VAR if VAR is unset or empty, then expands to that value. ${VAR:-default} only substitutes a fallback without changing VAR, so it doesn’t “set” it.
In Bash, which expansion prints an error message and exits if a variable is unset or empty
A ${VAR:-msg}
B ${VAR:+msg}
C ${VAR:?msg}
D ${VAR:=msg}
Explanation: ${VAR:?message} forces required variables to be set. If not, the shell prints the message and exits. It is useful for scripts that must not run with missing parameters.
When extracting fields from /etc/passwd reliably, which delimiter is used between columns
A Space delimiter
B Colon delimiter
C Comma delimiter
D Tab delimiter
Explanation: /etc/passwd uses colon-separated fields. Tools like cut -d ‘:’ or awk can parse it to extract username, UID, home directory, and shell fields accurately.
Which command shows which package owns a given file on RPM-based systems
A rpm -ql
B rpm -qi
C rpm -qa
D rpm -qf
Explanation: rpm -qf /path/file identifies the RPM package that installed that file. This is useful for locating the source of a binary or config file and reinstalling it if damaged.
Which dpkg command shows which installed package owns a specified file path
A dpkg -l
B dpkg -i
C dpkg -S
D dpkg -P
Explanation: dpkg -S /path/file finds the owning package for that file on Debian-based systems. It helps trace unexpected files and determine which package to reinstall or remove.
When a command must run weekly but the machine may be off at the scheduled time, which scheduler fits best
A cron service
B anacron service
C at service
D nohup service
Explanation: Anacron runs periodic jobs that were missed while the system was powered off. It is ideal for desktops and laptops, ensuring daily or weekly maintenance tasks still occur.
Which file commonly stores per-user cron jobs in an editor-like managed format
A /etc/cron.daily
B /etc/crontab
C /var/log/cron
D user crontab
Explanation: User-specific cron jobs are stored in a per-user crontab managed by crontab -e. This separates user schedules from system-wide cron configuration and keeps permissions controlled.
Which command edits the current user’s crontab safely through a standard interface
A crontab -e
B cron -e
C editcron -e
D at -e
Explanation: crontab -e opens the user’s cron schedule in an editor and installs it safely. It avoids direct file editing mistakes and ensures the cron daemon reads the updated schedule.
Which command lists the current user’s scheduled cron entries
A cron -l
B at -l
C crontab -l
D jobs -l
Explanation: crontab -l shows the user’s current cron jobs. It helps verify whether schedules were saved correctly and is useful during auditing and troubleshooting of automated tasks.
In Linux boot troubleshooting, which target provides a minimal environment with basic services and a root shell
A graphical.target
B rescue.target
C multi-user.target
D reboot.target
Explanation: rescue.target starts a basic system with essential services and a root shell. It is useful for fixing configuration errors, repairing filesystems, or recovering from broken service settings.
Which systemd target provides the most minimal emergency shell with very few services
A rescue.target
B multi-user.target
C poweroff.target
D emergency.target
Explanation: emergency.target launches an extremely minimal environment for serious recovery, often without networking. It is used when normal and rescue boot modes are not enough to fix deep system problems.
In Linux filesystems, which command checks and repairs filesystem errors, usually on unmounted partitions
A mount tool
B fsck tool
C tar tool
D du tool
Explanation: fsck checks filesystem consistency and can repair errors. It is typically run on unmounted partitions to avoid corruption and is often used after crashes or unclean shutdowns.
Which command displays filesystem UUID and type, helping build stable /etc/fstab entries
A lsmod command
B lsof command
C blkid command
D pstree command
Explanation: blkid shows UUIDs, filesystem types, and labels for partitions. Using UUIDs in /etc/fstab keeps mounts consistent even if device names like /dev/sdb change after reboot.
Which file shows currently mounted filesystems and options in real time
A /proc/mounts
B /etc/fstab
C /etc/mounts
D /var/mounts
Explanation: /proc/mounts reflects current mounts as seen by the kernel. It is useful for confirming what is mounted now, while /etc/fstab is the static configuration used at boot.
Which command shows block devices and mount points in a tree view
A ps command
B lsblk command
C lsof command
D grep command
Explanation: lsblk lists disks and partitions with mount points, making it easy to identify which device corresponds to which filesystem. It is helpful when mounting, partitioning, or troubleshooting storage.
In Linux, which directory is designed for variable runtime files like PID files and sockets on modern systems
A /var directory
B /tmp directory
C /usr directory
D /run directory
Explanation: /run stores runtime data such as PID files and sockets and is usually a tmpfs cleared at boot. It provides a standard place for early-boot runtime state.
Which directory historically stored PID files and was often used before /run became standard
A /etc/run directory
B /usr/run directory
C /var/run directory
D /tmp/run directory
Explanation: /var/run historically held runtime PID files and sockets. Many modern systems now link /var/run to /run, but the older path is still commonly seen in configs.
In Linux user management, which command creates a new user account on many systems
A usermod command
B useradd command
C userdel command
D passwd command
Explanation: useradd creates a user account and can set home directory and default shell. Some distros prefer higher-level tools like adduser, but useradd remains a core standard command.
Which command modifies an existing user account, such as changing shell or adding groups
A useradd command
B userdel command
C chmod command
D usermod command
Explanation: usermod edits user properties like shell, home directory, and group membership. It is used for managing access after account creation without deleting or recreating user data.
Which command removes a user account from the system, optionally deleting home directory
A useradd command
B usermod command
C userdel command
D chown command
Explanation: userdel deletes a user account. With appropriate options it can remove the home directory and mail spool. Admins use it when deprovisioning users who no longer need access.
Which command adds a user to an additional supplementary group on many Linux systems
A usermod -aG
B useradd -g
C chgrp -aG
D chmod -aG
Explanation: usermod -aG group user appends the user to a group without removing existing groups. This is important; missing -a can overwrite group memberships and break access.
In Linux, which file stores group definitions and group member lists
A /etc/passwd file
B /etc/group file
C /etc/shadow file
D /etc/hosts file
Explanation: /etc/group defines groups and lists members. Group membership controls access to files and system resources through group permissions, supporting shared access for teams and services.
Which file stores secure password hashes and aging info, readable only by root
A /etc/passwd file
B /etc/group file
C /etc/profile file
D /etc/shadow file
Explanation: /etc/shadow stores password hashes and password aging details. It is restricted for security, preventing normal users from reading hashes that could be attacked offline.
In Linux, which command shows detailed password aging information for a user
A passwd -l
B usermod -l
C chage -l
D groups -l
Explanation: chage -l user lists password expiry settings like last change date, maximum days, and warning period. It helps verify whether an account will expire or require password updates.
Which file often sets default password aging policy for new accounts created by tools
A /etc/shadow
B /etc/login.defs
C /etc/passwd
D /etc/securetty
Explanation: /etc/login.defs contains default settings for user account tools, including password aging defaults. It helps enforce consistent security policies for new users without manual configuration each time.
Which Linux security concept restricts services by limiting what system calls they can make
A seccomp filtering
B cron scheduling
C PATH ordering
D file rotation
Explanation: seccomp limits system calls a process can use, reducing attack surface. It is often used with containers and hardened services. If a service is compromised, restricted syscalls can limit damage.
Which principle best explains why admins use sudo instead of staying logged in as root
A Fast boot time
B Least privilege
C Better compression
D Lower disk usage
Explanation: Least privilege means using only the minimum permissions needed. sudo allows temporary elevation for specific tasks, reducing risk from mistakes or malware compared to operating continuously as root.