LPI 101-500 LPIC-1 Exam 101 Exam Dumps and Practice Test Questions Set2 Q21-40

Visit here for our full LPI 101-500 exam dumps and practice test questions.

Question 21:

Which command displays information about all block devices on your Linux system, including partitions?

A) df -h
B) lsblk
C) fdisk -l
D) Both B and C

Answer: D) Both B and C

Explanation:

lsblk lists all block devices in a tree-like format, showing size, type, and mount points. Fdisk -l lists partitions and their sizes, types, and other attributes. Df -h shows only mounted filesystems, not all block devices. Combining lsblk and fdisk -l gives complete device information.

In Linux, understanding storage devices and partitions is essential for system administration, disk management, and troubleshooting. The lsblk command is a powerful tool that lists all block devices in a tree-like format. It shows key details such as device name, size, type (disk, partition, or LVM), and mount points. This provides a clear visual representation of how storage devices and partitions are organized, making it easy to understand relationships between disks, partitions, and mounted filesystems.

The fdisk -l command lists all partitions on available disks along with their sizes, types, and attributes. It is particularly useful when adding new disks, creating or modifying partitions, or verifying partition layouts. Unlike lsblk, which emphasizes a tree structure and current mount points, fdisk -l provides detailed low-level information about partition tables, sectors, and filesystem types, helping administrators work with disk structures at a more technical level.

On the other hand, df -h shows disk usage for mounted filesystems in a human-readable format (e.g., GB or MB), including total size, used space, and available space. It does not display unmounted devices or the full block device hierarchy. Therefore, combining lsblk and fdisk -l gives a complete view of all block devices, their partitions, and structural details, while df -h complements them by showing actual filesystem usage. This combination is crucial for effective storage management.

Question 22:

You want to view the last 50 lines of a system log file /var/log/syslog in real-time as new entries are added. Which command will accomplish this?

A) tail -50 /var/log/syslog
B) tail -f /var/log/syslog
C) tail -n 50 -f /var/log/syslog
D) less +F /var/log/syslog

Answer: C) tail -n 50 -f /var/log/syslog

Explanation:

Tail -n 50 -f shows the last 50 lines and follows new additions to the file in real-time. Tail -50 only shows the last 50 lines once and exits. Tail -f follows the file but defaults to the last 10 lines. Less +F also follows the file interactively but requires navigation commands.

In Linux, monitoring log files in real-time or viewing their end content is a common administrative task. The tail command is widely used for this purpose. For example, tail -n 50 -f /var/log/syslog displays the last 50 lines of a file and continues to follow new additions in real-time, updating the output as new lines are appended. This is particularly useful for monitoring log files such as system logs, web server logs, or application logs as events occur.

The command tail -50 /var/log/syslog shows only the last 50 lines once and then exits, providing a snapshot of recent activity without ongoing monitoring. Similarly, tail -f/var/log/syslog follows the file for new entries but, by default, displays only the last 10 lines initially.

The less command, with the +F option, also allows interactive real-time following of files, similar to tail -f. Unlike tail, less +F provides the ability to scroll backward, search, and navigate within the file while still following new content. To exit follow mode in less, the user presses Ctrl-C, and normal navigation resumes.

Together, these commands provide flexible ways to view and monitor file content, either as a static snapshot or a continuously updated stream, making them essential tools for system administrators who need to troubleshoot or track system activity efficiently.

Question 23:

Which command can be used to change the default runlevel on a System V init system?

A) systemctl set-default runlevel
B) init 3
C) telinit 3
D) vi /etc/inittab

Answer: D) vi /etc/inittab

Explanation:

On System V init systems, the default runlevel is set in /etc/inittab. Editing this file allows you to define which runlevel the system starts at. Init and telinit can change the current runlevel temporarily, but do not alter the default. systemctl is for systemd, not SysV init.

In Linux systems using the System V (SysV) init system, the concept of runlevels defines the state of the system at boot, such as single-user mode, multi-user mode, or graphical mode. The default runlevel determines which set of services and processes the system starts automatically when it boots. This default is defined in the /etc/inittab file. By editing /etc/inittab, an administrator can specify the desired default runlevel using the id: entry, for example, id:3:initdefault: for multi-user text mode or id:5:initdefault: for graphical mode. This ensures that the system always boots into the preferred operating state.

To temporarily change the current runlevel without modifying the default, the init or telinit commands can be used. For example, telinit 1 switches to single-user mode immediately. These commands affect the current session only and do not persist after a reboot.

It is important to note that systemctl is a command used in systemd-based systems, which have replaced SysV init on most modern distributions. While systemctl can manage targets (the systemd equivalent of runlevels), it does not apply to SysV init systems. Understanding /etc/inittab and init is essential for maintaining older Linux servers or distributions still using SysV init.

Question 24:

How can you display all available groups on a Linux system?

A) groups
B) cat /etc/group
C) getent group
D) Both B and C

Answer: D) Both B and C

Explanation:

cCatetc/group directly reads the group file. getent group queries the Name Service Switch and can list groups from both /etc/group and external sources like LDAP. Group shows the groups for the current user, not all system groups.

In Linux, managing and querying group information is essential for access control and permissions. The /etc/group file is the primary local database of groups on the system. Each line in this file represents a group and includes the group name, password placeholder (typically x), group ID (GID), and a comma-separated list of member usernames. Using cat /etc/group simply reads this file directly, showing all groups and their members that are defined locally. It is straightforward but limited to local groups and does not account for groups managed externally.

The getent group command provides a more comprehensive approach by querying the Name Service Switch (NSS). This allows it to list groups not only from /etc/group but also from external sources such as LDAP, NIS, or Active Directory, depending on the system configuration. For example, getent group is especially useful in enterprise environments where group management is centralized and not limited to local files.

The group’s command, on the other hand, displays the groups associated with a specific user, or the current user if none is specified. It does not list all system groups; instead, it shows only membership information, making it useful for checking user permissions rather than auditing all groups.

Together, cat /etc/group, getent group, and groups provide different perspectives on group information: local vs. global, and user-specific vs. system-wide.

Question 25:

You need to allow a user to execute a command with root privileges without entering the root password every time. Which configuration file would you edit?

A) /etc/sudoers
B) /etc/passwd
C) /etc/shadow
D) /etc/login.defs

Answer: A) /etc/sudoers

Explanation:

The /etc/sudoers file controls sudo privileges. You can add a line like username ALL=(ALL) NOPASSWD: /path/to/command to allow passwordless execution. /etc/passwd and /etc/shadow manage users and passwords, not sudo privileges. /etc/login.d defconfigures general login defaults.

In Linux, sudo is a powerful utility that allows users to execute commands with the privileges of another user, usually the root user, without logging in directly as root. The configuration of sudo privileges is managed by the /etc/sudoers file, which defines which users or groups are permitted to run specific commands and under what conditions. This file is critical for system security because it grants controlled administrative access while preventing unauthorized privilege escalation.

Each line in /etc/sudoers typically follows the format:

user host=(run-as-user) options: command

 

For example, adding a line such as:

john ALL=(ALL) NOPASSWD: /usr/bin/systemctl restart apache2

 

Allows the user John to execute the systemctl restart apache2 command without entering a password on any host. The ALL=(ALL) portion indicates that John can run the command as any user, on any host, while NOPASSWD disables the password prompt for this specific command.

It is important to note that /etc/sudoers is distinct from other user and login configuration files. The /etc/passwd file contains user account information, such as username, UID, GID, home directory, and login shell, but does not control administrative privileges. The /etc/shadow file securely stores encrypted user passwords and password aging information, again with no relation to sudo configuration. Similarly, /etc/login.defs defines general login defaults, such as password expiration policies, UID ranges, and account settings, but does not affect sudo privileges.

For security reasons, the /etc/sudoers file should never be edited directly with a normal text editor; instead, the visudo command should be used. visudo performs syntax checking before saving, preventing errors that could lock administrators out of sudo access. Proper configuration of /etc/sudoers ensures that users have the necessary administrative privileges without compromising system security, making it an essential tool for Linux system administration.

Question 26:

Which of the following commands will show detailed memory usage, including cached and free memory, in Linux?

A) free -h
B) vmstat
C) top
D) All of the above

Answer: D) All of the above

Explanation:

Free shows total, used, free, shared, buffer/cache, and available memory in a human-readable format. vmstat provides memory statistics along with process and CPU info. The top gives real-time memory usage per process along with overall system memory. All are useful tools depending on context.

In Linux, monitoring system memory is essential for maintaining performance, diagnosing issues, and managing resources effectively. Several commands provide insights into memory usage, each with its own focus and level of detail.

The free command is one of the simplest and most commonly used tools for viewing memory statistics. Using the -h option, as in free -h, displays memory values in a human-readable format (e.g., MB or GB), showing total memory, used memory, free memory, shared memory, buffer/cache, and available memory. The “available” field estimates how much memory is readily available for new applications without swapping, while “buffer/cache” represents memory used by the system for caching and buffering. This provides a quick snapshot of the system’s memory state, which is helpful for general monitoring and scripting.

The vmstat (virtual memory statistics) command provides a more comprehensive overview of memory, processes, and CPU activity. It shows metrics such as free and used memory, swap usage, the number of processes waiting for CPU, and system I/O statistics. This makes it particularly useful for troubleshooting performance bottlenecks or analyzing system behavior over time.

For real-time monitoring of memory usage per process, top is a dynamic utility that continuously updates the display. It shows active processes along with CPU and memory consumption, allowing administrators to identify memory-intensive applications. htop, an enhanced interactive version of top, provides color-coded output, easier navigation, and filtering options, which are especially useful on multi-user systems or servers running many processes.

Each tool serves a different purpose: free -h gives a quick overall memory snapshot, vmstat provides detailed system-wide metrics, and top/htop allows process-level monitoring in real-time. Using these tools together gives a complete picture of system memory usage, helping administrators optimize performance, prevent memory exhaustion, and troubleshoot issues efficiently.

Question 27:

Which command would you use to list all files, including hidden files, i a directory?

A) ls
B) ls -a
C) ls -l
D) ls -lh

Answer: B) ls -a

Explanation:

The -a option in ls shows all files, including hidden files that start with a dot (.). Lsalonedoes not show hidden files. -l and -lh provide long-format or human-readable file sizes but do not affect hidden file visibility.

In Linux, the ls command is the most commonly used utility to list files and directories. By default, running ls displays only non-hidden files, meaning files and directories that do not begin with a dot (.). Hidden files, often configuration or system files, are excluded from the standard output to reduce clutter in directory listings. Examples of hidden files include .bashrc, .profile, and .gitconfig.

To view these hidden files, the -a option can be used, as in ls -a. This option lists all files, including those beginning with a dot. It is especially useful when inspecting system directories, checking configuration files, or debugging issues related to hidden files. Using ls -a provides a comprehensive overview of a directory’s contents, revealing files that would otherwise remain invisible to standard directory listings.

In addition to the -a option, the -l option allows viewing detailed information about each file in a long listing format. This includes the file type and permissions, number of hard links, owner, group, file size, and last modification timestamp. For human-readable file sizes, the -h option can be added, producing ls -lh, which converts sizes into KB, MB, or GB instead of raw bytes. These options do not affect hidden file visibility; they simply provide more information about the files listed.

Combining these options, as in ls -alh, allows a user to see all files, including hidden ones, with detailed, human-readable information about file permissions, ownership, sizes, and modification times. This is particularly valuable for system administrators, developers, and users who need a complete and clear understanding of the directory contents, including hidden configuration and system files.

Understanding these ls options is fundamental for Linux file management, ensuring both visibility of hidden files and insight into file attributes, which is critical for troubleshooting, permissions management, and system auditing.

Question 28:

Which command will display the permissions, owner, and group of all files in the current directory?

A) ls -l
B) stat *
C) ls -a
D) chmod

Answer: A) ls -l

Explanation:

LLs-ll provides a long listing format, showing file permissions, number of links, owner, group, size, and timestamp. sStat* shows similar info,  but in a different format for each file. LLs-a shows all files, including hidden files, but not detailed permissions. chmod changes permissions rather than displaying them.

In Linux, understanding file permissions and attributes is critical for system administration. The ls command is one of the most commonly used tools for viewing files and directories. Using the -l option, as in ls -l, displays a long listing format that includes detailed information about each file: the file type and permissions, the number of hard links, the owner and group, file size, and the last modification timestamp. This output allows administrators to quickly assess access rights and ownership for each file in a directory.

The stat command provides similar information, but in a more detailed and structured format. For example, stat * displays attributes for each file, including inode number, device ID, number of links, access, modification, and change times, along with detailed permission information in both numeric and symbolic forms. This makes stat useful for in-depth file analysis and scripting.

The ls -a command shows all files, including hidden files starting with a dot (.), but it does not provide detailed permission or ownership information.

It is important to note that chmod does not display information; it is used to change file permissions. While ls -l and stat are for viewing file attributes, chmod modifies them, making these commands complementary. Proper understanding of ls, stat, and chmod is essential for effective file management and security in Linux systems.

 

Question 29:

Which command shows the last login times of all users on the system?

A) last
B) who
C) w
D) uptime

Answer: A) last

Explanation:

The last command reads from /var/log/wtmp to show a historical list of logins, reboots, and shutdownsWhoshowsws current logged-in users. w shows current users with system activity. Uptime shows how long the system has been running.

In Linux, monitoring user logins, system activity, and uptime is essential for administration and troubleshooting. The last command provides a historical record of logins, reboots, and shutdowns by reading entries from the /var/log/wtmp file. Each line shows the username, terminal, IP address (if remote), login time, logout time, and session duration. Additionally, it records system reboots and shutdowns, making it a valuable tool for auditing user activity and analyzing system usage over time.

The who command, in contrast, shows users currently logged into the system. It displays the username, terminal, login time, and, in some implementations, the host from which the user is connected. This is useful for real-time monitoring of active sessions.

The w command extends the functionality of who by providing current system activity, including the processes each logged-in user is running, CPU usage, and idle time. It gives a dynamic overview of user behavior and system load in real time.

Finally, the uptime command provides a concise summary of how long the system has been running since the last reboot, along with the number of currently logged-in users and the system load averages for the past 1, 5, and 15 minutes. Together, these commands give administrators both historical and real-time insights into user activity and system performance, aiding in monitoring, security, and resource management.

Question 30:

Which command would you use to find which processes are using a specific file?

A) fuser filename
B) lsof filename
C) ps aux | grep filename
D) Both A and B

Answer: D) Both A and B

Explanation:

fFuserfilename lists PIDs using the file. lsof filename provides detailed information about open files, including process ID, user, and file descriptor. ps aux | grep filename only finds processes matching a name, not necessarily file usage.

In Linux, identifying which processes are currently using or accessing a particular file is an essential task for system administration, especially when performing maintenance, unmounting filesystems, or troubleshooting issues, and the commands provided—A) fuser filename, B) lsof filename, C) ps aux | grep filename, and D) Both A and B—serve different purposes with distinct approaches. Option A, fuser filename, is a command-line utility designed to show all processes accessing a specified file or filesystem. When executed, it returns the process IDs (PIDs) of programs currently using the file, and with additional flags, it can display the user owning the process or terminate the processes using the file. For example, running fuser -v filename provides verbose output with detailed information about access type (read, write, execute), which is particularly useful for administrators who need to safely release a file for maintenance or deletion. Option B, lsof filename, stands for List Open Files and is another powerful tool to identify processes using a specific file. Unlike fuser, lsof provides extensive details about the file, including the PID, user, file descriptor, access mode, and the associated command, offering a comprehensive view of all interactions with the file. It can also be used to examine network connections, open directories, and other resources, making it versatile for debugging and system monitoring. Option C, ps aux | grep filename, is a more general approach that attempts to identify processes by searching the process list for the filename. While this can sometimes work if the filename appears in the command-line arguments of a running process, it is less reliable because many processes may access the file without referencing it explicitly in their command line, and it can produce false positives if other processes contain the filename in their command strings. Option D, Both A and B, highlights that combining fuser and lsof offers the most robust method for accurately identifying all processes interacting with a file, as fuser quickly provides PIDs and access types while lsof delivers detailed metadata and context about the file usage. In practical system administration, using both commands ensures that administrators can safely manage files, terminate conflicting processes if necessary, and perform maintenance without risking data corruption or service disruption. Understanding the differences between these tools is crucial: fuser is straightforward and quick for targeted file usage, lsof is comprehensive for in-depth investigation, ps aux | grep is general but limited and prone to inaccuracies, and using both A and B together (option D) provides a complete solution. This knowledge allows administrators to effectively monitor file usage, manage resources, and maintain system stability while handling files that are actively used by running processes.

Question 31:

Which command allows you to create a cron job for the current user?

A) crontab -e
B) cron -e
C) systemctl cron
D) /etc/cron.d

Answer: A) crontab -e

Explanation:

cCrontab-e opens the user’s crontab file for editing. You can define recurring jobs here. /etc/cron.d contains system-wide cron jobs. Cron-e and systemctl cron are incorrect.

In Linux, managing scheduled tasks is often done through the cron system, which allows users and administrators to execute scripts or commands automatically at specified intervals, and the commands or locations provided—A) crontab -e, B) cron -e, C) systemctl cron, and D) /etc/cron.d—illustrate different approaches and contexts for working with cron, each with its specific use case and scope. Option A, crontab -e, is the standard method for editing the crontab of the current user. When executed, it opens the user’s personal crontab file in the default text editor, allowing them to define scheduled tasks using the cron time format (minute, hour, day, month, weekday) followed by the command to execute. This approach is user-specific, meaning each user can maintain their own set of scheduled tasks without affecting others, and changes made with crontab-e take effect immediately once the file is saved. Option B, cron-e, is not a valid command in most Linux distributions; there is no standard cron-e executable for editing crontab files. Users attempting to edit cron jobs should always use crontab -e for individual users or appropriate system files for global settings. Option C, systemctl cron, is also incorrect as written, because systemctl is used to manage systemd services, and while cron may be a service (like cron. service or crond.service), systemctl cron alone does not provide functionality for editing or scheduling tasks. The correct usage would be systemctl start cron or systemctl enable cron to manage the cron daemon, but it does not replace the need to edit crontabs for scheduling tasks. Option D, /etc/cron.d, is a directory for system-wide cron jobs and is typically used by administrators to define scheduled tasks for the system or for specific services. Files placed in /etc/cron.d must follow a specific format, including the username under which the task runs, along with the timing and command. This allows multiple system tasks to be scheduled without modifying individual user crontabs, providing centralized management and better control over automated operations. In summary, among the four options, crontab -e (option A) is the correct and standard method for editing user-specific cron jobs, /etc/cron.d (option D) is used for system-wide scheduled tasks, and options B and C are incorrect for scheduling purposes: cron -e does not exist as a command, and systemctl cron only manages the cron service itself rather than editing scheduled tasks. Understanding the distinctions between these approaches is essential for Linux administrators to effectively automate tasks, ensure consistent execution of scripts, and maintain system stability, while differentiating between user-specific and system-wide scheduling mechanisms and avoiding confusion with invalid commands.

Question 32:

What is the purpose of the /etc/fstab file?

A) It stores user passwords
B) It lists mounted filesystems
C) It contains the ootloader configuration
D) It defines automatic mounting of filesystems at boot

Answer: D) It defines automatic mounting of filesystems at boot

Explanation:

/etc/fstab specifies how disk partitions, devices, and remote filesystems should be automatically mounted at boot. It contains device, mount point, filesystem type, and mount options. It does not store passwords or bootloader information.

In Linux, /etc/fstab is a critical configuration file that plays a central role in defining how filesystems are mounted at boot, and understanding its purpose in relation to other system files is essential for effective system administration, especially when comparing the options provided—A) It stores user passwords, B) It lists mounted filesystems, C) It contains the bootloader configuration, and D) It defines automatic mounting of filesystems at boot. Option A, “It stores user passwords,” is incorrect in the context of /etc/fstab, as user passwords are securely stored in /etc/shadow with hashed values, while /etc/passwd contains basic account information such as usernames, UIDs, GIDs, home directories, and login shells. Therefore, /etc/fstab does not handle authentication or password management at any level. Option B, “It lists mounted filesystems,” is partially related but not fully accurate; while administrators can view currently mounted filesystems using commands like mount or df -h, /etc/fstab itself does not dynamically list what is currently mounted. Instead, it contains static definitions of filesystems, their mount points, types, options, and dump/pass values, which the system references during boot to determine which filesystems should be automatically mounted and with what parameters. Option C, “It contains the bootloader configuration,” is also incorrect, as bootloader configuration is managed separately, typically in files like /boot/grub/grub.cfg for GRUB, or via UEFI configuration for modern systems. /etc/fstab does not interact with bootloaders; it operates at the filesystem level after the kernel has been loaded to ensure that filesystems are properly mounted and accessible for system operation. Option D, “It defines automatic mounting of filesystems at boot,” is the correct description of /etc/fstab’s purpose. Each line in /etc/fstab specifies a device, a mount point, the filesystem type, mount options (such as defaults, noatime, or ro), and optional dump and pass fields for filesystem checking. By referencing this file, the system knows which partitions, network shares, or virtual filesystems to mount automatically during the boot process, ensuring that directories such as /home, /var, and /tmp are available before users or services attempt to access them. Proper configuration of /etc/fstab is crucial, as incorrect entries can lead to boot failures or inaccessible filesystems. In summary, among the four options, only D accurately reflects the function of /etc/fstab as a system configuration file for automatic mounting of filesystems at boot, while A, B, and C describe unrelated functions handled by /etc/shadow, commands like mount, or bootloader configuration files, respectively. Understanding this distinction allows administrators to manage filesystem mounts effectively, troubleshoot boot-time errors, and ensure a reliable and consistent system environment.

Question 33:

Which of the following commands will check disk usage on all mounted filesystems?

A) df -h
B) du -sh *
C) lsblk
D) fdisk -l

Answer: A) df -h

Explanation:

dDf shows disk space usage for mounted filesystems. -h formats it in human-readable units. dDushows directory usage, not the entire filesystem. lsblk shows block devices, and fdisk -l lists partition info.

In Linux, managing storage and understanding disk usage is an essential part of system administration, and the commands provided—A) df -h, B) du -sh *, C) lsblk, and D) fdisk -l—each serve distinct purposes while providing complementary information about disks, partitions, and filesystem utilization. Option A, df -h, is used to display the disk space usage of mounted filesystems in a human-readable format, showing total, used, available space, and the mount points for each filesystem. This command is particularly useful for administrators and users who need a quick overview of how much space is consumed on different partitions and where potential storage issues might arise. Option B, du -sh *, focuses on the size of individual directories and files within the current working directory. The -s option summarizes the total size of each item, while -h converts the size into a human-readable format like KB, MB, or GB. Unlike df -h, which reports overall filesystem usage, du-sh * provides detailed insights into which directories or files are consuming the most space, making it ideal for tracking down large files and managing disk space efficiently. Option C, lsblk, provides a tree-like view of all block devices, including disks, partitions, and their mount points, along with size, type, and attributes. While it does not directly show usage statistics, lsblk is invaluable for understanding the structure of storage devices, identifying unmounted partitions, and verifying how disks are organized. Option D, fdisk -l, lists all partitions on all available disks, displaying detailed information such as partition size, type, and start/end sectors. This command is essential for low-level storage management, including creating, modifying, or troubleshooting partitions, but it does not provide usage statistics like df -h or du -sh *. When used together, these four tools give a comprehensive view of the system’s storage: lsblk and fdisk -l describe the physical and logical layout of disks and partitions, while df -h reports mounted filesystem usage, and du -sh * identifies directory-level storage consumption. For example, an administrator troubleshooting disk space issues might first run lsblk to identify all available disks, use fdisk -l to verify partitioning, check df -h to see which partitions are nearly full, and finally use du -sh * to pinpoint which directories or files are consuming excessive space. Understanding the scope and purpose of these commands allows for effective storage monitoring, maintenance, and planning, ensuring system stability and optimal resource utilization. By leveraging all four tools together, administrators gain both high-level and granular perspectives on disk usage, partitions, and filesystem health, which is critical for maintaining a reliable and efficiently managed Linux system.

Question 34:

You want to find all files larger than 100MB in /var. Which command would you use?

A) find /var -size +100M
B) du -sh /var/* | grep 100M
C) ls -lh /var | grep 100M
D) df -h /var

Answer: A) find /var -size +100M

Explanation:

Find can filter files by size using -size +100M. Dushows displays directory sizes but not individual files in a searchable way.LLs-lhh does not directly filter by size. dDf-h shows filesystem usage, not individual file sizes.

In Linux, identifying large files within a directory like /var is essential for managing disk space and ensuring system stability, and the commands provided—A) find /var -size +100M, B) du -sh /var/* | grep 100M, C) ls -lh /var | grep 100M, and D) df -h /var—each serve different purposes, offering complementary methods to monitor storage usage. Option A, find /var -size +100M, is the most precise approach for locating individual files exceeding a specified size, in this case, files larger than 100 megabytes. The find command recursively searches the /var directory and its subdirectories, providing exact filenames and paths of large files. This is particularly useful for pinpointing problematic files that could be consuming significant disk space, such as log files, database files, or cache files. Option B, du -sh /var/* | grep 100M, provides a summary of the sizes of directories and files directly under /var. The du -sh command calculates disk usage for each item in a human-readable format, and piping the output to grep 100M filters results to display only those directories or files roughly around 100 megabytes. While du summarizes sizes at the directory level, it does not automatically examine nested subdirectories unless combined with additional options, so it is better suited for quickly identifying which top-level directories are consuming the most space. Option C, ls -lh /var | grep 100M, lists files and directories in /var with human-readable sizes, but unlike find or du, it only examines the immediate contents of /var and does not provide recursive information. This makes it limited for thorough disk usage analysis, but useful for a quick check of top-level items that may have large files. Finally, option D, df -h /var, does not identify individual files but instead shows overall filesystem usage for the partition where /var resides. It displays total, used, and available space in a human-readable format, helping administrators understand whether the partition is nearing capacity, though it does not indicate which files are responsible for the usage. In practice, an administrator may use these commands together: starting with df -h /var to assess overall usage, then du -sh /var/* | grep 100M to narrow down large directories, and finally find /var -size +100M to identify specific files that require cleanup or archival. The ls -lh approach can be used for quick inspections of individual items when recursive searching is unnecessary. Understanding the differences and purposes of these commands allows for effective disk space management, targeted cleanup of large files, and proactive monitoring to prevent system issues caused by disk exhaustion. Collectively, these four tools provide a layered and comprehensive approach to managing storage within /var, combining high-level overviews with detailed file-level investigation.

Question 35:

Which file contains information about network interfaces and their IP addresses in most Linux distributions?

A) /etc/network/interfaces
B) /etc/sysconfig/network-scripts/
C) /etc/hosts
D) Both A and B depend on the distribution

Answer: D) Both A and B, depending on distribution

Explanation:

Debian-based systems store network interface configurations in /etc/network/interfaces. Red Hat-based systems use /etc/sysconfig/network-scripts/ifcfg-*. /etc/hosts maps hostnames to I but does not configure interfaces.

In Linux, network configuration is managed through different files and directories depending on the distribution and network management tools used, and the options provided—A) /etc/network/interfaces, B) /etc/sysconfig/network-scripts/, C) /etc/hosts, and D) Both A and B, depending on the distribution—highlight these differences and their specific roles in network configuration. Option A, /etc/network/interfaces, is commonly used in Debian-based distributions such as Debian and Ubuntu to define network interfaces, including static IP addresses, gateways, DNS servers, and interface-specific options. This file allows administrators to configure network settings for each interface manually, and it is read by networking scripts or services during system boot to bring the interfaces up with the specified configuration. Option B, /etc/sysconfig/network-scripts/, is used primarily in Red Hat-based distributions such as CentOS, RHEL, and Fedora. It contains individual configuration files for each network interface, typically named ifcfg-<interface>, and defines parameters such as IP address, netmask, gateway, and DNS information. These scripts are executed by the network service at boot time to activate interfaces according to the defined settings. Option C, /etc/hosts, is not used for interface configuration but is instead a local hostname resolution file, mapping hostnames to IP addresses. While it does not control interface parameters, it is essential for name resolution on the local system, allowing network tools and applications to resolve hostnames without querying DNS servers. It is a static file and is particularly useful for small networks or for overriding DNS results locally. Option D, Both A and B, depending on the distribution, correctly emphasizes that network configuration in Linux is distribution-dependent. Debian-based systems rely on /etc/network/interfaces for static configuration, whereas Red Hat-based systems use /etc/sysconfig/network-scripts/. Modern distributions may also utilize network management tools like NetworkManager or systemd-networkd, which can override or supplement these files, but understanding the traditional file-based approach remains essential for troubleshooting and manual configuration. In practice, an administrator working on a Debian system would edit /etc/network/interfaces to set a static IP or configure a DHCP client, while a Red Hat system administrator would modify ifcfg- files under /etc/sysconfig/network-scripts/. The /etc/hosts file is universally available and serves as a complementary tool for local hostname resolution regardless of distribution. Understanding the distinctions between these files and directories allows system administrators to effectively configure and troubleshoot network interfaces, manage IP assignments, and ensure reliable connectivity across diverse Linux distributions. By recognizing that options A and B are distribution-specific and that /etc/hosts serves a different purpose, administrators can select the correct method for the system they are managing and maintain consistent network configuration practices.

Question 36:

You need to change the priority (nice value) of a running process with PID 1234. Which command should you use?

A) renice 10 1234
B) nice -10 1234
C) kill -10 1234
D) priority -p 1234

Answer: A) renice 10 1234

Explanation:

Renice changes the nice value of an existing process. Nice sets the priority for a new process. Killsends signals to terminate or manage processes, but does not change nice values. Priority is not a standard Linux command.

Question 37:

Which command displays network interface statistics, including RX/TX packets and errors?

A) ifconfig
B) ip -s link
C) netstat -i
D) All of the above

Answer: D) All of the above

Explanation:

Ifconfig and ip -s link display network interfaces with statistics. netstat -i shows interface statistics, including packet counts and errors. Modern distributions prefer ip over ifconfig.

Question 38:

Which command updates the list of available packages in Debian-based systems?

A) apt-get update
B) apt-get upgrade
C) dpkg –update
D) apt-cache refresh

Answer: A) apt-get update

Explanation:

Apt-get update downloads the latest package lists from configured repositories s Apt-get update upgrades installed packages. dpkg is for managing local packages. Apt-cacherefresh is not a standard command.

Question 39:

Which of the following commands can change file timestamps?

A) touch file.txt
B) stat file.txt
C) ls -l file.txt
D) chmod file.txt

Answer: A) touch file.txt

Explanation:

tTouch updates the access and modification timestamps of a file, or creates the file if it does not exist. Stat displays timestamps. LLs-l lists them. chmod changes permissions, not timestamps.

Question 40:

Which command is used to check the current system hostname?

A) hostname
B) uname -n
C) cat /etc/hostname
D) All of the above

Answer: D) All of the above

Explanation:

hHostnameprints or sets the hostname. uname -n prints the network node hostname. /etc/hostname contains the persistent system hostname. All methods provide valid hostname information.

Leave a Reply

How It Works

img
Step 1. Choose Exam
on ExamLabs
Download IT Exams Questions & Answers
img
Step 2. Open Exam with
Avanset Exam Simulator
Press here to download VCE Exam Simulator that simulates real exam environment
img
Step 3. Study
& Pass
IT Exams Anywhere, Anytime!