Chapter 8: Unix and Linux Operating Systems (Set-5)
When a script must discard both normal output and error output safely, which special device file is most appropriate
A /dev/zero device
B /proc/null file
C /dev/null device
D /tmp/null file
/dev/null acts like a black hole for data. Anything written to it is discarded. It is commonly used with redirection to suppress output and keep scripts clean.
In Linux I/O, which file descriptor number represents standard input in most shells
A fd 1
B fd 2
C fd 3
D fd 0
File descriptor 0 is standard input, usually the keyboard or redirected input. Understanding descriptors helps in scripting with redirection and controlling where programs read their data.
Which file descriptor is standard output for most Linux command-line programs
A fd 1
B fd 0
C fd 2
D fd 9
File descriptor 1 is standard output, normally printed to the terminal. It can be redirected to files or piped to other commands for processing.
Which file descriptor is standard error, used for error messages by programs
A fd 1
B fd 2
C fd 0
D fd 4
File descriptor 2 is standard error. Errors remain visible even when output is piped unless you redirect fd 2, which is important when collecting clean command output.
In Bash redirection, which syntax sends standard output into a file without overwriting it
A > overwrite
B < input
C | pipe
D >> append
>> appends output to the end of a file. It keeps previous content and adds new lines, making it useful for building logs or accumulating results over time.
If you need to redirect standard error into the same place as standard output, which common Bash syntax is used
A 2>&1 merge
B 1>&2 swap
C 0>&1 merge
D 2>&0 merge
2>&1 makes standard error follow standard output. It is often used in scripts so both normal messages and errors go into one log file for easier debugging.
In Linux, which command safely edits the sudo rules file with syntax checking
A sudoedit command
B nano sudoers
C chmod sudoers
D visudo command
visudo edits the sudoers configuration safely and checks syntax before saving. This prevents broken sudo rules that could lock administrators out of root access.
Which file is the main configuration file that controls sudo permissions on many systems
A /etc/shadow file
B /etc/passwd file
C /etc/sudoers file
D /etc/profile file
/etc/sudoers defines which users and groups can run commands with sudo and under what conditions. It should be edited with visudo to avoid syntax mistakes.
When an admin needs to switch to a root shell and load root’s environment, which command is most typical
A sudo -i
B sudo -u
C su -m
D su -p
sudo -i starts a login shell as root, loading root’s environment and working directory settings. It is useful for full administrative sessions without direct root login.
In Unix-like systems, what is the main difference between a hard link and a symbolic link
A Faster vs slower
B Root-only vs user
C Network-only vs local
D Inode vs pathname
A hard link points to the same inode as the original file, while a symbolic link stores a path to the target. Symlinks can break if the target path changes.
Which command shows the target path that a symbolic link points to
A linkshow command
B readlink command
C lslink command
D filelink command
readlink prints the path stored inside a symbolic link. It helps confirm where a symlink points, especially when troubleshooting broken links in system directories.
Which tool is most suitable to copy files while preserving permissions, timestamps, and optionally syncing changes efficiently
A rsync utility
B cp utility
C mv utility
D cat utility
rsync can copy and synchronize files efficiently by transferring only differences. It can preserve permissions and times, making it excellent for backups and remote transfers.
When checking which files a process currently has open, which command is commonly used
A ps command
B df command
C free command
D lsof command
lsof lists open files and the processes using them. It helps diagnose “device busy” errors, find which program holds a log file, or track network sockets.
If a filesystem cannot be unmounted because it is busy, which command helps identify processes using that mount
A uname command
B whoami command
C fuser command
D cal command
fuser shows which processes are using a file, directory, or mount point. This helps find and stop the processes so the filesystem can be unmounted safely.
Which directory is commonly used for locally installed system-wide software not managed by the distro packages
A /usr/local directory
B /usr/bin directory
C /var/local directory
D /etc/local directory
/usr/local is intended for locally installed software and scripts. It keeps custom tools separate from distribution-managed files, reducing conflicts during system upgrades.
In Linux, which file stores static host-to-IP mappings used before DNS lookup in many cases
A /etc/resolv file
B /etc/hosts file
C /var/hosts file
D /proc/hosts file
/etc/hosts maps hostnames to IP addresses locally. It is useful for testing, local services, and troubleshooting DNS issues because it can override name resolution for specific entries.
Which file usually lists DNS resolver servers for hostname resolution on many Linux systems
A /etc/hosts.conf
B /etc/dns.conf
C /var/resolv.conf
D /etc/resolv.conf
/etc/resolv.conf commonly contains DNS server addresses and search domains. Many systems generate it automatically, so manual edits may be overwritten unless managed properly.
In SSH server configuration, which file typically controls SSH daemon settings like port and authentication
A sshd_config file
B ssh_config file
C known_hosts file
D authorized_keys file
sshd_config controls the SSH server behavior, such as allowed authentication methods and security options. Correct configuration helps secure remote access and reduce attack surface.
Which path commonly contains the OpenSSH server configuration file on Linux
A /etc/sshd/ssh_config
B /usr/ssh/sshd_config
C /var/ssh/sshd_config
D /etc/ssh/sshd_config
On most Linux systems, the SSH server configuration file is located at /etc/ssh/sshd_config. Editing it affects how the SSH daemon accepts connections and authenticates users.
Which command copies files securely over SSH using a simple source-to-destination syntax
A ftp command
B scp command
C telnet command
D rlogin command
scp transfers files securely using SSH encryption. It works like a secure copy tool for local-to-remote or remote-to-local transfers, protecting data and credentials over networks.
When you want to view kernel messages stored in the ring buffer, which command is standard
A dmesg command
B journalctl command
C last command
D history command
dmesg prints kernel messages, such as hardware detection and driver warnings. It is useful for diagnosing boot problems, device errors, and system-level events.
If you want to view logs only for one systemd service unit, which journalctl option is commonly used
A journalctl -k
B journalctl -b
C journalctl -f
D journalctl -u
journalctl -u service filters the journal for one unit. This helps troubleshoot a specific service without searching through all system logs.
On a systemd machine, which command lists currently loaded units, including services and sockets
A systemctl get-default
B systemctl daemon-reload
C systemctl list-units
D systemctl isolate
systemctl list-units shows active units and their states. It helps quickly see running services, failed units, and other loaded components managed by systemd.
In Linux authentication architecture, which module framework commonly handles login policies and authentication rules
A PAM framework
B GUI framework
C RPM framework
D TCP framework
PAM (Pluggable Authentication Modules) provides a flexible way to manage authentication policies. It controls login behavior for services like SSH, sudo, and local logins using configurable modules.
Which directory typically contains per-service PAM configuration files on many Linux distributions
A /etc/pam.conf
B /usr/pam.d
C /var/pam.d
D /etc/pam.d
/etc/pam.d holds PAM rules for individual services. Editing these files changes authentication behavior, such as password rules and account restrictions, so changes must be done carefully.
When enforcing password aging policies, which command commonly displays and changes user password expiry information
A passwd command
B chage command
C usermod command
D groups command
chage manages password expiry settings like maximum days, minimum days, and warning period. It supports security policies by forcing regular password changes and disabling accounts after expiry.
Which file often contains default password policy settings like minimum days and maximum days
A /etc/shadow
B /etc/passwd
C /etc/login.defs
D /etc/group
/etc/login.defs contains default settings used by user account tools, including password aging defaults. It helps enforce consistent security rules when new accounts are created.
In Linux permissions, which command displays ACLs when files use more detailed access control than rwx
A setfacl command
B chmod command
C chown command
D getfacl command
getfacl shows Access Control Lists, which allow more specific permissions than standard owner-group-other. ACLs are useful when multiple users need different access without changing ownership.
Which command sets or modifies ACL permissions for a user on a file
A setfacl command
B getfacl command
C chgrp command
D umask command
setfacl adds or changes ACL entries, such as granting a specific user read access. This is helpful for shared resources when group permissions alone are not enough.
In Linux, what is the main purpose of the file /etc/fstab during system startup
A User password rules
B Kernel version record
C Auto mount rules
D Process startup list
/etc/fstab defines which filesystems should mount at boot and with which options. Correct entries ensure disks, partitions, and network shares are attached consistently after reboot.
For safe automation, which systemd setting enables a unit to start at boot time
A restart action
B reload action
C status action
D enable action
Enabling a unit configures it to start automatically during boot. This is separate from starting it now, allowing admins to control both current state and future boot behavior.
If a service should never start, even by dependency, which systemctl action is used to block it strongly
A mask action
B stop action
C disable action
D reload action
Masking a service prevents it from being started manually or as a dependency. It is stronger than disable, and is used when you must ensure a service cannot run.
When a program should continue running after you close the terminal session, which command is commonly used
A fg command
B nohup command
C jobs command
D kill command
nohup runs a command immune to hangup signals, so it continues after logout. Output can be redirected to a file, making it useful for long tasks on remote servers.
In Linux, which directory contains system-wide cron schedules for hourly, daily, and weekly jobs
A /var/cron.*
B /home/cron.*
C /usr/cron.*
D /etc/cron.*
Many systems use directories like /etc/cron.daily and /etc/cron.weekly for scheduled scripts. This simplifies recurring maintenance tasks without editing a single large crontab file.
Which file commonly stores the system-wide crontab schedule format for cron daemon
A /etc/crontab file
B /var/crontab file
C /proc/crontab file
D /home/crontab file
/etc/crontab can schedule system-wide jobs and includes a user field to run commands as specific accounts. It is managed separately from individual user crontabs.
When analyzing a process’s environment variables via /proc, which file is relevant
A /proc/PID/cmdline
B /proc/PID/status
C /proc/PID/environ
D /proc/PID/uptime
/proc/PID/environ contains the environment variables of a process. It helps troubleshoot PATH issues, proxy settings, or configuration variables used by services and scripts.
In Linux, which directory commonly holds virtual terminal device files like tty0 and tty1
A /proc directory
B /etc directory
C /usr directory
D /dev directory
/dev contains device files representing hardware and virtual devices. Terminals, disks, and pseudo-devices appear here, allowing programs to communicate with them using file operations.
If you need to check which binary will run when you type a command name, which tool is most direct
A whereis tool
B command -v
C locate tool
D file tool
command -v name reports the command resolution in the current shell, showing if it is a built-in or external path. It is reliable for scripts and debugging command conflicts.
In shell scripting, which quoting style prevents variable expansion and treats most characters literally
A Single quotes
B Double quotes
C Backticks only
D No quotes
Single quotes preserve the exact text, stopping variable expansion and backslash interpretation. This is important when writing literal strings, regex patterns, or commands that contain special characters.
Which feature allows a command to receive interactive input from a file instead of the keyboard
A > output redirection
B | pipe operator
C & background run
D < input redirection
< redirects a file into standard input, letting a command read from a file as if typed. This supports automation and repeatable processing without manual entry.
In Linux, which command displays the manual page section number and description for a command keyword
A man command
B info command
C apropos command
D help command
apropos searches manual page names and descriptions for a keyword. It is useful when you don’t remember the exact command name but know what you want to do.
When a command’s output must be limited to the first N lines without opening a pager, which tool is best
A less command
B tail command
C nl command
D head command
head prints the first part of output quickly. It is useful in pipelines to preview data, check formats, and avoid flooding the terminal with huge outputs.
When reading a growing log file continuously in real time, which option is typically used with tail
A tail -n
B tail -f
C tail -r
D tail -p
tail -f follows a file and prints new lines as they are added. It helps monitor services live during troubleshooting, especially when checking logs while restarting services.
In Linux security best practices, why is direct root SSH login often disabled
A Reduce attack risk
B Increase startup speed
C Improve disk usage
D Fix DNS errors
Disabling root SSH login reduces brute-force risk because attackers cannot target the root account directly. Admins typically log in as a normal user and then use sudo for controlled privilege escalation.
In Linux, which command tests connectivity and latency but does not prove a TCP service port is open
A ssh command
B nc command
C ss command
D ping command
Ping tests ICMP reachability and round-trip time, but it does not confirm application ports like 22 or 80 are open. Firewalls may allow ping but block service ports.
Which concept best describes how Linux organizes filesystems under one single hierarchy
A Multiple drive letters
B Separate desktop disks
C Single directory tree
D Device-only storage
Linux uses one root “/” and mounts all filesystems into this tree. Disks, partitions, and removable drives appear as directories, unlike drive-letter systems.
In Linux, which directory is most appropriate for machine-specific host configuration and service settings, not user data
A /etc directory
B /home directory
C /tmp directory
D /usr directory
/etc stores configuration files for the system and services. It is where admins modify settings for networking, authentication, and application services, keeping configuration separate from binaries and user data.
Which command verifies whether a package is installed on Debian-based systems using the low-level package database
A apt -x
B yum -q
C rpm -q
D dpkg -l
dpkg -l lists packages known to the dpkg database and shows their status. It helps verify installation even when higher-level tools are unavailable or when debugging package problems.
On RPM-based systems, which command checks whether a specific package is installed using RPM database
A dpkg -q
B rpm -q
C apt -q
D tar -q
rpm -q package queries the RPM database and reports whether the package is installed and its version. It is a core command for auditing software on RPM-based systems.
In advanced permission scenarios, why can ACLs be useful compared to only owner-group-other permissions
A Faster file copying
B Smaller archive size
C Better GUI performance
D Per-user access control
ACLs allow assigning permissions to specific users or additional groups beyond the basic three classes. This helps manage shared resources precisely without changing ownership or creating many separate groups.