top of page
Shell Script to Check User Logins
Linux shell script allows us to create the script to check for the login details of any user. To achieve this we will be using the last command. The last is a command-line utility that displays information about the last login sessions of the system users.
vi user_login_check.sh
# !/bin/bash
echo "Enter the USER NAME : "
read user
last $user
Here is the sample output of the above script
More ways to use the last command.
You can to print only the last ten login sessions
You can also use the -p (--present) option to find out who logged into the system on a specific date.
bottom of page