Introduction
The Linux command ‘last’ is a powerful tool used to view information about the last logged in users on a Linux system. It can be used to view the login history of a user, the last time a user logged in, and the duration of the user’s session. It can also be used to view the last reboot of the system, and the last shutdown of the system. This command is useful for system administrators to monitor user activity on the system.
Examples
shutdown
The shutdown command is used to shut down or reboot a Linux system. It can be used to shut down the system immediately or at a specific time.
Syntax: shutdown [OPTION] [TIME] [MESSAGE]
Options:
-h: Shut down the system
-r: Reboot the system
-c: Cancel a pending shutdown
-k: Don’t really shut down, just send the warning message
Examples:
shutdown -h now: Shut down the system immediately
shutdown -r +5 “System update in progress”: Reboot the system in 5 minutes with the message “System update in progress”
The Last Linux Command
The last Linux command is a useful tool for displaying the last lines of a file or output from a command. It is commonly used to view the last few lines of a log file, to see recent system activity, or to view the output of a command. The last command can be used to view the last few logins of a user, the last few system reboots, or the last few commands that were executed.
The syntax for the last command is as follows:
last [options] [username]
The options can be used to specify the number of lines to display, the time period to display, or the type of output to display. The username option can be used to display the last logins of a specific user.
For example, to view the last 10 logins of the user “john”, the command would be:
last -10 john
The output of the command would be a list of the last 10 logins of the user “john”.
The last command is a useful tool for viewing recent system activity or the output of a command. It can be used to view the last few logins of a user, the last few system reboots, or the last few commands that were executed.