DaemonForums  

Go Back   DaemonForums > Miscellaneous > Guides

Guides All Guides and HOWTO's.

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1   (View Single Post)  
Old 14th December 2010
wesley wesley is offline
Real Name: Wesley
Shell Scout
 
Join Date: Aug 2009
Location: Reunion Island
Posts: 92
Post duig script - delete user in group

To delete a user, we need to edit the file : /etc/group, and remove manually the account. But if we need to remove many users, it will be very a big task.
So i built a small script that do it successfuly:

Code:
if [ $1 ] & [ $2 ]; then
cp /etc/group /tmp
cat /tmp/group | grep ^$2 > /tmp/onlygroup
cat /tmp/group | grep -v ^$2 > /tmp/nogroup
cat /tmp/onlygroup | sed "s/$1//g" | \
        sed "s/ /,/g" | sed "s/,,/,/g" | sed "s/,$//g" > /tmp/newgroup
cat /tmp/newgroup >> /tmp/nogroup
cat /dev/null > /tmp/group
cat /tmp/nogroup >> /tmp/group
cp /tmp/group /etc
chmod 644 /etc/group
chown root /etc/group
chgrp wheel /etc/group
rm -f /tmp/*
else
echo "Remove user from a group"
echo "Use : sh duig user group"
fi
Cheers,

Wesley MOUEDINE ASSABY
www.mouedine.net
Reply With Quote
 

Tags
duig script, openbsd

Thread Tools
Display Modes

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
script add user with encrypted password wesley OpenBSD General 3 14th December 2010 03:22 PM
OpenBSD: create user sh script J65nko Guides 3 31st January 2010 08:29 PM
Canadian BSD user group.. BSDfan666 Off-Topic 5 11th January 2009 03:37 PM
C Programming Study Group on SDF cajunman4life Programming 0 23rd August 2008 02:27 AM


All times are GMT. The time now is 03:40 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick