How would you find the default shell for a user?

Prepare for the LPIC-2 Certification Test with our study tools, including flashcards and multiple choice questions with hints and explanations. Get ready to pass your exam!

To determine the default shell for a user, inspecting the /etc/passwd file is a common method. Each line in this file represents a single user and contains several fields separated by colons. The last field of each line specifies the user’s default shell. By using a command like cat /etc/passwd | grep username, you are able to filter the relevant line for the specified user. This line will reveal the default shell set for that user.

Alternatively, getent passwd username could also be considered a valid approach as it retrieves the same user information from the system's user database, which may include entries from various sources, such as NIS or LDAP in addition to the local /etc/passwd file. While both of these methods yield the correct information, the specific choice in the question focuses on the direct text processing of the /etc/passwd file.

Options like usershell username and sh -l username are not standard commands for retrieving a user's default shell and therefore do not serve the requirement of the question. The former option isn’t a recognized command in typical Linux environments, while the latter would attempt to start a shell session for the specified user rather than simply providing the information needed regarding

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy