lkml.org 
[lkml]   [1996]   [Dec]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectDelete user

Hi,

I had written a shell to delete one user. But I do not know
if I had done what all I should do to delete user.

Any comment is appreciated.
Please send directly to me, Now I am not on this list.

ccdzh@pku.edu.cn

Duan Zhenhai
Peking University


//////////////////////////////////////////////////////////////////////////
#!/bin/bash
#
#delete the user your give.
#deluser username
#ccdzh@pku.edu.cn
#

if [ $# -ne 1 ]; then
echo "Usage: $0 user_account_you_want_to_delete"
exit 1
fi

#
#delete the user home directory
#

if [ -d /home/$1 ]; then
rm -r /home/$1
echo delete the /home/$1
else
echo No such user
exit 1
fi

#
#modify the passwd file
#

grep -v "^$1:" /etc/passwd > /tmp/passwd.tmp
mv /tmp/passwd.tmp /etc/passwd
echo delete the item in the /etc/passwd

#
#delete the user's system mailbox
#

if [ -f /usr/spool/mail/$1 ]; then
rm /usr/spool/mail/$1
echo delete the user system mailbox
fi

#
#done
#

\
 
 \ /
  Last update: 2005-03-22 13:37    [W:3.092 / U:0.516 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site