# About user login change



## goldenfire (Jan 14, 2010)

For some reasons, we often change user logins.
At machine 1, for example, we change login name from A to B.
Usually we'd like to type "vipw" and replace A with B at the editor screen, then quit editor with "wq".
I know that "pw usermod A -l B" cold also get the same result.

Is there any difference between these two methods? 
It says that "vipw" will lock the user database until finish.
How about "pw" ?


----------



## SirDice (Jan 14, 2010)

goldenfire said:
			
		

> Is there any difference between these two methods?


vipw uses an editor, pw doesn't.



> It says that "vipw" will lock the user database until finish.
> How about "pw" ?


They both lock the database. But pw is almost instantly done whereas vipw is done once vi is closed.


----------



## goldenfire (Jan 15, 2010)

SirDice said:
			
		

> vipw uses an editor, pw doesn't.
> 
> 
> They both lock the database. But pw is almost instantly done whereas vipw is done once vi is closed.



Thank you very much.
So "pw" is also a safe method to change user login (or modify user database) ?
Posing this question is because that I could not find a good way to use vipw in shell script.


----------



## DutchDaemon (Jan 15, 2010)

You could say that vipw is for a simple manual change, whereas pw lends itself more to scripting because everything can be passed on the command-line.


----------



## lme@ (Jan 15, 2010)

SirDice said:
			
		

> But pw is almost instantly done whereas vipw is done once vi is closed.



Better: ... once $EDITOR is closed.


----------



## goldenfire (Jan 18, 2010)

Thanks everyone!


----------

