XK0-005 CompTIA Linux+ Exam Dumps and Practice Test Questions Set 10 Q 181-200
Visit here for our full CompTIA XK0-005 exam dumps and practice test questions.
Question 181
Which command is used to display detailed information about the system’s CPU and architecture in Linux?
A) lscpu
B) uname -a
C) cat /proc/cpuinfo
D) dmidecode
Answer A) lscpu
Explanation
A) lscpu: lscpu displays detailed information about the CPU architecture, including the number of CPUs, cores, threads, sockets, model name, architecture type, and cache sizes. Administrators use lscpu to analyze processor capabilities, plan workload distribution, and optimize performance. Mastery of lscpu involves interpreting details such as NUMA nodes, CPU MHz, and cache hierarchy, which is critical for performance tuning, virtualization planning, and resource allocation. Proper use ensures efficient system operation, optimal scheduling of processes, and alignment of applications with hardware capabilities. It provides a concise, human-readable output specifically designed for administrators to quickly understand processor resources without parsing raw system files.
B) uname -a: uname -a provides basic system information, including kernel version, hostname, and architecture. While useful for general system overview, it lacks the detailed processor metrics that lscpu provides.
C) cat /proc/cpuinfo: cat /proc/cpuinfo displays raw CPU information, including vendor, model, and flags. It is highly detailed but less structured and harder to interpret quickly compared to lscpu.
D) dmidecode: dmidecode provides hardware information from the system BIOS, including CPU, memory, and motherboard details. While comprehensive, it is more hardware-centric and less focused on CPU operational metrics such as cores and threads available to the OS.
lscpu is correct because it provides structured, detailed CPU information suitable for analysis and planning. uname -a is general, /proc/cpuinfo is raw and less structured, and dmidecode is BIOS-centric. Mastery of lscpu allows Linux administrators to optimize performance, allocate resources effectively, and understand hardware capabilities for system tuning, virtualization, and workload distribution.
Question 182
Which command is used to check open network ports and associated processes on a Linux system?
A) netstat -tulnp
B) ss -tulnp
C) lsof -i
D) iptables -L
Answer B) ss -tulnp
Explanation
A) netstat -tulnp: netstat -tulnp lists TCP/UDP listening ports and associated processes. It is functional but considered legacy on modern Linux distributions. It provides valuable information about network sockets but lacks some advanced filtering and performance capabilities.
B) ss -tulnp: ss -tulnp is the modern replacement for netstat. It lists all TCP and UDP sockets along with the process ID and program name. Administrators use ss to monitor active connections, troubleshoot port conflicts, and ensure security by auditing listening services. Mastery of ss involves understanding socket states, filtering by protocol, port, or process, and using it in scripts for real-time monitoring. It is faster than netstat, more accurate, and integrates with modern Linux networking features, making it essential for enterprise-level network management and troubleshooting.
C) lsof -i: lsof -i lists network connections for processes. It is useful for identifying which process is using a port but is more resource-intensive and less efficient for large-scale monitoring compared to ss.
D) iptables -L: iptables -L displays firewall rules. While it indirectly affects network traffic, it does not list active open ports or processes.
ss -tulnp is correct because it efficiently displays active ports and associated processes in a modern, structured manner. netstat is legacy, lsof -i is resource-intensive, and iptables -L only shows firewall rules. Mastery of ss -tulnp allows Linux administrators to monitor network activity, troubleshoot connection issues, enforce security policies, and maintain operational network integrity.
Question 183
Which command is used to schedule a one-time task to run at a specific time in Linux?
A) at
B) cron
C) batch
D) systemd-run
Answer A) at
Explanation
A) at: at schedules a one-time task to run at a specified time. For example, echo “backup.sh” | at 23:00 executes the script once at 11 PM. Administrators use at for deferred execution of maintenance scripts, system updates, or ad-hoc tasks. Mastery of at involves understanding time formats, queues, and job management (using atq and atrm). Proper use of at ensures tasks are executed precisely, resources are managed efficiently, and operational routines are maintained without requiring continuous manual intervention. It is particularly useful for temporary or emergency tasks that should not recur regularly, providing flexibility in task scheduling.
B) cron: cron schedules recurring tasks based on a specified interval. It is not suitable for one-time tasks unless combined with temporary crontab entries.
C) batch: batch schedules tasks to run when system load is low. It is primarily load-based and not designed for precise one-time execution.
D) systemd-run: systemd-run can schedule transient services or timers, including one-time tasks, but it is more complex and systemd-specific. at is simpler for straightforward one-time scheduling.
at is correct because it schedules a one-time task at a specified time. cron is for recurring tasks, batch schedules under load, and systemd-run is complex for this use case. Mastery of at allows Linux administrators to automate tasks, plan deferred execution, and maintain operational efficiency for maintenance and system management.
Question 184
Which command is used to change the priority of a system service in systemd?
A) systemctl set-property service.service CPUWeight=50
B) nice -n 10 service.service
C) renice 10 -p service.service
D) systemctl start service.service
Answer A) systemctl set-property service.service CPUWeight=50
Explanation
A) systemctl set-property service.service CPUWeight=50: systemctl set-property allows administrators to adjust resource control properties for systemd-managed services, such as CPU, memory, or I/O weights. CPUWeight controls the relative CPU time allocation of a service. Mastery of this command involves understanding cgroups, resource allocation, and priority tuning to optimize system performance. Proper use ensures critical services get sufficient CPU resources, non-critical services do not monopolize the CPU, and overall system responsiveness is maintained. This is essential for enterprise workloads, virtualization hosts, or environments with mixed priority services.
B) nice -n 10 service.service: nice sets the priority for processes at launch but does not directly control systemd service priorities. It is more relevant for manually started processes.
C) renice 10 -p service.service: renice changes the priority of a running process but is less structured for systemd services, which may spawn multiple processes managed in cgroups. systemctl set-property integrates priority control at the service level.
D) systemctl start service.service: systemctl start simply starts a service. It does not modify its resource allocation or priority.
systemctl set-property service.service CPUWeight=50 is correct because it adjusts the priority of a systemd service using resource controls. nice sets launch priorities, renice modifies processes directly, and systemctl start only initiates services. Mastery of systemctl set-property allows administrators to manage resource allocation effectively, optimize performance for critical services, and maintain system stability under load conditions.
Question 185
Which command is used to permanently modify a user’s shell in Linux?
A) chsh
B) usermod -s
C) passwd
D) su -s
Answer B) usermod -s
Explanation
A) chsh: chsh (change shell) modifies a user’s login shell interactively. It is suitable for individual user changes but is less commonly used in scripts or bulk modifications.
B) usermod -s: usermod -s modifies a user’s login shell permanently at the system account level. For example, usermod -s /bin/bash username changes the shell for the specified user in /etc/passwd. Administrators use usermod -s to enforce shell policies, standardize environments, and manage account configurations programmatically. Mastery of usermod -s includes understanding file formats, system accounts, and compatibility considerations. Proper use ensures consistent shell access, adherence to security policies, and alignment of user environments with organizational standards.
C) passwd: passwd changes a user’s password, not the shell.
D) su -s: su -s allows switching to a user account with a specified shell temporarily. It does not modify the account’s default shell permanently.
usermod -s is correct because it permanently changes the login shell for a user account. chsh modifies it interactively, passwd changes passwords, and su -s temporarily overrides the shell. Mastery of usermod -s allows Linux administrators to standardize user environments, enforce shell policies, and ensure secure and consistent account configurations across systems.
Question 186
Which command is used to display disk usage of a directory and its subdirectories in Linux?
A) du -sh /path/to/dir
B) df -h /path/to/dir
C) ls -lh /path/to/dir
D) stat /path/to/dir
Answer A) du -sh /path/to/dir
Explanation
A) du -sh /path/to/dir: du (disk usage) calculates and displays the size of directories and their contents. The -s flag provides a summary of the total size, and -h makes the output human-readable (KB, MB, GB). Administrators use du to assess storage consumption, identify large directories, and plan disk usage optimization. Mastery of du involves understanding recursive calculations, symbolic link handling, and combining with sorting commands to analyze the largest directories. Proper use ensures efficient storage management, prevents unexpected disk exhaustion, and supports proactive capacity planning. du is also widely used in scripts to automate disk monitoring and reporting, which is critical in enterprise environments with large datasets or complex directory structures.
B) df -h /path/to/dir: df displays filesystem-level usage statistics, including total size, used space, and available space. It reports on the filesystem as a whole, not individual directories, making it less precise for directory-specific analysis.
C) ls -lh /path/to/dir: ls -lh lists files and directories with their sizes in a human-readable format but does not calculate the total size of subdirectories recursively. It is more suited for individual file inspection than aggregate usage.
D) stat /path/to/dir: stat provides metadata for a single file or directory, including size, permissions, and timestamps. It does not calculate the cumulative size of directory contents.
du -sh is correct because it provides a concise, human-readable summary of a directory’s total disk usage. df reports filesystem-level usage, ls lists individual files, and stat shows metadata only. Mastery of du allows Linux administrators to analyze storage usage accurately, identify space-consuming directories, and manage disk resources efficiently, which is crucial for maintaining operational stability and preventing storage-related system issues.
Question 187
Which command is used to display and analyze SELinux booleans in Linux?
A) getsebool -a
B) sestatus
C) setenforce 0
D) semanage fcontext -l
Answer A) getsebool -a
Explanation
A) getsebool -a: getsebool -a displays all SELinux booleans and their current values (on or off). SELinux booleans control optional access rules and behaviors, allowing administrators to fine-tune security policies without modifying the base policy. Mastery of getsebool -a involves understanding which booleans impact services, file contexts, and network access. It allows administrators to audit system security, enable or disable specific features safely, and maintain compliance with security policies. Proper use of getsebool ensures granular control over SELinux enforcement and supports both troubleshooting and operational flexibility.
B) sestatus: sestatus provides general information about SELinux status, mode, policy, and enforcing state but does not list individual boolean values. It is diagnostic rather than configuration-specific.
C) setenforce 0: setenforce 0 temporarily switches SELinux to permissive mode but does not display or modify booleans. It is used for testing or troubleshooting.
D) semanage fcontext -l: semanage fcontext -l lists file context rules and their paths. While useful for understanding file labeling, it does not provide information about SELinux boolean settings.
getsebool -a is correct because it lists all SELinux booleans and their current states. sestatus provides general status, setenforce changes enforcement mode, and semanage fcontext lists file contexts. Mastery of getsebool -a allows Linux administrators to audit SELinux configurations, fine-tune access policies, and enforce security without altering core policies, ensuring system compliance and minimizing security risks.
Question 188
Which command is used to mount a remote NFS filesystem on a Linux client?
A) mount -t nfs server:/export /mnt
B) mount -t cifs //server/share /mnt
C) nfsstat -m
D) showmount -e server
Answer A) mount -t nfs server:/export /mnt
Explanation
A) mount -t nfs server:/export /mnt: mount with -t nfs mounts a remote NFS filesystem to a local directory. For example, mount -t nfs nfsserver:/data /mnt allows access to shared files as if they were local. Administrators use this command to integrate networked storage, support collaborative workflows, and manage distributed filesystems. Mastery of mount -t nfs includes understanding mount options such as rsize, wsize, noexec, and background mounting. Proper use ensures secure, reliable, and performant access to remote filesystems. It is essential in enterprise environments, HPC clusters, or environments with shared storage requirements, enabling centralized data management and seamless access across multiple clients.
B) mount -t cifs //server/share /mnt: mount -t cifs mounts a Windows SMB/CIFS share. While similar in concept, it is specific to Windows network shares and not NFS.
C) nfsstat -m: nfsstat -m displays currently mounted NFS filesystems and their statistics but does not perform the mount operation. It is used for monitoring and troubleshooting only.
D) showmount -e server: showmount -e lists the exported directories on an NFS server. It is used to check available exports but does not mount them.
mount -t nfs server:/export /mnt is correct because it mounts a remote NFS filesystem on a client. mount -t cifs is for Windows shares, nfsstat -m monitors mounts, and showmount -e lists exports. Mastery of mount -t nfs allows Linux administrators to integrate remote storage, manage distributed environments, and ensure reliable access to networked filesystems.
Question 189
Which command is used to modify user account expiration and password aging in Linux?
A) chage
B) passwd
C) usermod -e
D) vipw
Answer A) chage
Explanation
A) chage: chage modifies user account expiration, password aging, and related policies. For example, chage -M 90 username sets a maximum password age of 90 days. Administrators use chage to enforce password rotation policies, comply with security standards, and prevent account misuse. Mastery of chage involves understanding flags for minimum age, maximum age, warning period, and account expiration. Proper use ensures that accounts follow organizational policies, reduces the risk of unauthorized access, and maintains overall system security. It is a critical tool in multi-user environments for proactive account management and regulatory compliance.
B) passwd: passwd changes user passwords interactively but does not control aging or expiration policies.
C) usermod -e: usermod -e sets an account expiration date but does not manage password aging details.
D) vipw: vipw edits the /etc/passwd file safely but does not provide built-in functionality for password aging.
chage is correct because it modifies password aging and account expiration. passwd changes passwords, usermod -e sets expiration only, and vipw edits account files. Mastery of chage allows Linux administrators to enforce secure account policies, manage user lifecycles, and maintain compliance with security standards effectively.
Question 190
Which command is used to display the status of all systemd services in Linux?
A) systemctl list-units –type=service
B) service –status-all
C) systemctl status service_name
D) ps -ef | grep service
Answer A) systemctl list-units –type=service
Explanation
A) systemctl list-units –type=service: This command lists all systemd services and their current states (active, inactive, failed, etc.). Administrators use it to monitor service health, troubleshoot failed units, and maintain operational stability. Mastery of this command involves understanding service states, dependencies, and how units interact with targets. Proper use allows proactive monitoring of critical services, identifying issues early, and ensuring high availability in production environments. It is essential for system administration, especially in environments relying on systemd for service management.
B) service –status-all: This displays the status of services in SysV init style. While functional on legacy systems, it lacks the detail, integration, and consistency provided by systemd.
C) systemctl status service_name: This shows detailed status for a single service but does not list all services. It is useful for targeted troubleshooting but not comprehensive monitoring.
D) ps -ef | grep service: This searches for processes related to a service but does not reflect the formal systemd service status, dependencies, or activation states.
systemctl list-units –type=service is correct because it provides a complete overview of all systemd-managed services and their statuses. service –status-all is legacy, systemctl status is per-service, and ps only shows processes. Mastery of systemctl list-units allows Linux administrators to monitor services, troubleshoot failures, and ensure system reliability in a structured, efficient manner.
Question 191
Which command is used to display kernel messages and system logs in real-time on Linux?
A) dmesg -w
B) journalctl -f
C) tail -f /var/log/messages
D) syslog
Answer B) journalctl -f
Explanation
A) dmesg -w: dmesg -w allows real-time viewing of kernel ring buffer messages, including hardware detection and driver messages. It is highly useful for debugging kernel-level events, boot issues, or hardware-related problems. Mastery involves understanding kernel log levels, interpreting device initialization messages, and filtering output using keywords or facilities. However, dmesg only shows kernel messages and does not integrate with systemd’s structured logs or service-specific logs.
B) journalctl -f: journalctl -f displays systemd-managed logs in real-time, following new entries as they are appended. Administrators use it to monitor system events, service messages, security alerts, and errors across the entire system. Mastery of journalctl includes using filters by unit, priority, boot sessions, or time ranges, providing a flexible and powerful mechanism for troubleshooting and auditing. Proper use ensures administrators can proactively detect failures, analyze service behavior, and maintain system stability. journalctl integrates with persistent storage and structured logging, making it the preferred tool for modern Linux systems over traditional methods.
C) tail -f /var/log/messages: tail -f allows following log files in real-time. While functional, it is limited to specific files, requires knowledge of log locations, and does not support structured queries, filters, or integration with systemd logging. It is manual and less efficient for comprehensive monitoring in modern Linux environments.
D) syslog: syslog is the system logging protocol and daemon that collects messages but does not provide real-time interactive viewing. It is the underlying mechanism for logging, whereas journalctl provides access and filtering capabilities.
journalctl -f is correct because it allows real-time, system-wide log monitoring in a structured, filterable, and integrated manner. dmesg -w only shows kernel messages, tail -f is limited to individual files, and syslog is a logging mechanism, not a viewer. Mastery of journalctl -f enables Linux administrators to maintain system health, troubleshoot issues efficiently, and ensure operational stability in complex environments.
Question 192
Which command is used to identify listening TCP/UDP ports and the associated service in Linux?
A) ss -ltnp
B) netstat -tunap
C) lsof -i -P -n
D) iptables -L
Answer C) lsof -i -P -n
Explanation
A) ss -ltnp: ss -ltnp lists listening TCP sockets and associated processes. It is fast and efficient but primarily focuses on sockets and may require additional filtering for UDP or full protocol analysis.
B) netstat -tunap: netstat -tunap lists TCP and UDP sockets along with the process ID and program name. While functional, it is a legacy tool and lacks modern enhancements and performance compared to ss and lsof.
C) lsof -i -P -n: lsof -i -P -n displays all network connections (TCP/UDP), ports, and the associated processes with numeric ports and addresses. Administrators use it to troubleshoot port conflicts, identify suspicious processes, and monitor active network services. Mastery of lsof -i -P -n involves understanding network layers, process associations, and integrating its output into automated scripts for monitoring or security auditing. Proper use ensures that services are running on expected ports, unauthorized processes are detected, and network resources are managed efficiently. It also allows cross-referencing with firewall rules or monitoring tools for comprehensive network management.
D) iptables -L: iptables -L lists firewall rules, which control packet flow but does not provide information on active ports or listening services. It is for policy enforcement, not service identification.
lsof -i -P -n is correct because it identifies listening ports and the processes using them. ss lists sockets, netstat is legacy, and iptables shows firewall rules. Mastery of lsof -i -P -n allows Linux administrators to maintain network security, troubleshoot service issues, and ensure proper resource allocation for critical services.
Question 193
Which command is used to create a logical volume in Linux using LVM?
A) lvcreate -L 10G -n mylv myvg
B) vgcreate myvg /dev/sdb
C) pvcreate /dev/sdb
D) mkfs.ext4 /dev/myvg/mylv
Answer A) lvcreate -L 10G -n mylv myvg
Explanation
A) lvcreate -L 10G -n mylv myvg: lvcreate creates a logical volume in a specified volume group with a defined size and name. Administrators use it to allocate storage dynamically, manage flexible partitions, and support scalable storage architectures. Mastery involves understanding volume group concepts, logical extents, resizing, snapshots, and integration with filesystems. Proper use ensures efficient storage utilization, allows dynamic allocation without downtime, and supports enterprise storage strategies, such as thin provisioning or multi-tiered storage deployment.
B) vgcreate myvg /dev/sdb: vgcreate creates a volume group from physical volumes. It is a prerequisite step before lvcreate but does not create the logical volume itself.
C) pvcreate /dev/sdb: pvcreate initializes a physical volume for use in LVM. It prepares the disk but does not create the logical volume.
D) mkfs.ext4 /dev/myvg/mylv: mkfs.ext4 formats a logical volume with the ext4 filesystem. It cannot create a logical volume; it only formats an existing LV.
lvcreate -L 10G -n mylv myvg is correct because it creates a logical volume of a specific size within a volume group. vgcreate creates the group, pvcreate initializes the physical volume, and mkfs.ext4 formats the LV. Mastery of lvcreate allows Linux administrators to manage dynamic storage, expand capacity efficiently, and maintain high availability in enterprise environments.
Question 194
Which command is used to enable a systemd service to start automatically at boot?
A) systemctl enable service_name
B) systemctl start service_name
C) chkconfig service_name on
D) update-rc.d service_name defaults
Answer A) systemctl enable service_name
Explanation
A) systemctl enable service_name: systemctl enable configures a systemd service to start automatically at boot. It creates symbolic links in the appropriate target directories. Administrators use it to ensure critical services, such as web servers, databases, or monitoring agents, are active after reboot. Mastery of systemctl enable involves understanding systemd targets, dependencies, and masking/unmasking services. Proper use ensures that essential services remain operational without manual intervention, maintaining system reliability and operational continuity. It is integral to service management in modern Linux systems, replacing legacy init mechanisms.
B) systemctl start service_name: systemctl start initiates a service immediately but does not configure it to start at boot. It is temporary until the next reboot.
C) chkconfig service_name on: chkconfig is used on legacy SysV init systems to configure services to start at boot. It is not used in systemd-based systems.
D) update-rc.d service_name defaults: update-rc.d is another legacy method for configuring service startup in Debian-based SysV init systems. It is not applicable to systemd.
systemctl enable service_name is correct because it configures a service for automatic start at boot under systemd. systemctl start starts the service temporarily, chkconfig and update-rc.d are legacy methods. Mastery of systemctl enable allows Linux administrators to ensure critical services are persistent, maintain system availability, and follow modern service management practices.
Question 195
Which command is used to monitor memory and swap usage in real-time on Linux?
A) free -m
B) vmstat 1
C) top
D) htop
Answer B) vmstat 1
Explanation
A) free -m: free -m provides a snapshot of memory and swap usage in megabytes. While useful for quick checks, it is not real-time and cannot continuously monitor changing memory usage.
B) vmstat 1: vmstat reports virtual memory statistics, including memory, swap, I/O, and CPU usage. The 1 argument refreshes the output every second, providing real-time monitoring. Administrators use vmstat 1 to analyze memory pressure, swap activity, and system performance trends. Mastery of vmstat involves interpreting key columns such as free, buff/cache, si (swap-in), so (swap-out), and CPU utilization metrics. Proper use ensures administrators can detect memory bottlenecks, prevent swapping-induced performance degradation, and plan for memory expansion or tuning. It is essential for performance analysis in servers, high-load systems, and virtualized environments, providing actionable insights for resource management.
C) top: top shows memory usage in real-time along with CPU and processes. It provides per-process detail but is primarily for interactive process monitoring rather than overall memory analytics.
D) htop: htop is similar to top with enhanced interactivity and visualization. While useful, it may not be installed by default and is interactive, making it less suitable for scripting or automated monitoring.
vmstat 1 is correct because it continuously monitors memory, swap, and system performance in real-time. free -m is a snapshot, top/htop are process-focused, and vmstat provides structured performance metrics suitable for analysis. Mastery of vmstat 1 allows Linux administrators to monitor memory trends, prevent resource bottlenecks, and maintain system stability in production environments.
Question 196
Which command is used to create a swap file and enable it on a Linux system?
A) fallocate -l 2G /swapfile && mkswap /swapfile && swapon /swapfile
B) dd if=/dev/zero of=/swapfile bs=1M count=2048 && mkswap /swapfile && swapon /swapfile
C) swapon -a
D) free -h
Answer A) fallocate -l 2G /swapfile && mkswap /swapfile && swapon /swapfile
Explanation
A) fallocate -l 2G /swapfile && mkswap /swapfile && swapon /swapfile: This command sequence creates a swap file of 2 GB using fallocate, initializes it as swap with mkswap, and enables it with swapon. fallocate quickly allocates disk space, avoiding slower methods like dd. Administrators use this approach to extend system virtual memory without repartitioning disks. Mastery involves understanding swap sizing strategies, performance implications, filesystem compatibility, and integration with /etc/fstab for persistence. Proper use ensures efficient memory management, prevents out-of-memory errors, and maintains system responsiveness under heavy load. It is critical for servers, high-performance computing, and virtualized environments where dynamic memory extension is required.
B) dd if=/dev/zero of=/swapfile bs=1M count=2048 && mkswap /swapfile && swapon /swapfile: This older method creates a swap file by writing zeroed bytes with dd. It works reliably but is slower compared to fallocate and can take longer on large files. It demonstrates compatibility but is less efficient for modern systems.
C) swapon -a: swapon -a enables all swap entries defined in /etc/fstab. It does not create a new swap file; it only activates existing ones.
D) free -h: free -h displays memory and swap usage in a human-readable format. It is diagnostic and does not create or activate swap.
The fallocate-based approach is correct because it efficiently creates and activates a swap file. dd works but is slower, swapon -a only activates existing swap, and free -h only monitors memory. Mastery of swap management allows Linux administrators to optimize memory utilization, prevent system crashes, and maintain stability in resource-intensive environments.
Question 197
Which command is used to display detailed inode and filesystem usage in Linux?
A) df -i
B) du -sh
C) ls -i
D) stat
Answer A) df -i
Explanation
A) df -i: df -i displays the number of used and available inodes for filesystems. Inodes represent filesystem objects, and their exhaustion can prevent file creation even if storage is available. Administrators use df -i to monitor inode consumption, detect inode-related capacity issues, and prevent operational failures. Mastery of df -i involves understanding inode allocation, filesystem limits, and integration with alerts or monitoring scripts. Proper use ensures proactive management of high-volume directories, especially in mail servers, web servers, or systems with many small files, where inode depletion is a common problem.
B) du -sh: du -sh displays directory disk usage in a human-readable summary. While useful for space analysis, it does not provide inode information.
C) ls -i: ls -i displays the inode number of individual files but is not suitable for analyzing overall filesystem inode usage or remaining capacity.
D) stat: stat provides metadata for a file, including its inode number, size, permissions, and timestamps. It does not aggregate inode usage for the filesystem.
df -i is correct because it provides filesystem-level inode usage statistics. du -sh calculates disk usage, ls -i shows individual inode numbers, and stat shows metadata for single files. Mastery of df -i enables Linux administrators to prevent inode exhaustion, manage large-scale filesystems, and maintain uninterrupted system operations in high-transaction environments.
Question 198
Which command is used to create a new user account and set the initial home directory in Linux?
A) useradd -m username
B) adduser username
C) passwd username
D) usermod -d /home/username username
Answer A) useradd -m username
Explanation
A) useradd -m username: useradd with the -m flag creates a new user account and automatically creates a home directory. Administrators use it to provision accounts quickly, standardize home directory structures, and enforce system policies. Mastery of useradd involves understanding default shells, UID/GID assignment, password policies, skeleton directories, and integration with LDAP or centralized authentication. Proper use ensures secure, consistent user account creation and efficient management in multi-user systems, enterprise environments, and automation scripts.
B) adduser username: adduser is a higher-level interactive wrapper for useradd found on some distributions (e.g., Debian). It simplifies user creation but is not universal across all Linux distributions.
C) passwd username: passwd sets or changes a password for an existing user account. It does not create the account or home directory.
D) usermod -d /home/username username: usermod -d changes the home directory of an existing user but does not create the account.
useradd -m username is correct because it creates both a new user account and the home directory. adduser is interactive and distribution-specific, passwd sets passwords, and usermod modifies existing accounts. Mastery of useradd ensures consistent account provisioning, secure home directories, and effective user management in automated and enterprise-grade environments.
Question 199
Which command is used to check memory usage, buffer/cache, and swap in Linux in real-time?
A) free -m
B) top
C) vmstat 1
D) sar -r 1
Answer C) vmstat 1
Explanation
A) free -m: free -m displays a snapshot of memory and swap usage in megabytes. It is not continuous and does not provide real-time monitoring or performance trends.
B) top: top displays per-process memory usage and system metrics in real-time. While it is useful for monitoring processes, it focuses on CPU utilization and individual process memory rather than aggregated memory, swap, and cache metrics.
C) vmstat 1: vmstat provides real-time memory usage, buffer/cache statistics, swap activity, and CPU utilization. The 1 argument refreshes the output every second. Administrators use vmstat 1 for memory trend analysis, performance tuning, and detecting swap-induced slowdowns. Mastery involves interpreting key fields such as free memory, buffers, cache, si (swap in), so (swap out), and CPU metrics. Proper use ensures early detection of memory pressure, optimized system performance, and informed resource planning. It is essential for high-load servers, virtualized environments, and production monitoring scripts.
D) sar -r 1: sar -r collects and reports historical memory statistics with specified intervals but may require sysstat to be installed and does not inherently provide real-time interactive monitoring.
vmstat 1 is correct because it continuously monitors memory, swap, and buffer/cache usage. free -m is a snapshot, top focuses on processes, and sar -r is historical. Mastery of vmstat 1 enables proactive memory management, early performance troubleshooting, and optimized system responsiveness.
Question 200
Which command is used to repair a corrupted ext4 filesystem on Linux?
A) fsck.ext4 /dev/sda1
B) e2fsck /dev/sda1
C) mkfs.ext4 /dev/sda1
D) tune2fs -l /dev/sda1
Answer B) e2fsck /dev/sda1
Explanation
A) fsck.ext4 /dev/sda1: fsck.ext4 is a filesystem-specific wrapper for e2fsck, which can repair ext4 filesystems. While functional, administrators often use e2fsck directly for detailed control and reporting.
B) e2fsck /dev/sda1: e2fsck checks and repairs ext2/3/4 filesystems. Administrators use it to detect and fix filesystem inconsistencies, lost inodes, or directory structure corruption. Mastery involves understanding flags like -p (automatic repair), -f (force check), and -n (read-only check). Proper use ensures data integrity, prevents further corruption, and maintains system reliability. It is critical in production environments where filesystem corruption can lead to downtime, data loss, or service interruptions.
C) mkfs.ext4 /dev/sda1: mkfs.ext4 formats a partition with the ext4 filesystem. It destroys existing data and does not repair corruption.
D) tune2fs -l /dev/sda1: tune2fs displays or modifies filesystem parameters, such as mount count or reserved blocks. It does not repair corruption.
e2fsck /dev/sda1 is correct because it checks and repairs ext4 filesystems. fsck.ext4 is a wrapper, mkfs.ext4 formats, and tune2fs only adjusts parameters. Mastery of e2fsck allows Linux administrators to maintain data integrity, recover from corruption, and ensure the stability of critical file systems in enterprise and production environments.
Popular posts
Recent Posts
