January 2004
Intermediate to advanced
368 pages
7h 25m
English
Deleting an account is a bit more tricky than suspending it, because the script needs to check the entire file system for files owned by the user, and this must be done before the account information is removed from /etc/passwd and /etc/shadow.
#!/bin/sh ## deleteuser - Deletes a user account without a trace... # Not for use with Mac OS X homedir="/home" pwfile="/etc/passwd" shadow="/etc/shadow" newpwfile="/etc/passwd.new" newshadow="/etc/shadow.new" suspend="/usr/local/bin/suspenduser" locker="/etc/passwd.lock" if [ -z $1 ] ; then echo "Usage: $0 account" >&2; exit 1 elif [ "$(whoami)" != "root" ] ; then echo "Error: you must be 'root' to run this command.">&2; exit 1 fi $suspend $1 # suspend their account ...
Read now
Unlock full access