Show only the five most recent login, logout, and reboot records from wtmp.
Which command is appropriate?
last -n 5 reads wtmp history and limits output to five records.
Detailed explanation
who -n 5Incorrect. who shows current sessions, not history.
w -n 5Incorrect. w shows current activity.
lastlog -n 5Incorrect. lastlog focuses on each user's latest login rather than the latest five records overall.
last -n 5Correct. It limits the historical output to five records.
Try it yourself
An example you can run in a temporary verification environment.
last --help 2>&1 | grep -E -- '-n|--limit' | head -n 1Expected result
件数制限に関するhelp行Key points
- last reads wtmp
- -n limits count
- who shows current sessions
Notes
- Environment: util-linux last help / 履歴変更なし
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Permission bit
A mode bit controlling read, write, execute, or special execution behavior.
Account state
Attributes that determine whether a password or login account can be used.
Resource limit
A per-process or per-user ceiling such as open files or process count.