Operating System - HP-UX
1832366 Members
2619 Online
110041 Solutions
New Discussion

Temporarily Deactivating Users

 
SOLVED
Go to solution
Jared Westgate_1
Valued Contributor

Temporarily Deactivating Users

Hello,

I would like to be able to temporarily keep certain users from loggin on to my HP-UX 11.0 system. I don't want to have to go into single-user mode. I'm wondering if I can just comment the usernames out of the /etc/passwd?

The reason I would like to do it this way is that I need the users to have the same password when I re-enable them. Will this method work? Or, is there a better way to temporarily disable many users at a time?

Thanks for your help.
6 REPLIES 6
Rita C Workman
Honored Contributor

Re: Temporarily Deactivating Users

Well another way is in SAM you can DeActivate a user...

but the choice is yours..

/rcw
Jared Westgate_1
Valued Contributor

Re: Temporarily Deactivating Users

Thanks for the info.

But, I think you can only deactivate one user at a time in SAM. I will need to deactivate around 50-100 users, so I'd rather do it in a script. Or at least in bulk, somehow.
Wilfred Chau_1
Respected Contributor
Solution

Re: Temporarily Deactivating Users

I would just vi /etc/passwd and change the users' shell to /usr/bin/false.

something like
# vi /etc/passwd
0,$s/\/usr\/bin\/sh/\/usr\/bin\/false
* which should subsitute /usr/bin/sh with /usr/bin/false from line 0 to very last line. Make a backup first!!
Karthik_2
Regular Advisor

Re: Temporarily Deactivating Users

Jared,
Editing /etc/passwd will work .But make sure that you have the uers logout when you edit this file else it is of no use .
Also make a copy of /etc/passwd as well .

Karthik...
Its ALL in the MATRIX
Brian Markus
Valued Contributor

Re: Temporarily Deactivating Users

Sounds like the slow way of doing it. I use a piece of code in my /etc/profile that will make it so no one can log in except the users you want. If the file nologin exists in the etc directory only your special users can log in. Just do the following: touch /etc/nologin when you want no one except people in your list to login. rm /etc/nologin to turn it off. You can make this list as long or as short as you want.


if [ -r /etc/nologin ]
then
case $LOGNAME in
root);;
bmarkus);;
oracle);;
esac
fi


Hope this helps,

Brian
When a sys-admin say's maybe, they don't mean 'yes'!
Scott Van Kalken
Esteemed Contributor

Re: Temporarily Deactivating Users

if this is for system maintenance you just either use modprpw - if it's a trusted system

or you can use a script to place a temporary password file that greps out the uers you don't want to have access.