010-150 · Question #37
Which of the following commands can be used to determine the time of the last login of a given user?
The correct answer is C. last. The last command reads /var/log/wtmp to display a history of user logins, including timestamps, terminal, and session duration.
Question
Which of the following commands can be used to determine the time of the last login of a given user?
Options
- Ashowlog
- Brecent
- Clast
- Dhistory
- Elogin
How the community answered
(28 responses)- B11% (3)
- C82% (23)
- D4% (1)
- E4% (1)
Why each option
The last command reads /var/log/wtmp to display a history of user logins, including timestamps, terminal, and session duration.
'showlog' is not a standard Linux command.
'recent' is not a standard Linux command for querying login history.
The last command reads from the /var/log/wtmp binary log file and outputs a reverse-chronological history of user logins, logouts, and system reboots. It can be filtered by username (e.g., 'last username') to display login times and durations for a specific user, making it the correct tool for determining the last login of a given user.
history displays the shell command history for the current session, not user login timestamps.
login is used to initiate a new login session interactively, not to query or display past login records.
Concept tested: last command for querying user login history
Source: https://man7.org/linux/man-pages/man1/last.1.html
Topics
Community Discussion
No community discussion yet for this question.