• Arun Kumar

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.

6 views

Recent Posts

See All

Basic Linux Commands

This article describes basic Linux commands that you must know as a system or database administrator. Below commands in Linux help you manage any Linux server fast and smoothly. Linux Command List Che

Linux Firewall with iptables and firewalld

In this article will be covering details regarding iptables and firewalld which helps in Linux firewall management. We will also be looking at how to enable specific ports (1521 for Oracle) inside ipt

Passwordless SSH in Linux

Every time you ssh from one Linux server to another, you need to enter target server user's password. We can also setup passwordless ssh in Linux between two Linux servers so that you don't have to en

  • Facebook
  • Twitter
  • YouTube
  • Instagram

© 2020 by DBA Genesis