|
Home > Archive > Unix Shell > September 2006 > A simple SuSe Linux user spot checks, user account info collector, bash.
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
A simple SuSe Linux user spot checks, user account info collector, bash.
|
|
| johngnub 2006-09-25, 7:34 pm |
| Was working on user spot check on the hosts, collecting info and the
like. Posting the script here for general know-how and comment /
feedback, at the risk of being mocked in a public forum. Well here it
is, thanks in advance for comments. JB!!
----------------------------------------------------------------
echo "`uname -n` :: User Spot Checks."
# Paths norm are /usr/bin, /bin, for sed,passwd, df and so on.
# Else full paths and checks used to DIAG if missing, is the package
# installed. Bash, I did not test with other shells.
# Fur SuSe Linux, tested on Rel = 9+ 10+.
# Line Formating = One : then data, two :: then errors, host name in
the
# line.
# Why is not the last letter, thus why is why oft the last
# question we ask. "DNA"
# Why no awk, lazy, and tr,cut much smaller in loops.
#
# OOPMH! Augen Auf..... johngnub@cox.net
########################################
###
#
# List user details, see man passwd.
passwd -a -S|sed "s/^/`uname -n` : /"
#
# List last bad logins that are in file, see lastb
[ -f /var/log/btmp ] || (
echo "`uname -n` :: No btmp last bad login not tracked." )
[ -f /var/log/btmp ] && (
/usr/bin/lastb|sed "s/^/`uname -n` Last_Bad : /" )
#
# List user details and dates, suff host in the line.
[ -a /usr/bin/chage ] || (
echo "`uname -n` :: No chage command not able to list user age dates."
)
[ -a /usr/bin/chage ] && (
foo=$(passwd -a -S|tr -s ' '|cut -d ' ' -f1)
for x in $foo
do
/usr/bin/chage -l "$x"|sed "s/^/`uname -n` $x : /"
done
)
#
# Look for error in the passwd file, see pwck.
[ -a /usr/sbin/pwck ] || (
echo "`uname -n` :: No pwck not able to check passwd file."
)
[ -a /usr/sbin/pwck ] && (
/usr/sbin/pwck |sed "s/^/`uname -n` : /"
)
#
# Ready a list of mounts for this host.
# Example of a auto list, I used auto list, see below.
# That Regex, drop out df header, cut it, drop out mounts I do not wish
to see.
# Mod for your needs OR just use a manual list, like example above.
# I am skiping the dev dir for the linux lvm, and root it self.
LIST=$(df|egrep -v "Filesystem"|tr -s ' '|cut -d ' ' -f6|egrep -v
"^[/]$|^/dev")
# Today I am useing a manual list.
LIST="/usr
/var
/home
/tmp"
# Warning, this can list out a lot of files.
for x in $LIST
do
find "$x" -nouser -ls|sed "s/^/`uname -n` : /"
done
echo "`uname -n` : Ok Done."
# Ende
|
|
|
|
|