Help answer threads with 0 replies.
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 06-14-2004, 01:46 PM   #1
Registered: Jun 2003
Distribution: Redhat
Posts: 87

Rep: Reputation: 15
useradd command question

I want to add user with password but when I looked up man useradd it says: -p passwd (use CRYPT(3)). What does it mean? and for example, if I want to add user user1 with password 12345 what should I type?

ps. I tried useradd -p 12345 user1 but it didn't work.
Old 06-14-2004, 02:10 PM   #2
Registered: Aug 2003
Location: Portland, Oregon
Distribution: RedHat, Libranet
Posts: 438

Rep: Reputation: 30
What it means is that you have to pass an encrypted password string
as the argument to your "useradd -p" command. The crypt(3) reference
is telling you where in the man pages (section 3) you can find information
about crypt.

I use the following perl script to encrypt a password when I need to do this:
#! /usr/bin/perl
($password, $salt) = @ARGV;
$password or die "usage: mycrypt password [salt]\n";
$salt = "cc" unless $salt;
$cryptpw = crypt($password,$salt);
print "$password -> $cryptpw \n";

In the above script, salt is a two character string that is used as the basis
for the encryption of the password. To use the script, (after saving it as
"myscript" and making it executable) invoke:
./myscript password

Use the string that is generated by the script as the argument after the
-p option in your useradd invocation.

Good luck.
Old 06-14-2004, 04:47 PM   #3
Senior Member
Registered: Nov 2003
Location: NB,Canada
Distribution: Something alpha or beta, binary or source...
Posts: 2,280
Blog Entries: 4

Rep: Reputation: 47
forget adding a password at the time of creation. Do it immediately after. If you have created "user1", then use "passwd user1" and enter the password. Done. No fighting with switches and encryption that is handled automatically by passwd.


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
useradd from command line question Strixy Linux - Newbie 4 08-05-2005 06:58 PM
useradd command Wolvastur Linux - Newbie 9 01-25-2005 10:01 AM
useradd command johnpayback Linux - General 4 08-13-2002 05:24 PM
useradd command johnpayback Linux - Newbie 5 08-13-2002 10:22 AM
useradd command allancondino Linux - General 5 04-27-2002 12:01 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:04 PM.

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
Open Source Consulting | Domain Registration