Chapter 8: Unix and Linux Operating Systems (Set-3)
In a Linux long listing, which command option commonly shows permissions, owner, group, and size together
A ls -a option
B ls -R option
C ls -d option
D ls -l option
ls -l displays detailed file information like permissions, link count, owner, group, size, and modification time. It’s the standard way to inspect access rights and file details quickly.
When checking hidden files in Linux, which ls option is commonly used
A ls -l option
B ls -t option
C ls -a option
D ls -S option
ls -a includes hidden files that start with a dot, such as .bashrc. Hidden files often store configuration settings, so viewing them helps when troubleshooting user environment issues.
Which command creates parent directories automatically if they do not exist
A mkdir -p
B mkdir -r
C mkdir -x
D mkdir -u
mkdir -p creates the full directory path, building missing parent folders as needed. It also avoids errors when directories already exist, making it useful in scripts and setup tasks.
Which command shows command history stored for the current shell session
A recent command
B history command
C listcmd command
D recall command
history displays previously executed commands. It helps repeat long commands, audit what was done, and search past commands. Many shells save history across sessions in a file.
In Bash, which key shortcut commonly searches backward through command history interactively
A Ctrl+C
B Ctrl+Z
C Ctrl+R
D Ctrl+D
Ctrl+R starts reverse incremental search in many shells. As you type, it finds matching past commands, letting you quickly reuse complex commands without retyping everything.
Which command displays a file’s content with line numbers, helpful for scripts and logs
A nl command
B cat command
C pwd command
D who command
nl prints file lines with numbering, making it easier to reference specific lines during debugging or when explaining changes. It’s especially helpful for scripts and configuration files.
Which command counts lines, words, and bytes in a file by default
A du command
B df command
C wc command
D ps command
wc reports line count, word count, and byte count. It’s useful for quickly measuring file size in text terms, like checking log growth or validating output records.
Which command sorts lines of text output alphabetically by default
A sort command
B uniq command
C cut command
D paste command
sort orders lines, typically in ascending order. It is often combined with pipes to process command output and prepare data for grouping, comparison, or removing duplicates.
Which command removes repeated adjacent lines, often used after sorting
A sort command
B uniq command
C tee command
D head command
uniq filters out repeated neighboring lines. Because it only removes consecutive duplicates, it is commonly paired with sort first, then uniq to get unique entries reliably.
Which command prints specific columns from each line using delimiters
A grep command
B tar command
C cut command
D ping command
cut extracts fields or character ranges from each line, such as selecting a username column from a file. It’s widely used in scripting for quick text processing.
Which command redirects output to both screen and a file at the same time
A tee command
B cat command
C mv command
D chmod command
tee reads standard input and writes it to standard output and a file. It is useful when you want to save results while still seeing them in the terminal.
Which command checks a file’s type based on its content, not just extension
A type command
B which command
C whereis command
D file command
file examines a file’s data and reports its type, like text, image, or executable. This helps when extensions are missing or incorrect and you need reliable identification.
Which command compares two text files line-by-line and shows differences
A cmp command
B comm command
C diff command
D join command
diff shows changes between files, which is essential for configuration comparisons and troubleshooting. It highlights added, removed, or modified lines, and is commonly used in patch creation.
Which command shows changes in a file with a simple numeric byte comparison
A diff command
B cmp command
C grep command
D less command
cmp compares two files byte-by-byte and reports the first difference location. It’s useful when checking if two files are identical, including binary files where line comparison is not ideal.
Which command changes the current shell environment variable for the session
A export command
B chmod command
C chown command
D passwd command
export marks a variable so it is passed to child processes. This is how you set environment variables like PATH for programs started from the current shell session.
In Linux, which variable is commonly used to locate the current shell program path
A HOME variable
B USER variable
C SHELL variable
D LANG variable
SHELL typically contains the path to the user’s login shell, such as /bin/bash. It helps confirm which shell environment is in use for scripts and interactive behavior.
Which command displays running processes in a hierarchical parent-child tree view
A pstree command
B ps command
C top command
D kill command
pstree shows processes as a tree, making it easier to understand parent-child relationships. This helps when tracking which service started a process or diagnosing process groups.
Which command shows process IDs for a given process name, useful before killing
A ps -l command
B grep -p
C pgrep command
D pkill -l
pgrep finds process IDs matching a name or pattern. It reduces manual searching and can be combined with other tools. It is often used before sending signals to processes.
Which command sends a signal to processes by name instead of PID
A kill command
B pkill command
C stop command
D halt command
pkill targets processes using their names or patterns and sends signals like terminate. It is convenient but must be used carefully to avoid stopping the wrong process.
Which signal name is commonly used for a graceful termination request
A SIGKILL signal
B SIGSTOP signal
C SIGCONT signal
D SIGTERM signal
SIGTERM asks a process to stop cleanly, allowing it to close files and save data. It is the default signal used by kill and is safer than forced termination.
Which signal immediately stops a process without allowing cleanup
A SIGTERM signal
B SIGCONT signal
C SIGKILL signal
D SIGHUP signal
SIGKILL forces a process to end immediately. The process cannot catch or ignore it, so it may cause unsaved data loss. It is used when a process is frozen or unresponsive.
Which command shows system uptime and load average in a quick summary line
A uptime command
B uname command
C usermod command
D passwd command
uptime reports how long the system has been running and shows load averages. Load averages indicate how busy the system is over time, helping detect CPU or scheduling pressure.
Which file contains static filesystem mount definitions used during boot
A /etc/hosts
B /etc/fstab
C /etc/group
D /etc/shadow
/etc/fstab lists filesystems and mount options for automatic mounting at boot. It helps mount disks and partitions consistently. Incorrect entries can cause boot issues or missing mounts.
Which command mounts a filesystem to a directory mount point
A mount command
B umount command
C chmod command
D chgrp command
mount attaches a filesystem to a directory so its files become accessible. For example, mounting a USB drive makes its contents appear under a chosen folder like /mnt/usb.
Which command safely detaches an attached filesystem from its mount point
A mount command
B unlink command
C umount command
D eject command
umount detaches a mounted filesystem. It helps prevent data corruption by ensuring pending writes are completed. Always unmount removable storage before unplugging it.
Which permission action is performed by the chgrp command in Linux
A Change owner
B Change password
C Change directory
D Change group
chgrp changes the group ownership of a file or directory. Group ownership is important for shared access where multiple users in the same group need consistent read or write permissions.
Which numeric permission value represents rw-r–r– on a regular file
A 644 value
B 755 value
C 600 value
D 777 value
644 means owner can read and write (6), while group and others can read only (4 and 4). This is a common default for readable documents and configuration files.
Which numeric permission value represents rwx—— on a file or directory
A 755 value
B 644 value
C 700 value
D 666 value
700 gives full permissions to the owner and no permissions to group or others. It is often used for private directories or sensitive scripts to reduce unauthorized access.
Which permission string indicates a directory in Linux long listing output
A Starts with –
B Starts with d
C Starts with l
D Starts with c
In ls -l output, the first character indicates file type. A leading d shows a directory. Regular files show -, and symbolic links show l.
Which file type indicator commonly represents a symbolic link in ls -l
A Starts with d
B Starts with b
C Starts with l
D Starts with p
A leading l in ls -l indicates a symbolic link. The listing often shows the link target using an arrow, helping identify shortcuts to files or directories.
Which command creates a symbolic link to another file or directory
A ln -s
B ln -h
C link -s
D mklink -s
ln -s creates a symbolic link pointing to a target path. Unlike hard links, symlinks can cross filesystems and can link to directories, making them very flexible.
Which command shows a file’s inode number, useful in link troubleshooting
A ls -h
B ls -i
C ls -p
D ls -u
ls -i displays inode numbers. Inodes help identify files uniquely on a filesystem. Hard links share the same inode, so inode checks help confirm link relationships.
In Linux, which log file commonly records authentication events on Debian/Ubuntu
A /var/log/boot.log
B /var/log/kern.log
C /var/log/auth.log
D /var/log/cron.log
On Debian/Ubuntu systems, authentication events like sudo usage and login attempts are recorded in /var/log/auth.log. Reviewing it helps detect failed logins and verify administrative actions.
On many Red Hat–based systems, which log file often records authentication and security events
A /var/log/auth.log
B /var/log/messages
C /var/log/syslog
D /var/log/secure
Many Red Hat family systems log authentication-related messages in /var/log/secure. This includes SSH logins, sudo actions, and other security events, aiding in audits and troubleshooting.
Which command on systemd systems views logs collected by the system journal
A journalctl command
B logcat command
C viewlog command
D syslogctl command
journalctl displays logs stored by systemd’s journaling system. It can filter by service, time, or priority, making it very useful for diagnosing boot issues and service failures.
In systemd, which target is commonly used for a standard multi-user text mode
A graphical.target
B rescue.target
C multi-user.target
D shutdown.target
multi-user.target represents a non-graphical multi-user environment with network services. It is similar to traditional runlevel 3 and is used for servers or text-only operation.
In systemd, which target is commonly used for a full graphical desktop environment
A graphical.target
B multi-user.target
C emergency.target
D reboot.target
graphical.target includes the multi-user environment plus a display manager and GUI. It is typically the default on desktop Linux installations where a graphical login screen is required.
Which Linux command sets permissions using symbolic form like u+rwx,g+rx
A chown command
B chgrp command
C passwd command
D chmod command
chmod supports symbolic permission changes such as adding execute for the user or removing write for others. This method is readable and reduces mistakes compared to numeric permissions.
Which command changes both owner and group when written as user:group
A chmod user:group
B chown user:group
C chgrp user:group
D useradd user:group
Using chown user:group file sets both the owner and group at once. This is common during deployment, where application files must be owned by a service account and group.
Which command compresses files into a .zip archive commonly used across platforms
A zip command
B gzip command
C tar command
D cat command
zip creates compressed archives compatible with many operating systems. It is convenient when sharing files with Windows users. For Linux-native backups, tar with gzip is also common.
Which command compresses a single file using gzip compression
A zip command
B tar command
C gzip command
D grep command
gzip compresses files using the gzip format, usually producing .gz output. It is fast and common for logs and backups, often paired with tar for multi-file compression.
Which command checks free memory and used memory in a human-readable format
A free -h
B df -h
C du -h
D ps -h
free -h shows memory and swap usage in readable units. It helps understand RAM availability and whether swap is being heavily used, which can indicate memory pressure.
Which command tests file permissions by attempting to access a file as the current user
A chmod command
B test command
C cat command
D uname command
test is used in shell scripts to check conditions like file existence, type, and permissions. It helps scripts make decisions, such as ensuring a file is readable before processing.
Which command sets a process priority when starting it from the terminal
A renice command
B top command
C nice command
D ps command
nice starts a process with a chosen scheduling priority. Higher nice values usually mean lower priority. It helps run heavy tasks without slowing down important interactive work.
Which command changes the priority of an already running process
A renice command
B nice command
C kill command
D uptime command
renice modifies the scheduling priority of a running process by PID. Administrators use it to reduce resource impact of background jobs or increase priority for critical tasks.
Which command checks exit status code of the last command in Bash
A echo $!
B echo $$
C echo $0
D echo $?
$? stores the exit status of the most recent command. A value of 0 usually indicates success, while non-zero indicates an error, helping scripts detect failures reliably.
Which command runs a program in background by adding a symbol at the end
A | symbol
B & symbol
C > symbol
D * symbol
Adding & runs a command in the background, returning control to the terminal. This is useful for long-running tasks, but you should still monitor output and process status.
Which command brings a stopped or background job to the foreground in many shells
A fg command
B bg command
C jobs command
D top command
fg moves a job to the foreground so it can interact with the terminal again. It works with job control features and is helpful after running programs in background accidentally.
Which command lists jobs started from the current shell session
A ps command
B who command
C jobs command
D last command
jobs shows background or stopped tasks associated with the current shell. It is useful with fg and bg to manage job control without searching system-wide processes.
Which command is used to stop a running foreground process without closing the terminal
A Ctrl+R
B Ctrl+D
C Ctrl+S
D Ctrl+C
Ctrl+C sends an interrupt signal to the foreground process, usually stopping it safely. It is the standard way to cancel a running command that is taking too long or behaving wrongly.