#!/bin/bash
# Change the GID of a Group and make it effective for all the members in /etc/passwd
pwfile=/etc/passwd
grpfile=/etc/group
DATE=`date +%d.%b.%Y`
TIME=`date +%H.%M.%S`
echo Creating backups $pwfile.$DATE.$TIME and $grpfile.$DATE.$TIME
cat $pwfile > $pwfile.$DATE.$TIME
cat $grpfile > $grpfile.$DATE.$TIME
echo Enter group name
read gname
cgid=`grep $gname $grpfile | cut -f3 -d:`
username_s=`cat $pwfile | grep $cgid | cut -f1 -d:`
echo Following users will be affected
echo "##############"
echo $username_s
echo "##############"
echo Enter new GID
read ngid
## Change the GID of the group
groupmod -g $ngid $gname
## Change GID(s) in passwd file
uidc=`grep $cgid $pwfile | cut -f3 -d: | wc -l`
uidh=1
while [ "$uidc" -ge "$uidh" ]
do
{
id=`head -$uidh uid | tail -1`
sed 's/'$id':'$cgid'/'$id':'$ngid'/g' $pwfile > $pwfile.new
cat $pwfile.new > $pwfile
uidh=$[$uidh + 1 ]
}
done
echo The entries in replaced File are
grep $ngid $pwfile.new
echo The original has been backed up as $pwfile.$DATE
echo Thank you
cd $PWD
exit 0
Wednesday, October 17, 2007
Subscribe to:
Post Comments (Atom)
AT&T USA | Internet not working | Fix by custom APN
If the AT&T Mobile internet is not working on your cellphone, it can be fixed easily by adding an APN configuration. You can read this a...
-
Hi there, You all know how to check TCP port connectivity from a Linux or UNIX machine to a remote machine using telnet as per th exampl...
-
Before you start Ensure that you have installed wvdial, usbmodeswitch and usbmodeswitch_data # dpkg -l | grep wvdial # dpkg -l | grep ...
-
#!/bin/sh # Shell script to monitor the disk space,Memory,SWAP Usage and send an email to $ADMIN, if the free avilable percentage of space i...
No comments:
Post a Comment