Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 03-23-2016, 04:08 AM   #1
LQ Newbie
Registered: Feb 2016
Posts: 18

Rep: Reputation: Disabled
Question usermod vs passwd - usermod not working

I have a CentOS machine, and I made a test user then set his password to splinter:

# useradd test1
# usermod -p splinter test1
Then I tested it by logging in:
mycentos login: test1
Login incorrect
The secure log said:
Mar 21 22:31:00 myhost unix_chkpwd[2685]: password check failed for user (test1)
So I tried to change password to splinter using passwd function:
# passwd test1
New Password: [typed splinter here]
Retype New Password: [typed splinter here]
Logged in just fine with user test1... So am I missing something? I chose splinter as the test password simply because it has no special chars etc, so I figured the usermod command would have no issues.

Why is usermod failing to change the password but the passwd command works just fine?


Last edited by scriptkiddy; 03-23-2016 at 04:09 AM.
Old 03-23-2016, 06:14 AM   #2
Registered: Mar 2015
Distribution: Ubuntu
Posts: 37

Rep: Reputation: Disabled
Have a look through the man page for "usermod" and you'll find something like this.

       -p, --password PASSWORD
           The encrypted password, as returned by crypt(3).
That's from Ubuntu, so the wording may be different. But the idea still holds.
1 members found this post helpful.
Old 03-23-2016, 11:25 AM   #3
Senior Member
Registered: Sep 2013
Distribution: Void Linux / Slackware 14.2
Posts: 4,742

Rep: Reputation: 877Reputation: 877Reputation: 877Reputation: 877Reputation: 877Reputation: 877Reputation: 877
it worked for me in,
Void Linux
root@voided/home/userx >># useradd  deleteme
root@voided/home/userx >># usermod -p homeboy deleteme
root@voided/home/userx >># exit
% 10:23 AM [userx@voided]~ >>$sudo -u deleteme
[deleteme@voided userx]$ whoami
[deleteme@voided userx]$ exit
% 10:24 AM [userx@voided]~ >>$whoami
but logging in the other way, by logging out then back in under new user name password did not take.

found this it is way worth the read "A Complete Guide to Usage of ‘usermod’ command – 15 Practical Examples with Screenshots"

 Create Un-encrypted Password for User

To create an un-encrypted password, we use option ‘-p‘ (password). For demonstration purpose, I’m setting a new password say ‘redhat’ on a user pinky.

Last edited by BW-userx; 03-23-2016 at 11:40 AM.
1 members found this post helpful.
Old 03-23-2016, 08:11 PM   #4
Registered: May 2006
Location: Brisbane, Australia
Distribution: linux
Posts: 153

Rep: Reputation: 44
Have a look at "/usr/sbin/chpasswd" which is a password changing program for batch (bulk) processing of users.

It can take the password in the clear, or a pre-encrypted passwd.

For example
   useradd  junkuser
   echo 'junkuser:junky password' | /usr/sbin/chpasswd
1 members found this post helpful.
Old 03-24-2016, 02:43 AM   #5
LQ Newbie
Registered: Feb 2016
Posts: 18

Original Poster
Rep: Reputation: Disabled
Interesting responses and information, thanks everyone, here are some thoughts.

@cnamejj I did see entry in the manpage about crypt, but I couldn't find any information on how to use it. For example, I couldn't find a yum package that had crypt in it, nor could I find a man page for crypt.

@BW-userx Its interesting that your login didn't work, but sudo did. I didn't try sudo, just logging in myself. Either way, the user wouldn't be able to log in if I did a usermod -p, so that's the issue I'm trying to fix. Was a good read

@A.Thyssen Well, it doesn't answer why usermod doesn't work, but that is a really interesting solution.



Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Linux Commands to manage Local Accounts useradd, usermod, chage & passwd LXer Syndicated Linux News 0 02-12-2016 08:51 PM
what the difference between usermod -G usermod -g LittleMaster Linux - Newbie 3 10-09-2012 04:26 AM
[SOLVED] how do I use the usermod command to add a comment to /etc/passwd Tayuechick SUSE / openSUSE 7 08-24-2011 10:48 PM
usermod and passwd Shwick Linux - Software 2 10-09-2008 05:32 AM
usermod, beyond passwd & shadow Hans Zilles Linux - General 0 11-26-2005 06:29 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:48 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration