LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 10-02-2003, 01:56 PM   #1
cparker15
Member
 
Registered: Jan 2003
Location: Malden, MA
Distribution: Debian, FreeBSD, gNewSense, Ubuntu, Ututo
Posts: 73

Rep: Reputation: 15
Question Shell Scripting: Users "**Never logged in**"


I'm new to shell scripting and am trying to automate the checking of a certain security risk.

I'm trying to test and see if there are any user accounts that haven't been logged in yet. I know I can do this with a script such as

Code:
#!/bin/bash
lastlog | grep '**Never logged in**'
However, there are some system users in there that I don't want to consider deleting.

I've read that when a new user is created, the UID (User ID) starts at 500 and increments. I believe I should be able to grab the individual's user ID like this:

Code:
#!/bin/bash
cut -f : -d 3 /etc/passwd
However, I'm having some difficulty figuring out how to combine these two methodologies to output only new custom users (versus system users who will never be logged in on my systems).

Since new users on my system will be assigned generic passwords (all of which are going to be the same password), unused user accounts are a security risk on my systems. I'd like to automate the checking process to save myself some time.

Thanks everyone!

Last edited by cparker15; 10-02-2003 at 02:00 PM.
 
Old 10-02-2003, 03:48 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,254
Blog Entries: 54

Rep: Reputation: 2834Reputation: 2834Reputation: 2834Reputation: 2834Reputation: 2834Reputation: 2834Reputation: 2834Reputation: 2834Reputation: 2834Reputation: 2834Reputation: 2834
Quickie:
Code:
cat /etc/passwd | while read l; do 
# IFS saves me using "cut" here
IFS=":"; l=( ${l} )
if [ "${l[2]}" -ge "500" ]; then 
# "expr" saves me using "grep" here
expr index "$(lastlog -u "${l[0]}")" "*">/dev/null
case "$?" in 0) echo ${l[0]} never logged in;; esac
fi; done
new users on my system will be assigned generic passwords (all of which are going to be the same password),
Why? Is this absolutely necessary?

unused user accounts are a security risk on my systems.
...yes, and you're doing your best to thwart any efforts to correct it, right? :-]

I've read that when a new user is created, the UID (User ID) starts at 500 and increments.
Starting UID is configurable though.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
shell scripting - using ${variable:=","} Steve Riley Linux - General 7 02-08-2005 05:07 AM
"who" showing users that aren't logged on MS3FGX Slackware 13 10-06-2004 01:23 AM
"adduser" not adding users to default group "users" PunkPT Slackware 2 09-23-2004 11:50 AM
"finger" shows logged out users. webboss Linux - Networking 1 06-11-2004 01:19 PM
"who" shows logged in users that are not there... shadow.blue Linux - General 3 05-17-2004 06:33 AM


All times are GMT -5. The time now is 11:39 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration