LPI 010-160 Linux Essentials Certificate Exam, version 1.6 Exam Dumps and Practice Test Questions Set6 Q101-120
Visit here for our full LPI 010-160 exam dumps and practice test questions.
Question 101
Which command is used to display the currently logged-in users along with their activity?
A) who
B) w
C) last
D) all of the above
Answer: D) all of the above
Explanation:
Monitoring user activity is crucial for system administration, auditing, and security. Linux provides several commands for different levels of detail regarding user sessions.
The who command displays users currently logged in along with terminal information, login time, and originating host. It is particularly useful for administrators to verify real-time sessions and determine who is accessing the system at any moment. For example, who can show multiple users logged in through SSH or local terminals, providing insight into active sessions.
The w command extends the functionality of who by providing additional information, including each user’s active processes, CPU time, idle time, and the command currently being executed. This is valuable for identifying resource-intensive users or monitoring multi-user environments to ensure that no user is monopolizing system resources.
The last command reads the /var/log/wtmp file and provides a historical list of user logins, including login times, durations, and logout events. This is essential for auditing past activities, detecting unusual login patterns, or investigating security incidents. Administrators can filter last output by username or terminal, making it flexible for both general and targeted monitoring.
A) who – Correct. Displays real-time login sessions, helping administrators monitor current user activity.
B) w – Correct. Shows active processes for each logged-in user, providing context for system resource usage.
C) last – Correct. Offers historical login records, crucial for auditing and troubleshooting user activity.
D) all of the above – Correct. Mastery of all three commands ensures comprehensive monitoring, from real-time session observation (who), process-level activity monitoring (w), to historical audit trails (last). Understanding the differences between these commands allows administrators to track user behavior, maintain system security, and optimize multi-user system performance, which is a critical skill for Linux Essentials certification.
Question 102
Which command is used to display the path of an executable that would be run for a given command?
A) which
B) whereis
C) type
D) all of the above
Answer: D) all of the above
Explanation:
Understanding the location of executables and command resolution is critical for troubleshooting, scripting, and system maintenance. Linux provides several tools to find where a command resides and how it will be executed.
The which command searches the directories listed in the PATH environment variable and shows the full path of the executable that would run if the command is executed. For example, which ls typically outputs /bin/ls, confirming the actual binary location. This helps in verifying that the correct version of a command is being executed, especially in systems with multiple versions installed.
The whereis command provides information about the binary, source, and man page location for a command. For example, whereis ls might return /bin/ls /usr/share/man/man1/ls.1.gz, showing both executable and documentation locations. This command is useful for administrators to locate resources for documentation, troubleshooting, or scripting.
The type command explains how a command name is interpreted by the shell. It distinguishes between aliases, shell built-ins, functions, and external binaries. For example, type cd may indicate that it is a shell built-in, whereas type ls shows it as an external command at a specific path.
A) which – Correct. Shows the path of the executable that would run, useful for verifying command resolution.
B) whereis – Correct. Provides executable and related documentation locations, helpful for locating resources.
C) type – Correct. Indicates how the shell interprets the command, differentiating built-ins from binaries.
D) all of the above – Correct. Understanding all three commands is essential for Linux Essentials. Administrators can ensure scripts execute expected binaries, troubleshoot path conflicts, and verify system configuration. These tools collectively improve system reliability, prevent misconfigurations, and support efficient troubleshooting and administration.
Question 103
Which command is used to schedule a one-time task to run at a specific time?
A) at
B) cron
C) systemd timer
D) all of the above
Answer: A) at
Explanation:
Scheduling tasks is essential for system automation, maintenance, and repetitive operations. Linux provides different mechanisms for executing commands at specific times.
The at command schedules a one-time task to run at a specified future time. For example, echo “backup.sh” | at 22:00 schedules the execution of backup.sh at 10 PM. After scheduling, atq can list pending jobs, and atrm <jobid> can remove jobs. at is ideal for ad-hoc tasks that do not need repetitive execution.
cron is used for recurring scheduled tasks. It reads crontab files and executes commands at specified intervals (e.g., daily, weekly, or monthly). While powerful, cron is not intended for single, one-off execution.
systemd timers can replace cron in modern systems, providing both one-time and recurring task scheduling. However, setting up timers requires creating unit files, which is more complex than using at for simple one-time jobs.
A) at – Correct. Best suited for scheduling one-time tasks at a specific time, commonly used in Linux Essentials.
B) cron – Incorrect for one-time tasks; designed for recurring execution.
C) systemd timer – Technically capable but complex; not standard for simple one-off tasks.
D) all of the above – Incorrect. Only at directly schedules one-time tasks efficiently. Mastery of at ensures administrators can automate ad-hoc operations, plan system maintenance, and run scripts at precise times without manual intervention, which is essential for Linux Essentials certification and daily system administration.
Question 104
Which command is used to display the manual page for a command?
A) man
B) info
C) help
D) all of the above
Answer: D) all of the above
Explanation:
Accessing documentation is a critical Linux skill for understanding command syntax, options, and usage examples.
The man command displays the manual page for a command. For example, man ls shows sections such as name, synopsis, description, options, and examples. Manual pages are standardized and provide comprehensive reference material for most commands.
The info command presents GNU-style documentation in hyperlinked sections, allowing more detailed explanations and navigation than traditional man pages. For example, info ls provides extended explanations and examples of all options.
The help command displays built-in shell command information. For example, help cd lists usage and available options for the shell built-in cd. It is not for external binaries but essential for shell internal commands.
A) man – Correct. Standard command to access traditional Unix/Linux manual pages.
B) info – Correct. Accesses detailed GNU documentation with navigation features.
C) help – Correct. Provides documentation for shell built-ins.
D) all of the above – Correct. Combined knowledge ensures administrators can access relevant information for external commands, shell built-ins, and extended documentation, a key Linux Essentials competency.
Question 105
Which command is used to terminate a process by its PID?
A) kill
B) pkill
C) killall
D) all of the above
Answer:
D) all of the above
Explanation:
Managing processes is essential for system stability, troubleshooting, and resource management. Linux provides several commands to terminate processes using different criteria.
The kill command sends signals to a process specified by its Process ID (PID). For example, kill -9 1234 forcibly terminates the process with PID 1234. The kill command requires knowledge of the PID, usually obtained using ps, top, or pidof.
The pkill command terminates processes by name, eliminating the need to manually look up PIDs. For example, pkill firefox kills all processes named firefox. pkill can also match patterns and accept additional options like sending specific signals.
The killall command kills all processes with the given name, similar to pkill. For example, killall apache2 terminates all running Apache processes. Differences exist in syntax and available options between distributions, but functionality overlaps significantly.
A) kill – Correct. Terminates a process using its PID, critical for precise control over system processes.
B) pkill – Correct. Kills processes by name or pattern, useful for administrative convenience.
C) killall – Correct. Kills all processes by name, useful for batch termination.
D) all of the above – Correct. Understanding all three methods ensures administrators can manage processes effectively, whether by PID or process name, enhancing system reliability and resource management, a key requirement for Linux Essentials.
Question 106
Which command is used to monitor memory usage in real-time?
A) free -s 5
B) top
C) htop
D) all of the above
Answer: D) all of the above
Explanation:
Monitoring memory is critical for system performance, troubleshooting, and capacity planning. Linux provides multiple tools for this purpose.
The free command with the -s option repeatedly displays memory usage at intervals. For example, free -s 5 updates memory statistics every 5 seconds, showing total, used, free, buffers, and cache. This allows administrators to observe trends over time and detect memory leaks.
The top command displays real-time memory usage per process and overall system memory. Sorting by %MEM helps identify processes consuming excessive memory, enabling proactive intervention.
The htop command provides an enhanced interactive view of memory usage with visual bars, color coding, and process tree views. Administrators can sort processes, kill tasks, and observe memory in a user-friendly interface.
A) free -s 5 – Correct. Provides real-time memory statistics at specified intervals.
B) top – Correct. Interactive monitoring of memory usage per process.
C) htop – Correct. Enhanced real-time memory monitoring with visual tools.
D) all of the above – Correct. Using these tools together allows comprehensive monitoring of system memory, identification of high-usage processes, and troubleshooting of performance issues, which is essential for Linux Essentials certification.
Question 107
Which command is used to display disk usage of files and directories in a human-readable format?
A) du -h
B) df -h
C) ls -lh
D) all of the above
Answer: A) du -h
Explanation:
Disk space management is a crucial task for system administrators and is essential for Linux Essentials certification. Knowing which files and directories consume disk space allows administrators to optimize storage, prevent full filesystems, and identify unnecessary files or logs that could be cleaned up. The du (disk usage) command is specifically designed for this purpose. The -h option stands for “human-readable” and formats the output using units like KB, MB, or GB, which makes interpreting the output easier, especially for larger directories.
When executing du -h /path/to/directory, the command recursively calculates the size of each file and subdirectory within the specified path. By adding –max-depth=1, administrators can see the sizes of immediate subdirectories without being overwhelmed by detailed output for every single file. This is particularly useful for quickly identifying large subdirectories that may be using excessive disk space. For example, in /var/log, du -h –max-depth=1 can reveal whether logs or application-generated data are consuming disproportionate amounts of storage.
While df -h also provides disk usage information, it operates at the filesystem level, showing total, used, and available space for mounted filesystems rather than detailed usage for individual files and directories. For example, df -h can tell you that /dev/sda1 has 80% disk usage, but it cannot tell you which specific directory or file is responsible for consuming that space.
Similarly, ls -lh lists files in a directory with human-readable sizes, which is useful for seeing the size of individual files but does not calculate the cumulative size of directories. For example, ls -lh /var/log shows file sizes but does not provide a total size for /var/log.
Using du -h effectively allows administrators to maintain system performance, prevent unexpected full disk situations, and plan for storage expansion or cleanup. In production environments, monitoring disk usage is a proactive task that can prevent outages caused by full filesystems, especially for critical directories such as /var/log, /home, or /tmp. Combining du with sort -h allows the output to be sorted by size, making it even easier to pinpoint the largest directories and files.
Overall, du -h is the most suitable command for examining disk usage at the directory and file level. Mastery of this command allows Linux administrators to manage disk space efficiently, troubleshoot storage issues, and maintain system health, which is a key requirement for the Linux Essentials certification.
Question 108
Which command is used to change the permissions of a file or directory?
A) chmod
B) chown
C) chgrp
D) all of the above
Answer:
A) chmod
Explanation:
File permissions in Linux control who can read, write, or execute a file or directory. Understanding how to modify these permissions is critical for maintaining system security, controlling access, and ensuring proper operation in multi-user environments. The chmod (change mode) command is used to set or modify the access permissions of files and directories. Permissions can be represented either numerically (octal) or symbolically (using letters like r, w, and x).
For example, chmod 755 file.txt assigns full read, write, and execute permissions to the owner, while granting read and execute permissions to the group and others. Alternatively, using symbolic mode, chmod u+rwx,g+rx,o+rx file.txt achieves the same effect. Symbolic mode is particularly useful for modifying specific permissions without affecting others.
chmod also allows recursive changes with the -R option, which is essential when setting permissions for entire directory trees. For example, chmod -R 755 /var/www/html ensures that all files and subdirectories under /var/www/html have the same permissions, which is common when configuring web servers.
While chown changes the owner of a file or directory, and chgrp changes the group ownership, neither modifies permission bits. Using chmod correctly ensures that users have appropriate access to files, scripts, or directories while preventing unauthorized access. For instance, sensitive files like /etc/shadow require strict permission settings (chmod 600) to prevent system compromise.
Proper understanding of chmod is critical in environments where multiple users share access to files. Misconfigured permissions can lead to security vulnerabilities, accidental file deletion, or failure of automated scripts. By mastering chmod, administrators can control access precisely, enforce security policies, and ensure system stability. It is a foundational skill for the Linux Essentials certification, providing a basis for more advanced file security and permission management tasks.
Question 109
Which command is used to view the contents of a text file one page at a time?
A) less
B) more
C) cat
D) all of the above
Answer: D) all of the above
Explanation:
Viewing file contents efficiently is a fundamental Linux skill. There are multiple commands to read files, each offering different capabilities for navigation, search, and interaction.
The less command displays the content of a file one screen at a time. It is highly versatile because it allows scrolling forward and backward, searching with regular expressions, and jumping to specific lines. For example, less /var/log/syslog enables administrators to navigate large log files without opening the entire file in memory. less does not load the whole file at once, making it efficient for very large files. Navigation keys include Space to move forward, b to move backward, / to search, and q to quit.
The more command also displays content one page at a time but is more limited. It allows forward navigation and simple searching but does not support backward navigation in some implementations. Historically, more was the first pager utility and is still included for compatibility. For example, more /var/log/syslog allows simple paging but with less flexibility than less.
The cat command displays the entire file content at once, which can be impractical for large files. While cat can be combined with | less to emulate paging, it does not natively provide interactive navigation. For example, cat /var/log/syslog | less allows paged viewing using less after streaming the content.
Using less is generally preferred due to its advanced capabilities, including search, backward navigation, and efficiency with large files. Administrators can use less to examine logs, configuration files, or any textual data efficiently without overwhelming the terminal. Combined with other commands like grep, it becomes even more powerful. For example, less /var/log/syslog | grep error allows locating specific entries interactively.
Mastering these commands ensures administrators can read and analyze system files effectively, troubleshoot issues, and maintain operational efficiency. Understanding the differences between less, more, and cat is essential for Linux Essentials certification, as these skills form the basis of log analysis, file inspection, and general system administration.
Question 110
Which command is used to display currently logged-in users along with their active processes?
A) who
B) w
C) last
D) all of the above
Answer: B) w
Explanation:
Monitoring user activity is an essential part of Linux system administration. The w command provides a real-time overview of who is logged in, what they are doing, and the system’s load averages. The output of w includes the username, terminal, login time, idle time, and the command currently being executed. This information is critical for administrators who need to monitor resource usage, identify runaway processes, or verify that users are following system policies.
While who displays the currently logged-in users with their terminal and login time, it does not provide information about the processes each user is running. This makes it less useful for identifying resource-intensive activity.
The last command shows historical login sessions, including login time, duration, and logout events, which is important for auditing but does not provide real-time monitoring of active processes.
The w command is particularly valuable in multi-user environments because it allows administrators to correlate user activity with system performance. For example, if the CPU load is unusually high, running w can help identify which user or process is causing the spike. Additionally, w provides load averages for the past 1, 5, and 15 minutes, helping administrators understand overall system utilization and detect trends that could indicate potential performance issues.
Using w in conjunction with top or htop provides a more comprehensive view of user activity and process performance, allowing administrators to take timely action, such as terminating problematic processes or optimizing resource allocation. Mastery of this command is essential for Linux Essentials certification because it ensures administrators can monitor user activity effectively, maintain system performance, and troubleshoot issues proactively.
Question 111
Which command is used to display the network configuration and IP addresses of the system?
A) ifconfig
B) ip addr
C) nmcli
D) all of the above
Answer: D) all of the above
Explanation:
Understanding the network configuration of a Linux system is critical for system administration, troubleshooting connectivity issues, and managing network services. Multiple commands are available for viewing network interfaces, IP addresses, and routing information, each offering different levels of detail and output formatting.
The ifconfig command is a traditional tool for displaying and configuring network interfaces. When executed without arguments, it lists all active interfaces, their IP addresses, MAC addresses, netmask, broadcast address, and other essential parameters. Although considered deprecated on some modern distributions in favor of the ip command, ifconfig remains widely used in tutorials, scripts, and legacy systems. For example, ifconfig eth0 displays detailed information about the eth0 interface, which is useful for verifying connectivity or diagnosing misconfigurations.
The ip addr command is part of the newer iproute2 suite and provides more comprehensive networking information. For instance, ip addr show lists all interfaces, assigned IP addresses (both IPv4 and IPv6), state (UP or DOWN), and associated link-layer addresses. Unlike ifconfig, ip addr can also display advanced networking details such as multiple addresses per interface, link scope, and broadcasting options. Using ip is recommended for modern Linux systems because it is actively maintained, script-friendly, and supports a broader range of networking tasks.
The nmcli command is a tool specific to NetworkManager, commonly used in desktop and server environments that rely on dynamic network configuration. Running nmcli device show displays information about all network interfaces, their IP addresses, MAC addresses, DNS servers, and connection states. Additionally, nmcli can be used to configure connections, manage Wi-Fi networks, and automate network management tasks, making it versatile for both monitoring and administration.
A) ifconfig – Correct. Provides basic interface information and IP addresses, useful for legacy systems and quick checks.
B) ip addr – Correct. Offers detailed interface information in a modern, comprehensive format suitable for scripting and advanced networking.
C) nmcli – Correct. Displays interface and connection details for systems managed by NetworkManager, with capabilities for monitoring and configuration.
D) all of the above – Correct. Mastery of all three commands ensures administrators can access network configuration information in various environments, understand IP addressing, troubleshoot connectivity issues, and manage network interfaces efficiently. This knowledge is a fundamental requirement for Linux Essentials certification, as networking is an essential skill for both servers and desktop Linux environments.
Question 112
Which command is used to archive files into a single compressed file?
A) tar
B) gzip
C) zip
D) all of the above
Answer: D) all of the above
Explanation:
Archiving and compressing files is a critical skill in Linux for backup, storage efficiency, and file transfer. Linux provides multiple tools to combine multiple files and directories into a single archive and optionally compress the archive to save space.
The tar command is the most commonly used tool for archiving. It combines multiple files or directories into a single file, often referred to as a tarball (with a .tar extension). For example, tar -cvf archive.tar /home/user/docs creates an uncompressed archive of the docs directory. Adding compression flags like -z for gzip or -j for bzip2 allows administrators to compress the archive: tar -czvf archive.tar.gz /home/user/docs creates a gzip-compressed tarball, while tar -cjvf archive.tar.bz2 /home/user/docs creates a bzip2-compressed archive. This is ideal for backups, distribution, or moving large directories efficiently.
The gzip command is used to compress individual files, reducing their size. For example, gzip file.txt compresses file.txt and produces file.txt.gz. Gzip is commonly used in combination with tar to create compressed tarballs (.tar.gz). It is not designed to archive multiple files by itself; for that purpose, tar is generally preferred.
The zip command is another method to archive and compress files simultaneously. It is widely used, particularly for compatibility with Windows systems. For example, zip archive.zip file1 file2 creates a zip file containing multiple files. Unlike tar, which focuses on combining files into an archive and optionally compressing them, zip compresses and archives in a single step. It also provides options for encryption, password protection, and recursive directory compression.
A) tar – Correct. The standard tool for archiving multiple files or directories, often used with gzip or bzip2 for compression.
B) gzip – Correct. Compresses individual files and is commonly combined with tar for creating compressed archives.
C) zip – Correct. Archives and compresses files simultaneously, compatible with cross-platform environments.
D) all of the above – Correct. Understanding all three commands ensures administrators can handle a variety of archiving and compression tasks, manage backups efficiently, and prepare files for storage or transfer. Mastery of these commands is critical for Linux Essentials certification because it supports file management, storage optimization, and interoperability between Linux and other operating systems.
Question 113
Which command is used to display the current working directory?
A) pwd
B) ls
C) cd
D) all of the above
Answer: A) pwd
Explanation:
The current working directory is the directory in which the user is currently operating. Knowing the working directory is fundamental to performing tasks in Linux, such as navigating the filesystem, executing scripts, or managing files. The pwd command, which stands for “print working directory,” outputs the full path of the current directory. For example, running pwd in /home/user/docs will display /home/user/docs. This information is vital for scripting, troubleshooting, and ensuring commands operate on the correct files.
The ls command lists files and directories in the current or specified directory, but it does not indicate the absolute path of the working directory. While it helps identify contents, it is insufficient for determining the full location in the filesystem hierarchy.
The cd command changes the current working directory but does not display it unless used in combination with pwd afterward. For instance, cd /tmp changes the directory to /tmp, but without pwd, the current directory is not explicitly shown.
Using pwd is essential for scripting, as scripts often require knowledge of the current directory to access relative paths correctly. Combining pwd with other commands ensures accuracy in operations like file manipulation, backups, or system configuration tasks. For example, cp file.txt $(pwd)/backup/ copies a file into a backup directory using the absolute path derived from pwd.
Mastery of pwd allows administrators to avoid errors caused by relative path misunderstandings, navigate complex directory structures efficiently, and maintain operational accuracy. This skill is fundamental for Linux Essentials certification because all file management, scripting, and system operations rely on a clear understanding of the current working directory.
Question 114
Which command is used to show the last lines of a log file in real-time?
A) tail -f
B) head
C) cat
D) all of the above
Answer: A) tail -f
Explanation:
Log monitoring is a critical aspect of Linux system administration. System logs provide detailed information about system activity, errors, and security events. Monitoring the latest log entries in real-time allows administrators to respond quickly to system problems, suspicious activity, or application failures. The tail -f command is specifically designed for this purpose.
The tail command by itself displays the last N lines of a file (default is 10). Adding the -f option causes tail to follow the file, updating the output in real-time as new lines are appended. For example, tail -f /var/log/syslog allows administrators to continuously observe system log activity, such as login attempts, service failures, or kernel messages. This is particularly useful during debugging, monitoring services like web servers, or investigating performance issues.
The head command displays the first N lines of a file and is useful for examining file headers, but it does not provide ongoing monitoring capabilities. For example, head -n 20 /var/log/syslog shows the first 20 lines, which may be outdated and not suitable for real-time observation.
The cat command concatenates and displays the entire content of a file but does not provide scrolling or real-time updates for large files. Using cat on log files may overwhelm the terminal, especially for logs with thousands of lines, and does not allow monitoring as new entries are added.
Using tail -f is often combined with grep for filtering specific messages. For example, tail -f /var/log/syslog | grep error continuously monitors the log and highlights lines containing the word “error,” enabling targeted troubleshooting and rapid response to critical issues.
Mastery of tail -f is essential for Linux Essentials certification. It equips administrators with the ability to actively monitor system logs, detect failures, and maintain system reliability. Real-time log monitoring is a best practice for production systems and supports proactive problem resolution, which is a core skill for any Linux professional.
Question 115
Which command is used to display the current date and time in Linux?
A) date
B) cal
C) timedatectl
D) all of the above
Answer: D) all of the above
Explanation:
Time and date management is essential in Linux for scheduling tasks, logging events, and ensuring system synchronization. Several commands can provide this information, each offering different levels of detail and functionality.
The date command displays the current system date and time and allows formatting of the output. For example, date “+%Y-%m-%d %H:%M:%S” outputs the date in a readable format with year, month, day, hour, minute, and second. It is also used to set the system date temporarily (requires superuser privileges).
The cal command displays a calendar for the current month or specified month and year. While not used for exact time, it provides a visual reference for dates. For example, cal 2025 shows the calendar for the year 2025.
The timedatectl command, part of systemd, provides detailed information about time, date, timezone, NTP synchronization, and RTC (hardware clock). Running timedatectl displays local time, universal time, RTC time, timezone, and NTP status. It can also be used to change the system timezone or enable automatic time synchronization.
A) date – Correct. Displays current date and time and supports custom formatting.
B) cal – Correct. Displays calendar information, helpful for planning and visual reference.
C) timedatectl – Correct. Provides comprehensive time-related information and configuration options.
D) all of the above – Correct. Mastery ensures administrators can check the system date, plan tasks, and maintain accurate time settings, which is essential for Linux Essentials certification and reliable system operation.
Question 116
Which command is used to search for a specific text pattern within files?
A) grep
B) find
C) locate
D) all of the above
Answer: A) grep
Explanation:
Searching for text within files is a core Linux skill, essential for troubleshooting, log analysis, and configuration management. The grep command (global regular expression print) is designed to search files or input for specific patterns, providing matches along with context.
grep supports regular expressions, allowing sophisticated search patterns. For example, grep “error” /var/log/syslog searches the syslog file for lines containing the word “error,” enabling administrators to pinpoint critical events efficiently. grep -i makes searches case-insensitive, grep -r searches recursively through directories, and grep -n displays line numbers where matches occur, which is invaluable for locating issues in configuration or code files.
While find and locate are used to locate files by name or metadata, they do not search for text inside files. find can be combined with grep to search contents within files across directories, for example: find /var/log -type f -exec grep “error” {} \;, which combines both tools for advanced searches.
locate uses a prebuilt database of file paths to quickly find filenames but cannot search within the file content itself. For example, locate syslog lists all files named syslog but does not indicate if the word “error” exists inside them.
A) grep – Correct. Directly searches file contents using patterns, supports regular expressions, and provides context, making it essential for Linux administrators to analyze logs, troubleshoot errors, and inspect configuration files.
B) find – Incorrect as a standalone tool for text searches. Primarily used for locating files by name, size, or attributes.
C) locate – Incorrect for searching within files; it indexes filenames and paths for quick retrieval.
D) all of the above – Incorrect. Only grep searches text within files effectively.
Mastery of grep is critical for Linux Essentials certification because it enables administrators to quickly analyze logs, identify errors, and verify configurations. Combined with other tools like awk, sed, and find, it becomes a powerful component of daily system administration, making it indispensable for troubleshooting, auditing, and automating repetitive tasks.
Question 117
Which command is used to display running services on a systemd-based system?
A) systemctl list-units –type=service
B) service –status-all
C) ps aux
D) all of the above
Answer: D) all of the above
Explanation:
Managing and monitoring services is a fundamental Linux administration skill. Services (also called daemons) run in the background, performing system tasks such as network management, web serving, or database handling. Monitoring their status is essential for troubleshooting, system maintenance, and ensuring that critical services remain available.
On modern Linux distributions that use systemd, systemctl list-units –type=service provides a detailed overview of all active, loaded, and failed services. It lists unit names, load state, active state, and sub-state, enabling administrators to quickly determine which services are running, which failed to start, or which are inactive. For example, systemctl list-units –type=service | grep apache shows whether the Apache web server service is active and loaded correctly. Systemd provides tools to start, stop, enable, or disable services, making it a central part of service management.
On older systems or for compatibility with SysVinit scripts, service –status-all lists all services and their current status. It displays symbols like [ + ] for running services or [ – ] for stopped services. While less detailed than systemctl, it remains useful for auditing services in environments that maintain legacy init scripts.
ps aux lists all running processes, which indirectly includes services. By filtering with grep (e.g., ps aux | grep nginx), administrators can check whether specific services’ processes are running. However, this method does not provide service state metadata or enable control over services, so it complements rather than replaces systemd commands.
A) systemctl list-units –type=service – Correct. Provides a comprehensive list of active services with status information.
B) service –status-all – Correct. Compatible with older init systems, lists the status of services, useful in mixed environments.
C) ps aux – Correct. Displays processes associated with services, helpful for troubleshooting specific daemons.
D) all of the above – Correct. Knowledge of all three methods ensures administrators can monitor services effectively across both modern and legacy systems, maintain service uptime, troubleshoot failures, and perform essential Linux system management tasks. Mastery of service monitoring is critical for Linux Essentials certification and real-world administration.
Question 118
Which command is used to display the current shell environment variables?
A) env
B) printenv
C) set
D) all of the above
Answer: D) all of the above
Explanation:
Environment variables control the behavior of the shell and applications. Viewing them is fundamental for configuring the system, troubleshooting scripts, and understanding how processes inherit settings. Linux provides multiple commands to view environment variables, each with different levels of detail.
The env command lists all environment variables for the current shell session. For example, env | grep PATH shows the directories in the PATH variable, which determine where the shell searches for executable files. Administrators often use env to verify that environment variables are correctly set for scripts, applications, or users.
The printenv command displays environment variables as well, either all of them or a specific variable. For example, printenv HOME outputs the current user’s home directory. printenv is commonly used in scripts to check or log environment settings.
The set command provides a more comprehensive view, listing both shell functions and all variables, including environment variables. While env and printenv focus only on environment variables, set displays everything defined in the shell session, including local variables, functions, and exported environment variables. For example, running set | grep PATH shows all definitions related to PATH, whether local or exported.
Understanding the output of these commands is crucial for troubleshooting script execution, verifying software dependencies, and ensuring system behavior matches expectations. For instance, missing environment variables like PATH or JAVA_HOME can cause scripts or applications to fail. By combining env, printenv, and set, administrators gain a complete view of the shell environment, allowing them to debug, configure, and maintain Linux systems effectively.
A) env – Correct. Lists environment variables for the current session, useful for troubleshooting and verification.
B) printenv – Correct. Displays specific or all environment variables, ideal for scripts and audits.
C) set – Correct. Displays shell variables, functions, and environment variables, offering a comprehensive view.
D) all of the above – Correct. Using all three commands ensures administrators can inspect, verify, and manage environment variables effectively, a key skill for Linux Essentials certification. Understanding environment variables allows proper configuration of software, scripts, and system behavior, preventing operational errors.
Question 119
Which command is used to display free and used disk space on mounted filesystems?
A) df -h
B) du -h
C) lsblk
D) all of the above
Answer: A) df -h
Explanation:
Monitoring disk space is essential for maintaining system health, preventing failures, and ensuring sufficient storage for applications and users. Linux provides several commands for different levels of disk usage reporting.
The df (disk filesystem) command reports free and used space on mounted filesystems. The -h option formats output in a human-readable way, using units like KB, MB, or GB. For example, df -h displays the filesystem, total size, used space, available space, and mount points. This allows administrators to quickly assess storage availability, detect potential bottlenecks, and plan for disk expansion or cleanup operations.
The du (disk usage) command, by contrast, calculates the disk usage of files and directories, focusing on individual paths rather than the entire filesystem. While du is useful for analyzing which directories consume the most space, it does not provide an overview of filesystem-wide usage.
The lsblk command displays block device information, showing devices, partitions, and mount points, but it does not report used or available space for mounted filesystems. It is more suited for understanding device hierarchy and partitioning rather than disk usage statistics.
A) df -h – Correct. Provides a concise summary of free and used space for all mounted filesystems in a human-readable format, essential for monitoring storage health.
B) du -h – Incorrect for filesystem-wide space; it focuses on directory/file usage.
C) lsblk – Incorrect; shows device hierarchy but not used space.
D) all of the above – Incorrect. Only df -h directly provides the required information about filesystem disk usage.
Mastering df -h allows administrators to proactively manage storage, detect full partitions before they cause system failures, and plan backups. For Linux Essentials certification, understanding df ensures candidates can monitor, maintain, and troubleshoot filesystem storage efficiently, which is a fundamental system administration skill.
Question 120
Which command is used to display the permissions, owner, and group of a file or directory?
A) ls -l
B) stat
C) getfacl
D) all of the above
Answer: D) all of the above
Explanation:
File permissions, ownership, and access control are critical for security and multi-user management in Linux. Multiple commands allow administrators to inspect files and directories to ensure proper configuration.
The ls -l command provides a simple listing of files with details such as permissions, owner, group, size, and modification time. For example, ls -l file.txt may show -rw-r–r– 1 alice users 1024 file.txt, indicating read/write permissions for the owner, read-only for group and others. This command is essential for quickly verifying file accessibility and ownership.
The stat command provides detailed information about a file, including inode number, device, permissions, owner, group, size, and timestamps. For example, stat file.txt displays access, modification, and change times, as well as numeric permission representation. This is useful for auditing and scripting, where precise metadata information is required.
The getfacl command displays Access Control Lists (ACLs), providing extended permissions beyond standard Unix modes. For example, getfacl file.txt may show additional user or group access rights not visible in ls -l. ACLs are commonly used in environments with complex permission requirements.
A) ls -l – Correct. Basic view of permissions, owner, and group, suitable for everyday use.
B) stat – Correct. Provides detailed metadata including permissions in numeric form.
C) getfacl – Correct. Shows extended ACL permissions for detailed access control analysis.
D) all of the above – Correct. Mastery ensures administrators can verify file security, troubleshoot access issues, and maintain system integrity, which is fundamental for Linux Essentials certification.
Popular posts
Recent Posts
