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



On Wed, 18 Dec 1996, Duan Zhenhai wrote:

> Date: Wed, 18 Dec 1996 09:47:23 +0900 (JST)
> From: Duan Zhenhai <ccdzh@shoukui.pku.edu.cn>
> To: Linux Kernel <linux-kernel@vger.rutgers.edu>
> Subject: Delete 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

ACK! This is very dangerous. You should never muck with /etc/passwd
without doing proper file locking. Personally, I dont like to reuse
UID's.. I just change or lock their password and change their shell to
something bogus. In the case of a shell access account, you would also
want to blow away the files within their home dir, including any .rhosts
files, and then their mail spool as you note below.

>
> #
> #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:38    [W:0.029 / U:0.260 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site