The last command in Linux is used to display the list of all the users logged in and out since the file /var/log/wtmp was created1. The output of the last command shows the username, the terminal, the IP address, the login time and date, and the duration of the session for each record2. The option E is the only one that matches this format. Theother options are not related to the last command. Option A shows a list of commands executed by a user. Option B shows the password change information for a user. Option C shows the last login information for a user. Option D shows the mount information for a filesystem. References:
Linux Essentials Version 1.6 Objectives3, Topic 1.4: Command Line Basics, Subtopic: Basic Shell Commands
Linux last Command Tutorial for Beginners (8 Examples)4
Linux Essentials Version 1.6 Exam Preparation Guide, Section 1.4: Command Line Basics, Page 16
Questions 5
What parameter of ls prints a recursive listing of a directory's content? (Specify ONLY the option name without any values or parameters.)
The -R parameter of the ls command prints a recursive listing of a directory’s content, meaning that it will list not only the files and directories in the current directory, but also the files and directories in all the subdirectories12. For example, if you have a directory structure like this:
You can use the command ls -R /home/user/ to list all the files and directories recursively, and the output will look like this:
/home/user/: dir1 dir2
/home/user/dir1: file1 file2
/home/user/dir2: file3 file4
The -R parameter is also known as the --recursive option, which is the long form of the same parameter12. You can use either -R or --recursive to achieve the same result.
References:
Use ls Command Recursively - Linux Handbook
How to List Files Recursively in Linux command line
Questions 6
Which of the following statements regarding Linux hardware drivers is correct?
Options:
A.
Drivers are regular Linux programs which have to be run by the user who wants to use a device.
B.
Drivers are not used by Linux because the BIOS handles all access to hardware on behalf of Linux.
C.
Drivers are stored on their devices and are copied by the Linux kernel when a new device is attached
D.
Drivers are downloaded from the vendor's driver repository when a new device is attached.
E.
Drivers are either compiled into the Linux kernel or are loaded as kernel modules.
Linux hardware drivers are software components that enable the Linux kernel to communicate with various devices, such as keyboards, mice, printers, scanners, network cards, etc. Drivers are either compiled into the Linux kernel or are loaded as kernel modules. Kernel modules are pieces of code that can be loaded and unloaded into the kernelon demand. They extend the functionality of the kernel without requiring to rebuild or reboot the system. Drivers that are compiled into the kernel are always available, but they increase the size and complexity of the kernel. Drivers that are loaded as kernel modules are only available when needed, but they require a matching version of the kernel and the module. Linux supports a large number of hardware devices, thanks to the efforts of the open source community and some vendors who provide drivers for their products. However, some devices may not have a driver available for Linux, or may require a proprietary driver that is not included in the Linux distribution. In such cases, the user may need to install the driver manually from the vendor’s website or from a third-party repository. References:
Linux Essentials - Linux Professional Institute (LPI), section 2.2.1
LPI Linux Essentials Study Guide: Exam 010 v1.6, 3rd Edition, chapter 3, page 67.
Questions 7
What information is stored in/etc/passwd? (Choose three correct answers.)
The /etc/passwd file is a plain text-based database that contains information for all user accounts on the system. It is owned by root and has 644 permissions. The file can only be modified by root or users with sudo privileges and readable by all system users. Each line of the /etc/passwd file contains seven comma-separated fields, representing a user account. The fields are as follows:
Username: The string you type when you log into the system. Each username must be a unique string on the machine. The maximum length of the username is restricted to 32 characters.
Password: In older Linux systems, the user’s encrypted password was stored in the /etc/passwd file. On most modern systems, this field is set to x, and the user password is stored in the /etc/shadow file.
User ID (UID): The user identifier is a number assigned to each user by the operating system to refer to a user. It is used by the kernel to check for the user privileges and grant access to system resources. The UID 0 is reserved for the root user and cannot be assigned to any other user.
Group ID (GID): The user’s group identifier number, referring to the user’s primary group. When a user creates a file, the file’s group is set to this group. Typically, the name of the group is the same as the name of the user. User’s secondary groups are listed in the /etc/group file.
User ID Info (GECOS): This is a comment field. This field contains a list of comma-separated values with the following information: User’s full name or the application name, Room number, Work phone number, Home phone number, Other contact information.
Home directory: The absolute path to the user’s home directory. It contains the user’s files and configurations. By default, the user home directories are named after the name of the user and created under the /home directory.
Login shell: The absolute path to the user’s login shell. This is the shell that is started when the user logs into the system. On most Linux distributions, the default login shell is Bash.
Therefore, the correct answers are B, C, and E. The user’s storage space limit (A) is not stored in the /etc/passwd file, but in the /etc/quota file. The encrypted password (D) is not stored in the /etc/passwd file, but in the /etc/shadow file. References:
Linux Essentials Topic 104: The Linux Operating System, section 104.4: Runlevels and Boot Targets.
Linux Essentials Topic 106: Security and File Permissions, section 106.1: Basic security and identifying user types.
Linux Essentials Topic 106: Security and File Permissions, section 106.2: Creating users and groups.
Understanding the /etc/passwd File | Linuxize
Understanding the /etc/passwd File - GeeksforGeeks
passwd(5) - Linux manual page - man7.org
Understanding /etc/passwd file in Linux - DEV Community