LPI 101-500 LPIC-1 Exam 101 Exam Dumps and Practice Test Questions Set7 Q121-140

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

Question 121:

Which command shows disk usage for directories in a human-readable format?

A) df -h
B) du -sh /path/to/directory
C) lsblk
D) mount

Answer: B) du -sh /path/to/directory

Explanation:

Du -sh summarizes the total size of a directory and converts it to human-readable units. Df -h shows filesystem usage, not individual directories.

In Linux, monitoring disk usage is a critical task for system administration. Administrators often need to determine both how much space a specific directory occupies and the overall usage of entire filesystems. Two commonly used commands for these purposes are du (disk usage) and df (disk free). While they may seem similar at first glance, each serves a distinct purpose, and understanding the difference is essential for effective disk management, troubleshooting, and planning.

The du command provides information about the disk space used by files and directories. Its primary purpose is to summarize the size of a particular directory and all its contents, recursively including subdirectories. When used with the -s (summary) and -h (human-readable) options, as in:

Du -sh /path/to/directory

 

The command outputs the total size of the specified directory in an easy-to-read format, such as KB, MB, or GB. The -s option ensures that only the total for the directory is displayed, without listing each file or subdirectory, which is helpful for quickly assessing space usage. The -h option converts the size from bytes to human-readable units, allowing administrators to interpret large directory sizes quickly without manual conversion.

For example, if a directory /var/log contains numerous log files and subdirectories, running du -sh /var/log might display 1.2G, indicating that all contents of /var/log consume 1.2 gigabytes of disk space. This is especially useful for tracking large directories, monitoring storage growth, and identifying directories that may need cleanup.

In contrast, the df command provides information about disk usage at the filesystem level rather than individual directories. When used with the -h option (df -h), it shows the total size, used space, available space, and percentage of space used for each mounted filesystem in human-readable units. For example, df -h can indicate that the root filesystem / is 50 GB in total, with 35 GB used and 15 GB free. This helps administrators determine if the overall filesystem is reaching capacity, but it does not provide granular information about which directories or files are consuming the space.

The key distinction is that du focuses on directories and files, while df focuses on mounted filesystems. In practice, these commands are often used together. For example, if df -h indicates that a filesystem is nearly full, the administrator can run du -sh on directories within that filesystem to identify which directories are using the most space. This combination enables both broad monitoring and targeted analysis.

Additionally, du can be used with other options to provide more detailed analysis. For instance, du -ah /path lists the size of every file and directory in human-readable units, while du -sh * shows the sizes of all subdirectories in the current directory. This flexibility allows administrators to pinpoint storage issues efficiently.

Question 122:

Which command displays currently mounted filesystems?

A) lsblk
B) mount
C) df -h
D) du -sh

Answer: B) mount

Explanation

 mount lists all currently mounted filesystems and their mount points.

In Linux, the mount command is a fundamental tool for managing filesystems and storage devices. It allows administrators to attach storage devices, partitions, network shares, or virtual filesystems to a specific directory within the existing directory tree. Understanding mounts is crucial for system administration, troubleshooting storage issues, and preparing for exams like the LPIC-1 101.

At its simplest, running the mount command without any arguments lists all currently mounted filesystems and their corresponding mount points, along with additional details such as the filesystem type and mount options. The output typically includes columns for:

Device or source: The storage device, partition, or network share (e.g., /dev/sda1, //server/share) being mounted.

Mount point: The directory in the filesystem where the device is attached (e.g., /, /home, /mnt/data).

Filesystem type: The type of filesystem used, such as ext4, xfs, btrfs, nfs, or vfat.

Mount options: Options specifying how the filesystem is mounted, such as read-only (ro), read-write (rw), user permissions, or special flags for performance and security.

For example, the command:

mount

 

Might produce output like:

/dev/sda1 on / type ext4 (rw,relatime,data=ordered)

/dev/sda2 on /home type ext4 (rw,relatime,data=ordered)

/dev/sdb1 on /mnt/backup type ext4 (rw,relatime)

 

This indicates that /dev/sda1 is mounted as the root filesystem (/), /dev/sda2 is mounted at /home, and an additional device /dev/sdb1 is mounted at /mnt/backup. The rw option shows that these filesystems are mounted with read-write permissions, while relatime and data=ordered are filesystem-specific mount options.

The mount command is also used to mount a new filesystem manually. The general syntax is:

mount -t <filesystem_type> <device> <mount_point> [-o options]

 

For example:

sudo mount -t ext4 /dev/sdc1 /mnt/external

 

This mounts the partition /dev/sdc1 to the directory /mnt/external using the ext4 filesystem type. Administrators can specify mount options like ro for read-only access or noexec to prevent execution of binaries.

Unmounting a filesystem is done with the related umount command, ensuring that all data is properly written to the device before detachment.

Understanding mount is essential for managing storage on Linux systems. It provides administrators with information about which filesystems are currently active, their mount points, and any options affecting access and performance. It is especially important when configuring network shares (NFS or SMB), removable media, or additional partitions. By using mount in combination with /etc/fstab, which defines persistent mount points for devices at boot, administrators can ensure that filesystems are available consistently across reboots.

Question 123:

Which file stores system-wide login definitions like UID/GID ranges and password expiration policies?

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

Answer: C) /etc/login.defs

Explanation:

/etc/login.defs defines defaults for new accounts, password policies, and UID/GID ranges.

In Linux, the management of user accounts and security policies is a critical aspect of system administration. One of the primary configuration files that governs default behaviors for user accounts is /etc/login.defs. This file defines system-wide defaults for account creation, password policies, and UID/GID assignments. Understanding its role and configuration options is essential for maintaining a secure, well-organized Linux environment and is a key topic for the LPIC-1 101 exam.

The /etc/login.defs file is a plain-text configuration file that is read by several user management utilities, including useradd, adduser, and passwd. When a new account is created using useradd, the parameters are specified in /etc/login. defs provide default values for attributes such as password expiration, home directory location, UID (user ID) and GID (group ID) ranges, and more. By standardizing these defaults, administrators can ensure consistency and security across all newly created accounts.

One important set of parameters is in /etc/login. defs relates to password policies. For example:

PASS_MAX_DAYS defines the maximum number of days a password can be used before it must be changed.

PASS_MIN_DAYS specifies the minimum number of days between password changes, preventing users from repeatedly changing passwords to bypass expiration rules.

PASS_WARN_AGE sets the number of days before password expiration when users begin receiving warnings, allowing them to update their passwords in advance.

These parameters enforce security policies and help prevent account compromise due to weak or stale passwords.

Another critical function of /etc/login.defs is controlling UID and GID ranges. Parameters such as UID_MIN, UID_MAX, GID_MIN, and GID_MAX determine the valid range of IDs assigned to new users and groups. This distinction ensures that system accounts and regular user accounts do not conflict, as system accounts typically use lower-numbered IDs (e.g., 0–999), while standard users use higher-numbered IDs (e.g., 1000 and above). Correct configuration of these ranges maintains system stability and prevents privilege escalation issues.

The file also contains other important defaults, such as:

CREATE_HOME – whether a home directory should be automatically created for new users.

UMASK – the default permission mask applied to new files created by users.

ENCRYPT_METHOD – the default encryption method used for passwords (e.g., SHA512).

Because /etc/login.defs is a system-wide configuration file, changes to it affect all future user accounts. It does not modify existing accounts, but administrators can combine it with tools like usermod to adjust attributes for existing users.

In practice, /etc/login.defs is critical for system security and organization. Properly configured defaults reduce administrative overhead, enforce consistent policies, and prevent common security issues related to weak passwords or misassigned IDs.

Question 124:

Which command displays a historical record of logins?

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

Answer: C) last

Explanation:

Last reads /var/log/wtmp to show previous login sessions.

In Linux, monitoring user activity is an essential part of system administration, both for auditing and troubleshooting purposes. One of the primary tools for reviewing historical login activity is the last command. This command provides administrators with a detailed record of previous login sessions by reading data from the system file /var/log/wtmp, which stores information about logins, logouts, system reboots, and shutdowns. Understanding last is crucial for maintaining security, tracking user activity, and performing forensic analysis on Linux systems.

The last command retrieves records from /var/log/wtmp and displays them in reverse chronological order, meaning the most recent sessions are listed first. Each line of the output typically includes several important pieces of information:

Username: The account name of the user who logged in.

TTY or terminal: The terminal or pseudo-terminal used for the session, such as tty1, pts/0, or pts/1.

Host or IP address: If the login occurred via a remote connection (e.g., SSH), the source host or IP is displayed.

Login and logout times: The exact time when the session started and ended.

Duration: How long the user remained logged in.

Session type: Special entries, such as reboot or shutdown, indicate system events rather than user logins.

For example, running last on a server might produce:

john     pts/0        192.168.1.10  Tue Nov 12 09:15 – 11:30  (02:15)  

mary     pts/1        192.168.1.12  Tue Nov 12 08:50 – 09:05  (00:15)  

reboot   system boot  5.15.0-76-generic Tue Nov 12 08:45  

 

This shows that the user John logged in via a remote terminal at 192.168.1.10 for 2 hours and 15 minutes, while Mary had a short 15-minute session. The reboot entry indicates when the system was restarted.

The last command supports several useful options for filtering and formatting output:

Last -n 10 shows only the last 10 login sessions.

Last -a displays the hostname or IP at the far right for better readability.

Last -i includes the IP addresses instead of hostnames, which is useful for remote login tracking.

Last reboot lists only reboot events, helping administrators identify system uptime and restart patterns.

Unlike the who or w commands, which show only current logged-in users, last provides historical context. This makes it invaluable for security audits, detecting unauthorized access, or investigating incidents. For example, if a suspicious login occurs outside normal hours, administrators can identify the source and duration of that session.

Additionally, last can be used in combination with other tools. For example, piping the output to grep allows filtering for specific users or dates, while redirecting output to a file enables archival for long-term auditing purposes.

Question 125:

Which command shows the currently logged-in users with system activity?

A) last
B) w
C) uptime
D) ps aux

Answer: B) w

Explanation:

w shows active users, their terminal, login time, idle time, and current commands.

In Linux, monitoring system activity is a fundamental responsibility of system administrators. One of the key aspects of monitoring involves understanding which users are currently active on the system, what they are doing, and how long they have been idle. The w command is designed precisely for this purpose. It provides a comprehensive overview of logged-in users, their activity, and overall system load, making it a valuable tool for real-time monitoring and performance analysis.

When executed, the w command displays information in two main sections. The first section provides a summary of the system’s status and overall activity, including:

Current time: The system’s current local time.

System uptime: How long the system has been running since the last boot, which is useful for monitoring server reliability.

Number of users: The total number of users currently logged in.

Load averages: The system load averages for the last 1, 5, and 15 minutes. These averages reflect the CPU demand on the system and are critical indicators for system performance.

For example, running w might show:

10:15:23 up 3 days,  4:12,  2 users,  load average: 0.45, 0.32, 0.28

 

This indicates that the system has been running for 3 days and 4 hours, has 2 active users, and the load averages indicate low CPU usage.

The second section lists detailed information for each active user, including several important columns:

USER: The username of the logged-in user.

TTY: The terminal or pseudo-terminal (e.g., pts/0) the user is connected to.

FROM: The host or IP address from which the user is logged in. Local logins may show as :0.

LOGIN@: The exact time the user logged in.

IDLE: The duration for which the user has been inactive. This helps identify idle sessions that may need termination to free resources.

JCPU: The CPU time used by all processes attached to the user’s terminal.

PCPU: The CPU time used by the user’s current foreground process.

WHAT: The command or process the user is currently running.

For example:

USER     TTY      FROM          LOGIN@   IDLE   JCPU   PCPU  WHAT

john     pts/0    192.168.1.10  09:15    2:10   0.05s  0.01s vim /etc/passwd

mary     pts/1    192.168.1.12  08:50    0.00s  0.10s  0.02s top

 

This output shows that John is editing a file with Vim and has been idle for 2 minutes and 10 seconds, whereas Mary is actively monitoring processes with top.

The w command is particularly useful in multi-user environments or servers accessed via SSH, as it allows administrators to:

Quickly see who is logged in.

Identify resource-intensive processes associated with specific users.

Detect idle or abandoned sessions that may be consuming system resources unnecessarily.

Monitor overall system performance in conjunction with load averages.

Unlike the one who commands, which only lists active users and their terminals, w provides detailed information about what users are doing and their system resource consumption. This makes it an essential tool for real-time monitoring, auditing, and troubleshooting in Linux systems.

Question 126:

What is the difference between tail -f file.log and tail -n 50 -f file.log?

A) There is no difference
B) The latter shows the last 50 lines and follows updates
C) The former shows only the first 10 lines
D) The latter ignores new lines

Answer: B) The latter shows the last 50 lines and follows updates

Explanation:

Adding -n 50 shows the last 50 lines initially, then continues to follow appended lines.

In Linux, monitoring log files and ongoing output from processes is a common task for system administrators. One of the most powerful and widely used tools for this purpose is the tail command. The tail command, by default, displays the last 10 lines of a file, but it offers a variety of options to customize its behavior. One particularly important use case is monitoring the end of a file in real-time, which is accomplished using the -f option.

The -f option, short for “follow,” tells tail to keep the file open and display new lines as they are added. This is especially useful for monitoring log files such as /var/log/syslog, /var/log/messages, or application-specific logs. For example, running:

Tail -f /var/log/syslog

 

Will continuously display new log entries as they are appended to syslog. This allows administrators to watch system activity in real-time, detect errors as they occur, and troubleshoot issues interactively.

Adding the -n option allows you to specify how many lines from the end of the file should be displayed initially. For instance:

Tail -n 50 -f /var/log/syslog

 

This command combines the -n 50 and -f options. Here’s what happens:

-n 50 instructs tail to first display the last 50 lines of the file. This gives context, showing the most recent activity before starting to follow new lines.

-f then continues to monitor the file, printing any new lines as they are written. This ensures that administrators do not miss any recent entries and can see the ongoing output in real-time.

The combination of -n and -f is particularly useful when working with large log files, where reviewing the last few entries is more practical than scrolling through the entire file. For example, in a busy web server, /var/log/apache2/access.log might contain millions of lines. Using tail -n 50 -f allows you to quickly focus on the most recent 50 requests and continue monitoring live traffic without overwhelming the terminal.

There are additional options to enhance monitoring. For example, tail -F is similar to -f, but it reopens the file if it is rotated or replaced, which is common for log rotation practices. Piping tail -n 50 -f into grep allows administrators to filter for specific keywords, errors, or user activities while continuously monitoring the file.

In practice, tail -n 50 -f is an indispensable tool for system administration. It allows real-time tracking of system logs, application output, and troubleshooting processes. By initially showing the last 50 lines, it provides immediate context, while the follow mode ensures that administrators stay updated with ongoing changes without manual intervention.

Question 127:

Which command shows groups for the current user?

A) groups
B) getent group
C) cat /etc/group
D) id

Answer: A) groups

Explanation:

Displays the groups the current user belongs to. getent group lists all system and NSS groups.

In Linux systems, managing users and groups is a core responsibility of administrators, and commands such as groups, getent group, cat /etc/group, and id are essential tools for verifying user and group information, checking access permissions, and ensuring proper system security. Option A, groups, is a simple and efficient command that displays all the groups to which a user belongs. When executed without arguments, it shows the groups associated with the currently logged-in user, and when provided with a username, such as groups john, it lists all the groups for that user. For example, the output john: john sudo developers indicates that the user “john” is a member of the groups “john,” “sudo,” and “developers,” which is particularly useful for quickly verifying whether a user has administrative privileges or access to shared resources. Option B, getent group, offers a more comprehensive approach by retrieving group information from multiple sources, including the local /etc/group file, as well as external directories like LDAP or NIS if configured in /etc/nsswitch.conf. This ensures that administrators can see all group data in environments where accounts are centrally managed across multiple systems. For example, running getent group developers will display the developers group along with all its members, regardless of whether the group is stored locally or on a network directory, making it a critical tool in enterprise settings for consistent group management. Option C, cat /etc/group, provides a direct view of the system’s local group database, which lists all defined groups, their group IDs (GIDs), and associated members. Each line in /etc/group has the format group_name:x:GID:user_list, where x is a placeholder for a password, GID is the numeric group ID, and user_list is a comma-separated list of members. For instance, sudo:x:27:john,fatima indicates that the “sudo” group has GID 27 and includes users “john” and “fatima.” Using cat gives administrators immediate access to all locally defined groups, making it useful for auditing permissions or troubleshooting access issues on a single system, though it does not include groups managed through network services. Option D, id, provides a detailed overview of a user’s identity and group memberships, including the numeric user ID (UID), primary group ID (GID), and all supplementary groups with both numeric IDs and human-readable names. For example, id john may output uid=1001(john) gid=1001(john) groups=1001(john),27(sudo),1002(developers), giving a clear understanding of the user’s effective permissions and access rights. This command is particularly valuable for verifying that group changes, such as adding a user to a new group via usermod, have been applied correctly. Together, these four commands form a comprehensive toolkit for Linux group management: groups provides a quick overview of a user’s memberships, getent group ensures complete information across local and network sources, cat /etc/group allows direct inspection of the local group database, and id confirms detailed identity and group information for troubleshooting and auditing. By mastering these commands, administrators can efficiently manage user access, enforce permissions, and maintain security across both single-system and multi-user network environments.

Question 128:

Which file controls which users can run commands via sudo?

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

Answer: B) /etc/sudoers

Explanation:

Defines permissions for passwordless or restricted sudo command execution. In Linux system administration, several key configuration files play critical roles in managing user accounts, groups, privileges, and authentication policies, and understanding the functions of /etc/passwd, /etc/sudoers, /etc/group, and /etc/login.defs is essential for maintaining a secure and organized system. Option A, /etc/passwd, is the fundamental file that stores basic information about user accounts, such as the username, user ID (UID), primary group ID (GID), user description, home directory, and login shell. Each line in /etc/passwd represents a single user in the format username:x:UID:GID:comment:home_directory: shell, where the x indicates that the encrypted password is stored securely in /etc/shadow rather than in this file. For example, an entry like john:x:1001:1001:John Doe:/home/john:/bin/bash defines a user named “john” with UID 1001, primary GID 1001, home directory /home/john, and Bash as the default shell. This file is readable by all users, allowing basic identification and mapping of user IDs to usernames while keeping sensitive password data protected. Option B, /etc/sudoers, is a critical file that controls administrative privileges and sudo access. It defines which users or groups can execute commands with elevated privileges using sudo and specifies any restrictions, command aliases, or run-as user configurations. For example, an entry like john ALL=(ALL: ALL) ALL allows the user “john” to run any command as any user on the system, while group-based entries such as %sudo ALL=(ALL: ALL) ALL grant all members of the sudo group similar privileges. This file is typically edited using visudo to prevent syntax errors that could compromise system security. Option C, /etc/group, manages group information, organizing users into groups to simplify access control and permission management. Each line contains the group name, a placeholder for the password, the group ID (GID), and a list of users belonging to the group, formatted as group_name:x:GID:user_list. For instance, developers:x:1002:john,fatima indicates that the “developers” group has GID 1002 and includes the users “john” and “fatima.” Groups are essential for assigning shared permissions to files, directories, and system resources without modifying individual user accounts, enabling efficient management of collaborative environments. Option D, /etc/login.defs, defines system-wide default settings for user account creation and password policies, including UID and GID ranges for normal and system users, password expiration settings, and login restrictions. This file ensures consistency when creating users with commands like useradd and enforces security policies such as minimum password length, maximum password age, and default home directory locations. Together, these four files provide a comprehensive framework for Linux user and privilege management: /etc/passwd stores the core account data, /etc/group organizes users for permission management, /etc/sudoers controls administrative access, and /etc/login. defs enforces system-wide defaults and security policies. Mastery of these files allows administrators to securely create and manage users, assign appropriate privileges, audit system access, and maintain a consistent, secure multi-user environment, which is essential for both small-scale and enterprise Linux systems.

Question 129:

Which command changes file ownership to a specific user?

A) chmod
B) chown
C) chgrp
D) usermod

Answer: B) chown

Explanation

 chown user file changes the file’s owner. chgrp changes the group, chmod changes permissions. In Linux system administration, managing file and directory permissions, ownership, and user attributes is essential for maintaining system security and proper access control, and commands such as chmod, chown, chgrp, and usermod are key tools for achieving these tasks. Option A, chmod, is used to change the permissions of files and directories, allowing administrators to control who can read, write, or execute a file. Permissions can be set numerically or symbolically, and applying the correct permissions is critical for securing sensitive data. For example, running chmod 750 /var/www/html grants read, write, and execute permissions to the owner, read and execute permissions to the group, and no access to others. Recursive usage with chmod -R allows administrators to apply permissions to all files and subdirectories within a directory, ensuring consistent access policies across a project or directory tree. Option B, chown, is used to change the ownership of files and directories, allowing the assignment of a new user and, optionally, a new group as the owner. For instance, chown john: developers /var/www/html changes the owner to “john” and the group to “developers,” giving proper control to the designated user and associated group. Like chmod, the -R option enables recursive changes, which is particularly useful when migrating project directories or correcting ownership issues after copying files between systems. Option C, chgrp, specifically changes the group ownership of a file or directory without modifying the user ownership. For example, chgrp developers /var/www/html assigns the “developers” group to the directory while keeping the existing user owner intact. This command is useful when the ownership of the user does not need to change, but the file should be accessible to a different group, enabling controlled collaboration among team members or departments. Finally, Option D, usermod, complements file and group management by allowing administrators to modify user attributes, including group memberships, home directories, login shells, and other account-related settings. For example, usermod –aG developers john adds the user “john” to the “developers” group without removing him from existing groups, enabling appropriate permissions to files assigned to that group. usermod ensures that user access and privileges are aligned with organizational policies and can adapt as roles change over time. Together, these four commands provide a complete framework for managing both file-level access and user account configuration: chmod controls what users can do with files, chown sets the owner of files and directories, chgrp manages group ownership, and usermod adjusts user attributes and group memberships to maintain proper access control. By mastering these tools, Linux administrators can enforce security, ensure collaboration within groups, and maintain a well-organized and controlled file system, preventing unauthorized access and preserving system integrity across both small-scale and enterprise environments.

Question 130:

Which command changes only the group of a file?

A) chown
B) chgrp
C) chmod
D) usermod

Answer: B) chgrp

Explanation:

Updates group ownership without altering the file’s user owner.

In Linux system administration, controlling file and directory access, ownership, and user permissions is a critical part of maintaining system security and operational efficiency, and commands such as chown, chgrp, chmod, and usermod play central roles in these tasks. Option A, chown, is primarily used to change the ownership of a file or directory, allowing administrators to assign a new user as the owner, and optionally a new group. For example, executing chown john: developers /var/www/html sets “john” as the owner and “developers” as the group of the /var/www/html directory. This command is crucial when transferring ownership of files between users or managing access in collaborative environments, ensuring that only the designated user or group has the appropriate control. The -R option can be applied to recursively change ownership across a directory and all its contents, which is particularly useful when dealing with large project directories. Option B, chgrp, is specifically designed to modify the group ownership of a file or directory without affecting the user ownership. For instance, running chgrp developers /var/www/html assigns the “developers” group to the directory while keeping the original user owner intact. This allows administrators to grant group-based access to resources without altering the individual ownership, enabling team collaboration and consistent access permissions for members of the same group. Option C, chmod, is used to change file and directory permissions, controlling who can read, write, or execute a given file. Permissions can be set numerically or symbolically, and the command ensures that sensitive files are protected while allowing legitimate users appropriate access. For example, chmod 750 /var/www/html grants full access to the owner, read and execute access to the group, and no access to others. Recursive usage with chmod -R can propagate these permissions to all files and subdirectories within a directory, ensuring consistent security policies across an entire project. Finally, Option D, usermod, complements file and group management by allowing administrators to modify user accounts, including adding or removing users from groups, changing login shells, or updating home directories. For example, usermod-aGG developer John adds “John” to the “developers” group without removing him from any existing groups, granting him access to files and directories owned by that group. This command is essential for aligning user privileges with organizational roles and evolving responsibilities. Together, these four commands provide a comprehensive framework for managing Linux system security: chown establishes file ownership, chgrp manages group ownership, chmod enforces access permissions, and usermod ensures that user accounts have appropriate group memberships and privileges. Mastery of these tools allows administrators to maintain strict access control, prevent unauthorized access, and efficiently manage collaborative environments, ensuring the integrity and security of both individual files and the system as a whole, whether in small-scale servers or enterprise-level Linux deployments.

Question 131:

Which command changes file permissions?

A) chmod
B) chown
C) chgrp
D) usermod

Answer: A) chmod

Explanation:

chmod modifies read, write, and execute permissions for user, group, and others.

In Linux system administration, controlling file permissions, ownership, and user access is a fundamental aspect of maintaining system security and ensuring proper resource management, and commands such as chmod, chown, chgrp, and usermod provide administrators with the tools to manage these elements effectively. Option A, chmod, is used to change the permissions of files and directories, determining who can read, write, or execute a particular file. Permissions can be applied numerically or symbolically, and this command is essential for protecting sensitive data while allowing legitimate access. For example, chmod 750 /var/www/html grants full access to the owner, read and execute access to the group, and no access to others. The -R flag can be added to recursively apply permissions to all files and subdirectories within a directory, ensuring consistent security policies across an entire project. Option B, chown, is employed to change the ownership of files and directories, allowing administrators to assign a specific user as the owner and, optionally, a new group. For instance, chown john: developers /var/www/html sets “john” as the owner and “developers” as the group, giving appropriate control over the directory to the designated user and group. Recursive application with the -R option ensures that all contents of a directory are transferred correctly when moving projects or correcting ownership inconsistencies. Option C, chgrp, specifically allows administrators to modify the group ownership of files and directories without changing the user ownership. By executing chgrp developers /var/www/html, the group is updated to “developers” while the original owner remains the same. This is particularly useful when granting shared access to a team or department without affecting individual ownership, allowing group-based permission management and facilitating collaborative work environments. Option D, usermod, complements file and group management by enabling administrators to modify user accounts and their attributes, including login shells, home directories, and group memberships. For example, usermod –aG developers john adds the user “john” to the “developers” group without removing him from existing groups, granting him the necessary permissions to access files and directories associated with that group. This ensures that user privileges align with organizational roles and responsibilities, enabling administrators to adapt access as user roles change over time. Together, these four commands form a cohesive framework for Linux system security and user management: chmod enforces access control by defining what users and groups can do with files, chown assigns proper ownership to users and groups, chgrp manages group-specific ownership, and usermod updates user attributes and group memberships to reflect evolving responsibilities. Mastering these tools allows administrators to maintain strict access control, prevent unauthorized access, and efficiently manage collaborative environments, ensuring the integrity, security, and proper organization of both files and users across single systems or enterprise-level Linux environments.

Question 132:

Which command modifies an existing user account’s attributes?

A) useradd
B) usermod
C) passwd
D) groupadd

Answer: B) usermod

Explanation:

Allows changing login shell, home directory, or group memberships for existing users.

In Linux system administration, managing users and groups is a core responsibility, and commands such as useradd, usermod, passwd, and groupadd form the foundation for creating, configuring, and securing accounts. Option A, useradd, is the primary command for creating new user accounts. It allows administrators to specify essential attributes such as the home directory, default shell, user ID (UID), and initial group membership. For example, useradd -m -s /bin/bash john creates a user named “john,” sets up a home directory at /home/john, and assigns Bash as the default shell. The -m option ensures that the home directory is created automatically, providing a personal workspace for the user, while the -s option defines which shell the user will use upon login. After creating the user, it is typically necessary to set a password, which brings Option C, passwd, into play. The passwd command sets or changes a user’s password, updating the encrypted password stored in /etc/shadow. For instance, executing passwd john prompts the administrator to enter a secure password for the user “john,” which is essential for enabling authentication and protecting the account against unauthorized access. passwd can also enforce security policies such as password expiration, inactivity periods, and account locking, which are critical for maintaining system security in multi-user environments. Option B, usermod, is used to modify existing user accounts without recreating them. It allows administrators to change attributes like login shells, home directories, user IDs, and group memberships. For example, usermod –aG sudo john adds the user “john” to the sudo group without removing him from any existing groups, granting administrative privileges while preserving previous group memberships. Similarly, usermod -d /home/newjohn john changes the user’s home directory, providing flexibility in managing accounts as organizational roles evolve. Option D, groupadd, is used to create new groups, which are essential for managing shared access to files and directories. For example, groupadd developers creates a group named “developers” with a unique group ID (GID), and users can later be added to this group using usermod-GG developers username. Groups simplify permission management by allowing administrators to assign rights collectively rather than individually, enabling collaborative work while maintaining security. Together, these four commands provide a complete toolkit for Linux user and group management: useradd creates accounts, passwd secures them with passwords, usermod modifies account attributes and group memberships, and groupadd organizes users into logical groups for access control. Mastery of these commands allows administrators to efficiently manage user privileges, enforce security policies, and maintain a well-organized multi-user environment, ensuring both operational efficiency and system integrity across single-server setups and large-scale enterprise environments.

Question 133:

What does useradd -m -s /bin/bash john do?

A) Creates a user without a home directory
B) Creates a user John with a home directory and a Bash shell
C) Sets a password for John
D) Modifies an existing user

Answer: B) Creates a user John with a home directory and a Bash shell

Explanation:

-m creates a home directory, -s specifies the login shell.

Question 134:

Which command assigns or updates a user’s password?

A) passwd
B) useradd
C) usermod
D) chown

Answer: A) passwd

Explanation:

Updates the hashed password in /etc/shadow for an existing account.

Question 135:

Which command displays block devices and their mount points in a tree view?

A) df -h
B) lsblk
C) mount
D) du -sh

Answer: B) lsblk

Explanation:

Shows storage devices, partitions, and mount points in a hierarchical structure.

Question 136:

Which command shows mounted filesystem usage in human-readable units?

A) df -h
B) lsblk
C) du -sh
D) mount

Answer: A) df -h

Explanation:

Displays disk usage statistics of mounted filesystems in KB, MB, GB.

Question 137:

Which file contains encrypted passwords and password aging info?

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

Answer: B) /etc/shadow

Explanation:

Stores password hashes, last change date, and expiration policies securely.

Question 138:

Which command shows memory usage totals in human-readable format?

A) vmstat
B) free -h
C) top
D) uptime

Answer: B) free -h

Explanation:

Free -h displays RAM and swap usage in KB, MB, or GB.

Question 139:

Which command provides a static snapshot of running processes?

A) top
B) ps aux
C) uptime
D) last

Answer: B) ps aux

Explanation:

Shows all processes at the moment of execution; it does not update in real time.

Question 140:

Which command monitors processes in real-time and allows interactive control?

A) ps aux
B) top
C) uptime
D) last

Answer: B) top

Explanation:

Provides a continuously updating, interactive view of processes, CPU, and memory usage.

Leave a Reply

How It Works

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