cancel
Showing results for 
Search instead for 
Did you mean: 

Find the user not login

ivy1234
Frequent Advisor

Find the user not login

In my system , there are 800 users in it , can advise if I want to find the user(s) who do not have login to the sytem over 180 days ( in the past 180days ) , what is the best way ? thx
8 REPLIES
Kapil Jha
Honored Contributor

Re: Find the user not login

Is it truested system or normal.
Well there are a couple of ways the simples may be to check wtmp file

#last|awk '{print $1}'|sort|uniq

it would show u all the users logged in, check if you have login data for 180 days.

BR,
Kapil+
I am in this small bowl, I wane see the real world......
Suraj K Sankari
Honored Contributor

Re: Find the user not login

Hi,
use "last" command to find out the same.

The last command searches backwards through the file /var/adm/wtmp (which contains a record of all logins and logouts) for information about a user, a tty, or any group of users and ttys.

Suraj
ivy1234
Frequent Advisor

Re: Find the user not login

hi Kapil Jha ,

I tried your method , but it only show the user list , can advise how to use the command ? thx
Kapil Jha
Honored Contributor

Re: Find the user not login

It would show the user list which have logged in since the day your wtmp file started to log.
Rest of the user in etc passwd have not logged in for X days :)

to make it easy do
#cat /etc/passwd|awk '{print $1}'|sort
and #last .......

the difference is the user who have not logged for X days
X is the number of days your wtmp file is looging.

BR,
Kapil+

I am in this small bowl, I wane see the real world......
ivy1234
Frequent Advisor

Re: Find the user not login

hi Kapil Jha ,

sorry to my fool , i still not understand how to use it , when i use the command you provide , do I need to add parameter ? thx
ivy1234
Frequent Advisor

Re: Find the user not login


yes , I know the wtmp and last may check it , but I don't prefer to run the same command for 800 times , can advise what is the simplest way to check it ? thx
Kapil Jha
Honored Contributor

Re: Find the user not login

lets be very simple :)

run
#cat /etc/passwd|awk '{print $1}'|sort

put all 800 users in XL file

run
# last|awk '{print $1}'|sort|uniq
Put whatever come in the XL sheet.

Compare.

The user which are in 2nd output have logged in recently to the server
the users which are not in 2nd out and there in first output are the user who have not logged in.

BR,
Kapil+
I am in this small bowl, I wane see the real world......
singh sanjeev
Trusted Contributor

Re: Find the user not login

or you can run ,if your system is trusted system

/usr/lbin/getprpw

check for or cut the last successfull field when last time user enter the system ,here even you can check the status of the user account .
Sanjeev Singh