LPI 010-160 Linux Essentials Certificate Exam, version 1.6 Exam Dumps and Practice Test Questions Set 13 Q181-195

LPI 010-160 Linux Essentials Certificate Exam, version 1.6 Exam Dumps and Practice Test Questions Set 13 Q181-195

Visit here for our full LPI 010-160 exam dumps and practice test questions.

Question 181

Which of the following commands is used to search for a specific text pattern within files?

A) grep
B) find
C) locate
D) cat

Answer: A) grep

Explanation:

The grep command searches for text patterns within files. It can match regular expressions, specific words, or sequences of characters. grep is widely used for filtering log files, configuration files, or any text content. It can display matching lines, highlight matches, and even count occurrences.

The find command searches for files and directories based on their names, types, sizes, or other attributes. While powerful for locating files, it does not search the content of files for specific text.

The locate command is used to find files and directories using a prebuilt database. It is very fast for finding file paths but does not search inside the file contents themselves.

The cat command outputs the full contents of a file but does not perform any pattern searching. It merely displays the text, and any searching would have to be done manually or piped through grep.

grep is correct because it is explicitly designed to search for text patterns within files, making it the only command that meets the requirement in this context.

Question 182 

Which Linux directory contains device files representing hardware devices?

A) /dev
B) /usr
C) /proc
D) /bin

Answer: A) /dev

Explanation:

The /dev directory in Linux is a fundamental part of the filesystem hierarchy that plays a crucial role in enabling communication between software and hardware. This directory contains special files known as device files, which act as interfaces to hardware devices and kernel-managed resources. These device files are not regular files in the traditional sense; rather, they are representations of physical or virtual hardware components that allow user-space programs to interact with devices in a controlled and standardized manner. By using these files, programs can read from or write to devices without needing to know the low-level details of the underlying hardware.

In Linux, nearly every hardware component and many virtual resources are represented by a corresponding entry in the /dev directory. These include hard drives, solid-state drives, optical drives, terminals, input devices such as keyboards and mice, USB devices, network interfaces, and even pseudo-devices like random number generators and null devices. For example, block devices such as hard drives appear as /dev/sda, /dev/sdb, and so on, while partitions on those drives appear as /dev/sda1, /dev/sda2, etc. Character devices, which handle data streams such as keyboards and serial ports, also reside here with appropriate entries like /dev/tty for terminals and /dev/console for the system console. The presence of these device files allows standard Linux tools and applications to perform operations like reading from or writing to storage devices, sending data to a printer, or capturing input from a mouse in a consistent manner across different types of hardware.

It is important to note that the /dev directory does not contain the actual hardware itself; rather, it contains special files that serve as an abstraction layer. When a program interacts with a device file, the kernel interprets the actions and directs them to the actual hardware device. This approach is central to Linux’s philosophy of treating “everything as a file,” where hardware devices, system resources, and even inter-process communication channels can be accessed through the familiar file interface. For instance, writing data to /dev/sda1 sends that data to the first partition of the first hard disk, and reading from /dev/urandom retrieves random numbers generated by the kernel. The abstraction provided by /dev ensures that programs do not need device-specific knowledge to operate correctly, enhancing portability and simplifying software development.

By contrast, other directories in Linux serve different purposes and do not provide direct access to hardware devices. The /usr directory, for example, is primarily used to store user-installed software, libraries, and documentation. It is an important part of the system for application binaries, shared resources, and manual pages, but it does not contain device representations. Programs stored in /usr may interact with devices, but they do so through /dev or other system interfaces, not by containing device files themselves. Similarly, the /proc directory is a virtual filesystem that exposes runtime information about the system. It contains entries for processes, kernel parameters, system statistics, and configuration details. While /proc can provide information about devices, such as statistics for network interfaces or storage devices, it does not allow direct read/write access to hardware in the way /dev does. /proc is primarily for monitoring and querying the system state rather than interacting with devices as functional resources.

The /bin directory is another key part of the Linux filesystem hierarchy, storing essential binary executables required for basic system functionality and boot processes. Commands like ls, cp, mv, and other core utilities are located in /bin, ensuring that users and scripts can perform critical operations even in minimal environments. While /bin is vital for system operation, it does not contain device files or provide hardware access; it merely contains the programs that may use device files for performing tasks. This distinction emphasizes the unique role of /dev as the directory that directly represents devices within the filesystem.

From a practical standpoint, the /dev directory is also critical for system management and troubleshooting. Administrators often inspect or manipulate device files to configure storage devices, monitor terminals, or test hardware communication. Device files have permissions that control which users or processes can access them, providing a security layer that prevents unauthorized or accidental interactions with sensitive hardware resources. For example, only root may have write access to certain block devices, ensuring that users cannot overwrite critical filesystem partitions inadvertently.

In addition, modern Linux systems frequently use dynamic device management through tools like udev, which automatically creates and removes device files in /dev as hardware is added or removed. This dynamic handling ensures that /dev always accurately reflects the current state of available devices without requiring manual intervention, supporting hot-plugging of USB drives, external storage, and other peripherals. The combination of static entries for essential devices and dynamic entries for removable or transient devices makes /dev highly flexible and central to system operation.

The /dev directory is the dedicated location in Linux for special device files that represent both physical and virtual hardware. It allows applications and the kernel to communicate with devices in a standardized manner, enabling read and write operations to storage, input, output, and other system components. Unlike /usr, which contains software and shared resources, or /proc, which provides system information, or /bin, which contains essential executables, /dev is specifically designed to interface with hardware. Its abstraction and dynamic management capabilities make it an indispensable part of Linux systems, ensuring reliable and controlled access to all hardware resources.

Question 183

Which command is used to display the current logged-in user in Linux?

A) whoami
B) id
C) who
D) users

Answer: A) whoami

Explanation:

The whoami command in Linux is designed to display the username of the current user executing the command. It is a simple and direct way to identify the user in the current session. This command is particularly useful in multi-user systems where different accounts may be active, and a user needs to verify under which credentials they are operating. It outputs only the username, making it concise and ideal for use in scripts, automation, or verifying access permissions.

The id command provides comprehensive information about the current user, including the user ID (UID), primary group ID (GID), and all groups to which the user belongs. While it includes the username, it provides far more detail than necessary when simply verifying the current user. Its output is best suited for administrative tasks or for gathering detailed user-related information rather than a quick username check.

The who command displays all users currently logged into the system, along with details such as the terminal they are connected from, login times, and occasionally the remote host. While it is useful for monitoring active sessions and understanding system usage, it does not specifically identify the user executing a particular command in the current session. It is more appropriate for administrators monitoring multiple users rather than individuals checking their own identity.

The users command lists all usernames currently logged into the system. Unlike whoami, it does not distinguish which session is being executed or provide any context about the current session. It is useful for a quick view of active accounts but is not precise for determining the exact active user for a given command execution.

whoami is correct because it serves the exact purpose described: identifying the user currently executing commands. It is efficient, concise, and outputs only the information required, unlike id, who, or users, which provide either excessive detail or information not directly relevant to the current session. Understanding whoami is fundamental for Linux users managing permissions, executing scripts, or validating session identity in multi-user environments.

Question 184

Which directory in Linux typically contains system-wide configuration files?

A) /etc
B) /usr
C) /var
D) /home

Answer: A) /etc

Explanation:

The /etc directory in Linux serves as the central repository for system-wide configuration files. It contains settings that define how the operating system and installed applications behave. Examples include configuration files for network settings, user authentication, system services, startup scripts, and software configurations. These files are read by system processes during startup and execution, ensuring the system behaves consistently across sessions.

The /usr directory primarily contains user-installed programs, libraries, and documentation. It is designed for software and shared resources rather than configuration files. Files in /usr include binaries, libraries, and manuals but not system configuration data. Although /usr may contain application-specific configurations in certain subdirectories, it is not the standard location for system-wide configuration.

The /var directory is intended for variable data files, such as logs, caches, spool files, and databases. While logs in /var/log may contain information about system operations, /var is not used to store the configuration files that determine system behavior. Its contents are dynamic and can change frequently during system operation.

The /home directory is designated for individual users’ personal files, documents, and configuration settings. While user-specific configuration files may exist in hidden subdirectories within /home, they apply only to a single user and do not affect system-wide behavior.

/etc is correct because it is explicitly designed for global configuration files that the operating system and all users rely upon. Knowledge of /etc is essential for system administration, troubleshooting, and understanding how Linux maintains system behavior across multiple users and sessions.

Question 185

Which command displays information about the system’s running processes?

A) ps
B) df
C) top
D) uname

Answer: A) ps

Explanation:

The ps command in Linux provides a snapshot of currently running processes. It displays process IDs (PIDs), terminal associations, CPU time, and the commands associated with each process. ps is versatile and allows users to filter processes by criteria such as user, process state, or command name. It is commonly used to check which processes are running in a session, monitor background tasks, and troubleshoot system performance.

The df command reports disk space usage for mounted filesystems. While it provides valuable information about storage capacity and utilization, it does not offer any insight into running processes. df is oriented toward filesystem management rather than process management.

The top command offers a real-time, dynamic display of processes, including CPU and memory usage. While top provides continuous monitoring, ps is preferred when a static snapshot of running processes is needed. top is more interactive, whereas ps is non-interactive and more suitable for logging or scripting scenarios.

The uname command displays system information, including kernel version, system architecture, and OS name. It does not provide process information. uname is primarily used for system identification rather than monitoring system activity or processes.

ps is correct because it specifically lists processes active at the moment of execution. It provides a clear, structured view of process details, making it essential for system monitoring, troubleshooting, and administrative tasks. Unlike df, top, or uname, ps is purpose-built for capturing and reviewing the state of running processes.

Question 186

Which command is used to display the amount of free and used disk space on mounted filesystems?

A) df
B) du
C) free
D) ls

Answer: A) df

Explanation:

The df command, short for “disk free,” is used in Linux to display information about the disk space usage of mounted filesystems. It provides a snapshot of the total disk space, used space, available space, and percentage of usage for each filesystem. This command is essential for monitoring storage capacity and identifying disks that are running low on space. By default, df displays information in blocks, but it can also show human-readable sizes, such as kilobytes, megabytes, or gigabytes. It is particularly useful for system administrators, developers, and users who need to ensure that filesystems do not fill up and cause system issues.

The du command, which stands for “disk usage,” is often confused with df, but it serves a different purpose. du shows the size of files and directories, providing a breakdown of how much space specific items are using. While it can be combined with options to summarize directories, du is more focused on individual paths rather than giving an overview of mounted filesystems. Therefore, du is useful for analyzing which files or directories consume the most space, but it does not provide a concise view of free and used space across all mounted disks.

The free command reports memory usage, including RAM and swap space. It is completely unrelated to disk storage. While free is important for understanding system memory utilization, it does not provide information about disk partitions, available storage, or filesystem usage. Attempting to use free for disk monitoring would not provide meaningful results.

The ls command lists the contents of directories. While it can show file sizes with certain flags, it does not summarize total disk space usage for mounted filesystems. ls is mainly used for navigating and exploring directories rather than assessing overall storage availability.

df is correct because it directly reports the available, used, and total space for each mounted filesystem, providing an essential overview for storage management. Unlike du, free, or ls, df focuses specifically on the filesystem level rather than individual files or memory metrics. Understanding df is critical for Linux users who need to manage disk resources effectively and prevent storage-related issues.

Question 187

Which command in Linux displays the first few lines of a file by default?

A) head
B) tail
C) cat
D) more

Answer: A) head

Explanation:

The head command is designed to display the beginning portion of a file. By default, it shows the first ten lines, but this can be adjusted with specific options to display a desired number of lines. head is commonly used for quickly previewing files, especially large ones, without opening the entire content. It is particularly useful for reviewing logs, configuration files, or any text data where the top portion contains critical information. The command provides a non-intrusive way to inspect content, helping users identify structure or detect potential issues.

The tail command serves a complementary purpose by displaying the last part of a file. It is most frequently used to monitor logs in real-time or view the most recent entries in a file. While tail is invaluable for tracking system activity or monitoring updates, it does not show the beginning of a file. Therefore, it does not fulfill the requirement of displaying the first lines by default.

The cat command outputs the entire content of a file to the terminal. While it can be used in combination with other commands to view the start of a file, by itself, it does not limit output to the first lines. For large files, using cat may flood the terminal with excessive content, making it less practical for a quick preview compared to head.

The more command allows paginated viewing of a file, letting the user scroll through content one screen at a time. Although it can start from the top, it is interactive and designed for reading through files rather than directly showing only the first lines by default. It requires user interaction to navigate, unlike head, which immediately provides the initial lines.

head is correct because it is specifically designed to display the first portion of a file efficiently. It is concise, non-interactive, and widely used for quickly previewing file contents. Unlike tail, cat, or more, head directly addresses the requirement of showing only the first lines by default. Understanding head is essential for Linux users who frequently inspect files and logs without loading the entire content.

Question 188

Which directory in Linux is typically used for temporary files that do not persist after a reboot?

A) /tmp
B) /var
C) /home
D) /opt

Answer: A) /tmp

Explanation:

The /tmp directory is a designated location for temporary files in Linux. Files placed in /tmp are intended to be short-lived and are often automatically deleted upon system reboot or after a certain period. This directory is used by applications and the operating system to store intermediate data, caches, lock files, or session-related information. Because it is temporary, users should not store critical or permanent files in /tmp. It is commonly cleared by system maintenance scripts to free up space and ensure the filesystem remains uncluttered.

The /var directory contains variable data files that persist across reboots. This includes logs, spool files, databases, caches, and other runtime information. While /var may contain temporary-like data in specific subdirectories, its overall purpose is to store data that changes frequently but is meant to survive system restarts. Therefore, /var does not fulfill the requirement of being a fully temporary, ephemeral storage location.

The /home directory is dedicated to user data, including documents, configuration files, and personal settings. Files stored in /home are intended to persist across sessions and reboots. It is not used for temporary application or system data and is instead a location for user-specific persistent storage.

The /opt directory is used for optional software packages and third-party applications. It is designed to store installed programs and related files, typically with a more permanent lifecycle. /opt is not intended for temporary data storage and does not automatically clear its contents upon reboot.

/tmp is correct because it is specifically designated for temporary files that do not need to persist after a system restart. It provides a safe and standard location for applications to store ephemeral data without risking interference with user files or critical system data. Understanding /tmp is essential for Linux users, especially when troubleshooting application behavior or managing temporary storage needs.

Question 189

Which command in Linux is used to display the current working directory?

A) pwd
B) ls
C) cd
D) mkdir

Answer: A) pwd

Explanation:

The pwd command, short for “print working directory,” is used to display the absolute path of the directory in which the user is currently operating. Knowing the current working directory is essential when navigating through the filesystem, running scripts, or performing file operations, especially in nested directories. pwd provides a clear output of the full path, starting from the root directory, which helps prevent mistakes when referencing files or directories.

The ls command lists the contents of a directory, such as files and subdirectories, but it does not indicate the directory in which the command is executed. While ls can provide a visual overview of directory contents, it cannot be relied upon to determine the current path. It is used for inspection of files rather than location verification.

The cd command changes the current working directory to another specified location. While it affects the working directory, it does not display it directly. Users can combine cd with pwd to first navigate and then confirm their new location, but cd alone does not provide the requested information.

The mkdir command creates new directories in the filesystem. It does not report the current location or modify existing directory listings. Its sole purpose is expanding the directory structure by adding new folders.

pwd is correct because it directly addresses the need to display the current working directory. It is a fundamental command for Linux users to understand filesystem navigation and to ensure commands are executed in the correct location. In contrast, ls, cd, and mkdir serve different purposes, such as listing contents, changing directories, or creating directories.

Question 190 

Which command is used to display a list of logged-in users on a Linux system?

A) who
B) whoami
C) id
D) last

Answer: A) who

Explanation:

The who command displays a list of users currently logged into the Linux system. It provides details such as the username, the terminal they are connected from, login time, and occasionally the originating host. This information is critical for administrators to monitor active sessions, track system usage, and identify multiple logins. who is particularly useful in multi-user environments, helping maintain security and system oversight.

The whoami command displays only the username of the current session executing the command. While useful for identifying the active user, it does not provide a list of all logged-in users. Its scope is limited to the individual session rather than the full system.

The id command provides detailed information about a specific user, including user ID, group ID, and group memberships. While it can identify user attributes, it does not list all active users on the system. It is more suited for understanding permissions and user relationships rather than monitoring logins.

The last command shows a historical list of users who have previously logged into the system, including login times and session durations. While useful for auditing past activity, last does not show current active sessions. It is more historical than real-time.

who is correct because it provides a real-time view of all active users, including essential details about their sessions. Unlike whoami, id, or last, it focuses specifically on monitoring current logins, making it a crucial tool for system administrators and multi-user system management.

Question 191 

Which Linux command is used to display the manual pages for other commands?

A) man
B) help
C) info
D) whatis

Answer: A) man

Explanation:

The man command in Linux is one of the most fundamental and widely used tools for obtaining detailed information about commands, programs, and system functionalities. The term “man” is short for manual, and it serves as a gateway to the comprehensive documentation that comes with almost every command or utility installed on a Linux system. When a user invokes the man command followed by the name of a command or program, it opens a manual page that provides an organized, structured, and standardized description of that command’s usage. These manual pages include detailed information about the command’s syntax, the arguments it accepts, available options or flags, and descriptions of what each option does. They often also include sections on environment variables that affect the command, examples of typical usage, related commands, and references to further documentation. The man command is, therefore, an essential tool for both novice users who are learning the system and experienced administrators or developers who need to troubleshoot, optimize, or understand command behavior in depth.

Manual pages are divided into sections, each serving a specific purpose. For example, section 1 typically covers user commands, section 2 covers system calls, section 3 covers library functions, and other sections cover special files, configuration files, and conventions. This structure allows users to find precise information based on the type of command or resource they are consulting. For instance, if a user wants to understand how the ls command works, they can open the manual page using man ls and explore all the options, from basic usage to less common flags, in a clear and organized manner. This makes man an indispensable resource for understanding the subtleties of command usage, especially in environments where multiple options and complex syntax exist.

The man command is particularly valuable because it provides information about both simple and complex commands. For commonly used utilities, it explains basic options and examples, helping new users perform routine tasks such as copying files, navigating directories, or searching text. For advanced tools, it details numerous options and behaviors that may not be immediately obvious, helping users customize commands for specific needs or troubleshoot unexpected results. By providing authoritative documentation, man ensures that users have access to a reliable source of information without having to rely on online tutorials, third-party guides, or memory alone.

Other Linux documentation commands serve complementary purposes but are not as comprehensive or standardized as man. The help command, for example, provides a brief overview of built-in shell commands and their options. It is especially useful for quickly referencing simple commands like cd, echo, export, or read. Help is limited to commands built into the shell itself, and while it offers concise information for immediate use, it does not provide detailed explanations for external programs or utilities installed on the system. For users who need to understand a shell built-in quickly, help can be convenient, but it cannot replace the depth and coverage provided by man.

The info command is another documentation tool that provides structured information about commands in a hypertext-like format. Unlike man, which organizes content in a linear and sectioned manner, info presents documentation as nodes that can be navigated interactively, often with links to related topics. Info can offer more detailed explanations than help, including longer discussions, tutorials, or contextual examples. However, many users find the navigation system in info less intuitive or slower for quickly finding command syntax or usage details compared to the straightforward structure of man pages. Info is highly valuable for in-depth reading and learning about complex commands, but for quick reference, man remains the preferred choice.

The whatis command provides yet another type of reference, offering a one-line description of a command. This is particularly useful when a user encounters an unfamiliar command and wants to quickly determine its purpose without reading through an entire manual page. For example, whatis ls might return “ls (1) — list directory contents.” While whatis is excellent for identifying commands and understanding their general purpose, it does not provide usage examples, detailed option descriptions, or explanations of command behavior. It is a starting point, not a complete guide, and is typically used in conjunction with man when more information is required.

Man is therefore the most comprehensive and standardized tool among these options. It provides a full reference for understanding commands, including detailed descriptions of arguments, options, syntax, environment variables, examples, and related commands. Unlike help, which is limited to shell-built-ins, man covers both built-in and external commands. Unlike info, which provides interactive hypertext documentation that can sometimes be cumbersome to navigate, man presents content in a straightforward, familiar, and widely accepted format. Unlike whatis, which provides only brief descriptions, man delivers complete information, making it indispensable for learning, troubleshooting, or mastering Linux commands and programs.

In practical terms, man is essential for system administration, programming, and day-to-day command-line work. Administrators rely on man pages to understand command behavior, ensure correct syntax, and implement precise options to perform tasks efficiently. Users benefit from man when exploring new commands, troubleshooting errors, or learning how to customize commands for specific workflows. The availability of man pages for nearly every installed utility ensures that Linux users have access to authoritative, up-to-date documentation directly on their system without needing an internet connection, enhancing reliability and accessibility.

The man command is the cornerstone of Linux command-line documentation. It offers detailed, organized, and standardized information about commands and programs, covering all aspects of usage and behavior. While help, info, and whatis provide useful supplementary information in specific contexts, man stands out as the most complete and reliable reference for understanding and effectively using Linux commands. It is an indispensable tool for anyone working with Linux, from beginners to experienced professionals.

Question 192

Which command is used to display the contents of a file page by page in Linux?

A) more
B) cat
C) less
D) head

Answer: A) more

Explanation:

The more command in Linux allows users to view the contents of a file one screen at a time. It is particularly useful for reading long files, such as log files or documentation, without flooding the terminal. The user can press the spacebar to move to the next page or press Enter to advance one line at a time. more also allows simple navigation, but it has limitations compared to more advanced commands. It provides a practical solution when reading large files, as it prevents terminal overflow and gives the user control over how much content is displayed at once.

The cat command displays the full contents of a file at once. While it is useful for small files, it becomes impractical for large files because it outputs everything to the terminal, making it difficult to read or locate specific information. cat is mainly used to combine files, quickly inspect small content, or redirect file content to other commands, but it does not provide paging functionality.

The less command is a more advanced pager that allows viewing files interactively, scrolling forward and backward, and searching for specific text. Unlike more, less offers enhanced navigation and is widely preferred for large files because it allows both forward and backward movement and provides search capabilities. While less is more flexible than more, the question specifically asks for a command to view content page by page, which more was originally designed to do.

The head command displays only the first few lines of a file, typically ten by default. While useful for quickly previewing file beginnings, it does not allow users to read an entire file page by page. head provides a static snapshot of the top portion of a file and is not a paging tool.

more is correct because it provides a simple method to view file contents page by page, preventing terminal overflow and offering basic navigation. While less provides additional functionality, more is specifically recognized for basic page-by-page viewing, making it essential for users working with long files in Linux. Understanding more is important for efficiently navigating large textual content in situations where full interactive control is not required.

Question 193

Which command is used to move or rename files and directories in Linux?

A) mv
B) cp
C) rm
D) touch

Answer: A) mv

Explanation:

The mv command in Linux is used for moving files or directories from one location to another within the filesystem. It is also the standard method for renaming files or directories by moving them to the same directory with a new name. mv does not create new copies; it either changes the path or the name. It is essential for organizing the filesystem, managing file locations, and updating filenames to meet naming conventions or project requirements. Proper use of mv ensures that files are efficiently relocated or renamed without duplication.

The cp command copies files or directories from one location to another, creating duplicates. While cp can replicate content, it does not remove the original, which is necessary if the goal is to move or rename a file. cp is more appropriate for backup, duplication, or preserving the original file while creating additional copies.

The rm command removes files or directories from the filesystem. While it affects file presence, it is destructive and cannot be used for moving or renaming content. Using rm incorrectly can result in permanent data loss, making it unsuitable for tasks that require file relocation or renaming.

The touch command creates new empty files or updates timestamps on existing files. It does not move or rename files and is primarily used for file creation or managing modification times. It has no capability to alter the location or name of existing files.

mv is correct because it specifically fulfills the requirement of moving or renaming files and directories without creating duplicates. It is a fundamental command for filesystem management, helping users maintain organization, structure, and clarity. Understanding mv is crucial for Linux users to efficiently manage files, reorganize directories, and maintain accurate file naming conventions.

Question 194 

Which command is used to display disk usage of files and directories?

A) du
B) df
C) ls
D) free

Answer: A) du

Explanation:

The du command in Linux, short for “disk usage,” reports the space used by files and directories. It is used to determine how much storage each file or directory consumes, helping users identify large files or directories that may need cleanup. du can display results in human-readable format, recursively summarize directories, and provide totals for individual paths. It is essential for managing storage efficiently, auditing space usage, and identifying files that occupy excessive disk space.

The df command reports the total, used, and available space of mounted filesystems. While df provides an overview of storage capacity at the filesystem level, it does not break down usage for individual files or directories. It is useful for understanding overall filesystem health but not for analyzing specific file space consumption.

The ls command lists files and directories, optionally showing file sizes. However, ls only shows individual file sizes and does not summarize directory space usage. It cannot recursively calculate disk usage for nested directories and is therefore less practical for evaluating storage at a detailed level.

The free command displays memory usage, including RAM and swap space. It is unrelated to disk storage and does not provide any information about the size of files or directories. free is useful for memory management but does not help with disk space analysis.

du is correct because it directly measures the space used by files and directories, making it essential for identifying storage-intensive items and managing disk space. Unlike df, ls, or free, du provides a detailed and recursive view of disk usage at the file and directory level. Understanding du is critical for Linux users to maintain efficient storage usage and prevent space-related issues.

Question 195

Which command is used to display the currently logged-in users along with their login details in Linux?

A) who
B) whoami
C) id
D) users

Answer: A) who

Explanation:

The who command in Linux is used to display information about currently logged-in users. It provides essential details such as the username, terminal associated with the session, login time, and, in some cases, the originating host. This information is crucial for system administrators and users in multi-user environments to monitor active sessions, track system usage, and identify potential unauthorized access. By using who, administrators can quickly determine who is on the system and which sessions are active, making it valuable for security and management purposes.

The whoami command shows only the username of the current user executing the command. It is useful for identifying the active session for that user but does not provide a list of all users currently logged in. This makes it less suitable for administrative monitoring or auditing purposes when multiple users may be connected to the system simultaneously.

The id command displays detailed information about a specific user, including user ID (UID), group ID (GID), and the groups to which the user belongs. While it can be used to inspect a user’s permissions and identity, it does not provide information about other active sessions or users currently logged into the system.

The users command provides a list of usernames currently logged into the system but without details such as terminals, login times, or originating hosts. While it can give a quick overview of active users, it lacks the depth of information needed for monitoring sessions in detail.

who is correct because it offers a real-time, detailed snapshot of all active sessions on a Linux system. Unlike whoami, id, or users, it provides both the identity of the users and the context of their sessions, which is essential for system monitoring, security auditing, and administrative oversight. Understanding who is fundamental for administrators to maintain control and awareness of system activity.