The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-20-2009
daikeyang daikeyang is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 24
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
  #2 (permalink)  
Old 03-21-2009
KenJackson KenJackson is offline
Registered User
  
 

Join Date: May 2008
Location: Maryland, USA
Posts: 108
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

  #3 (permalink)  
Old 03-21-2009
daikeyang daikeyang is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 24
Hi, Kenjackson

Thank you very much for your replay!

-Keyang
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 04:19 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0