![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Difference between : Locked User Account & Disabled User Accounts in Linux ? | avklinux | UNIX for Dummies Questions & Answers | 3 | 02-06-2009 09:01 PM |
| how can distingiush user account | alert0919 | HP-UX | 1 | 02-06-2009 10:05 AM |
| How do you set up an FTP user account? | XZOR | UNIX for Dummies Questions & Answers | 3 | 09-29-2008 04:06 AM |
| user account | chomca | Post Here to Contact Site Administrators and Moderators | 1 | 05-22-2006 01:41 PM |
| creatin user account | damian | UNIX for Dummies Questions & Answers | 1 | 08-01-2001 11:53 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
How to suspend a user account?
Hi, guys. I have two questions:
I need to write a script, which can show all the non-suspended users on system, and suspend the selected user account. There are two things I am not sure: 1. How can I suspend user's account? What I think is: add a string to the encrypted password in shadow file, then the user is not able to login into the system. 2. How can I know which accounts are suspended? What I think is: add fix string to the encrypted password in the shadow file, if I found any encrypted passwords begins with that string, I know these account are suspended. Are these ideas good practices? Thank you very much for your time in advance -Keyang |
|
||||
|
By suspend, do you mean to lock the account so they can't login? This command does that, which can easily be done from a script: Code:
usermod -L user As for listing all non-suspended users, this might work. I grep for /bin/false to try to get rid of non-user users, but you still end up with mail, halt, nobody, etc. You could also use grep to eliminate '/bin/sh' if no one actually uses that shell. Code:
for u in $(sudo grep -v ':!' /etc/shadow | cut -d: -f1); do
grep -qv "$u.*/bin/false" /etc/passwd && echo $u
done
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|