Linux / UNIX Tech Support Forum
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 ...
|
|||||||
| Shell scripting You can discuss the shell scripting, request shell scripts and scripting techniques |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Hi i want to know how you can find total number of users who have anaccount but are not logged in?
|
| Sponsored Links | ||
|
|
|
||||
|
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 |
|
|||
|
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?
|
|
||||
|
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
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 |
|
|||
|
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
|
![]() |
| 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 | |
|
|
|
||||
| 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 |