- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- delete users
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2005 02:59 AM
07-20-2005 02:59 AM
delete users
I need to create a script to delete users on our servers. The list of user ids to be deleted will be provided in a file , terminations.txt
We don't use NIS so i will just run this on each server. Below is a script I created.
Is there a better way?
#!/bin/sh
for i in `cat terminations.txt`
do
grep -q $i /etc/passwd
if [ $? -eq 0 ]
then
echo $?
echo user $i found in /etc/passwd file
/usr/sbin/userdel -r $i
else
echo $?
echo user $i not found in /etc/passwd file
fi
done
Thanks for your input.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2005 03:07 AM
07-20-2005 03:07 AM
Re: delete users
May I suggest this cosntruct :
grep -q $i /etc/passwd; r=${?}
if [ $r -eq 0 ]
then
blah...blah..
i
UNIX because I majored in cryptology...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2005 03:13 AM
07-20-2005 03:13 AM
Re: delete users
.
.
.
for SERVER in nodea nodeb nodec ;do
remsh $SERVER -n /usr/sbin/userdel -r $i
done
.
.
.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2005 07:48 AM
07-20-2005 07:48 AM
Re: delete users
you should cut out field #1 before doing the grep because otherwise you may delete more than you want.
cut -d: -f1 /etc/passwd | grep -q ${i}
greetings,
Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2005 05:06 PM
07-20-2005 05:06 PM
Re: delete users
if egrep -q "^${i}:" /etc/passwd
then
...