linux-admin.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Change password with usermod
@ 2007-03-10  9:53 Mário Gamito
  0 siblings, 0 replies; 6+ messages in thread
From: Mário Gamito @ 2007-03-10  9:53 UTC (permalink / raw)
  To: linux-admin

Hi,

I'm trying to set a password directly from a script, using usermod, but 
i get an error, i shouldn't get:

#!Bin/bash
groupadd postgres
useradd -g postgres postgres
PASS=`mkpasswd secret`
ID=`cat /etc/passwd | grep postgres | cut -f3 -d':'`
usermod -p $PASS -u $ID

This gives me:
"usermod: user 502 does not exist"

But the odd thing is that it exists with that uid.

Any ideas ?

Warm Regards,
Mário Gamito
-
To unsubscribe from this list: send the line "unsubscribe linux-admin" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Change password with usermod
@ 2007-03-10 10:42 Mário Gamito
  2007-03-10 10:56 ` Mário Gamito
  2007-03-10 11:55 ` Krzysztof Dubowik
  0 siblings, 2 replies; 6+ messages in thread
From: Mário Gamito @ 2007-03-10 10:42 UTC (permalink / raw)
  To: linux-admin

Hi,

I'm trying to set a password directly from a script, using usermod, but 
i get an error, i shouldn't get:

#!Bin/bash
groupadd postgres
useradd -g postgres postgres
PASS=`mkpasswd secret`
ID=`cat /etc/passwd | grep postgres | cut -f3 -d':'`
usermod -p $PASS -u $ID

This gives me:
"usermod: user 502 does not exist"

But the odd thing is that it exists with that uid.

Any ideas ?

Warm Regards,
Mário Gamito
-
To unsubscribe from this list: send the line "unsubscribe linux-admin" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Change password with usermod
  2007-03-10 10:42 Mário Gamito
@ 2007-03-10 10:56 ` Mário Gamito
  2007-03-10 11:55 ` Krzysztof Dubowik
  1 sibling, 0 replies; 6+ messages in thread
From: Mário Gamito @ 2007-03-10 10:56 UTC (permalink / raw)
  To: linux-admin

Of course it isn't

#!Bin/bash

but

#!/bin/bash

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Change password with usermod
  2007-03-10 10:42 Mário Gamito
  2007-03-10 10:56 ` Mário Gamito
@ 2007-03-10 11:55 ` Krzysztof Dubowik
  2007-03-10 12:05   ` Mário Gamito
  2007-03-10 21:42   ` Ian Ward Comfort
  1 sibling, 2 replies; 6+ messages in thread
From: Krzysztof Dubowik @ 2007-03-10 11:55 UTC (permalink / raw)
  To: linux-admin

Hi,

Mário Gamito wrote:
> PASS=`mkpasswd secret`
> ID=`cat /etc/passwd | grep postgres | cut -f3 -d':'`
> usermod -p $PASS -u $ID
> 
> This gives me:
> "usermod: user 502 does not exist"

usermod needs a login name rather than the userid and you don't need -u
option:

# usermod -p $PASS postgres

However, I usually user chpasswd to change the password from a script, so
your script becomes:

# echo postgres:secret | chpasswd

Hope this helps,
Krzysztof

-
To unsubscribe from this list: send the line "unsubscribe linux-admin" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Change password with usermod
  2007-03-10 11:55 ` Krzysztof Dubowik
@ 2007-03-10 12:05   ` Mário Gamito
  2007-03-10 21:42   ` Ian Ward Comfort
  1 sibling, 0 replies; 6+ messages in thread
From: Mário Gamito @ 2007-03-10 12:05 UTC (permalink / raw)
  To: Krzysztof Dubowik, linux-admin

Hi,

Thank you for your answer.

> usermod needs a login name rather than the userid and you don't need -u
> option:
> 
> # usermod -p $PASS postgres
I tried that but didn't work for me:
"[root@mail ~]# usermod -p $PASS postgres
usage: usermod  [-u uid [-o]] [-g group] [[-a] -G group,...]
                 [-d home [-m]] [-s shell] [-c comment] [-l new_name]
                 [-f inactive] [-e expire ] [-p passwd] [-L|-U] name"


> However, I usually user chpasswd to change the password from a script, so
> your script becomes:
> 
> # echo postgres:secret | chpasswd
But this does :)

Thanks a bunch.

Warm Regards,
Mário Gamito
-
To unsubscribe from this list: send the line "unsubscribe linux-admin" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Change password with usermod
  2007-03-10 11:55 ` Krzysztof Dubowik
  2007-03-10 12:05   ` Mário Gamito
@ 2007-03-10 21:42   ` Ian Ward Comfort
  1 sibling, 0 replies; 6+ messages in thread
From: Ian Ward Comfort @ 2007-03-10 21:42 UTC (permalink / raw)
  To: linux-admin

On Mar 10, 2007, at 3:55 AM, Krzysztof Dubowik wrote:
> However, I usually user chpasswd to change the password from a  
> script, so your script becomes:
>
> # echo postgres:secret | chpasswd

A better idea is to:

# chpasswd < passfile

where passfile has been created with the contents:

postgres:secret

That prevents your new password from appearing momentarily in the  
process list during this procedure.

—IWC

-
To unsubscribe from this list: send the line "unsubscribe linux-admin" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2007-03-10 21:42 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-10  9:53 Change password with usermod Mário Gamito
  -- strict thread matches above, loose matches on Subject: below --
2007-03-10 10:42 Mário Gamito
2007-03-10 10:56 ` Mário Gamito
2007-03-10 11:55 ` Krzysztof Dubowik
2007-03-10 12:05   ` Mário Gamito
2007-03-10 21:42   ` Ian Ward Comfort

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).