nixCraft Linux Forum

nixCraft

Linux / UNIX Tech Support Forum

Shell script To find out who have account but are not logged in

This is a discussion on Shell script To find out who have account but are not logged in within the Shell scripting forums, part of the Development/Scripting category; Hi i want to know how you can find total number of users who have anaccount but are not logged ...


Go Back   nixCraft Linux Forum > Development/Scripting > Shell scripting

Linux answers from nixCraft.


Shell scripting You can discuss the shell scripting, request shell scripts and scripting techniques

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 18-03-2009, 11:55 PM
Junior Member
User
 
Join Date: Mar 2009
OS: Debian
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
gsb1bee is on a distinguished road
Question Shell script To find out who have account but are not logged in

Hi i want to know how you can find total number of users who have anaccount but are not logged in?
Reply With Quote
  #2 (permalink)  
Old 19-03-2009, 12:26 AM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
OS: RHEL
Scripting language: Bash and Python
Posts: 2,707
Thanks: 11
Thanked 244 Times in 183 Posts
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

Have you tried out last command? It will show listing of last logged in users in system. Using last and entries from /etc/passwd you should able to come with something.
__________________
Vivek Gite
Linux Evangelist
Be proud RHEL user, and let the world know about your enterprise choices! Join RedHat user group.
Always use CODE tags for posting system output and commands!
Do you run a Linux? Let's face it, you need help
Reply With Quote
  #3 (permalink)  
Old 19-03-2009, 10:29 PM
Junior Member
User
 
Join Date: Mar 2009
OS: Debian
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
gsb1bee is on a distinguished road
Default

Hi, thnx for replying but how should i organize to make it work. i have done it the way u said cat /etc/passwd | wc -l | awk -F: '{print $1}'
but still im unsure it is right or not

btw can u give me the code for user who have an account but not logged on?
Reply With Quote
  #4 (permalink)  
Old 20-03-2009, 07:22 PM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
OS: RHEL
Scripting language: Bash and Python
Posts: 2,707
Thanks: 11
Thanked 244 Times in 183 Posts
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

Use the following command to get list of regular users:
Code:
export UGIDLIMIT=500
awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534) { print $1}' /etc/passwd
Once you got list compare username with output of last using for loop and if commands as follows:

Code:
#!/bin/bash
export UGIDLIMIT=500
ALLUSER=$(awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534) { print $1}' /etc/passwd)
for u in $ALLUSER
do
    lastlog -u $u | grep 'Never'
done
__________________
Vivek Gite
Linux Evangelist
Be proud RHEL user, and let the world know about your enterprise choices! Join RedHat user group.
Always use CODE tags for posting system output and commands!
Do you run a Linux? Let's face it, you need help
Reply With Quote
  #5 (permalink)  
Old 21-03-2009, 06:30 PM
Junior Member
User
 
Join Date: Mar 2009
OS: Debian
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
gsb1bee is on a distinguished road
Default

heyy hii thanx al lot it worked . can u explain me in full reason how did u work out that command.

and btw can u find how to chk the current status OF NIC?

whts the best way to practise shell scripting
Reply With Quote
Reply

Tags
/etc/passwd , for loop , lastlog , shell script , shell scripting


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
Solaris UNIX Script to Find Users who has logged in for past 30 Days GSRaj Solaris/OpenSolaris 0 05-02-2009 12:59 AM
writing a shell script to find out my shell name jaymob123 Shell scripting 1 08-10-2007 12:36 AM
Alphabetical file name and list logged in user script oronno Shell scripting 5 22-08-2007 12:10 PM
How to get free shell Linux and UNIX account for friends jerry Shell scripting 0 09-06-2007 01:57 AM
shell script for finding users not logged on for last 10 day ganes Shell scripting 4 06-07-2005 11:01 AM


All times are GMT +5.5. The time now is 06:59 PM.


Powered by vBulletin® Version 3.8.5 - Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2
©2005-2010 nixCraft. All rights reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38