useradd -m -p $(perl -e'print crypt("passwordscelta", "stigghiola")') user

Create new user with home dir and given password

The crypt function takes a password, key, as a string, and a salt character array which is described below, and returns a printable ASCII string which starts with another salt. It is believed that, given the output of the function, the best way to find a key that will produce that output is to guess values of key until the original value of key is found. from http://en.wikipedia.org/wiki/Crypt_(Unix)

1
By: 0disse0
2012-02-06 19:53:01

These Might Interest You

  • This command line creates a new user with home directory, using the command "useradd". The command "mkpasswd" lets you encrypt the password e.g. with SHA-512 method. This line ensures that your password is written encrypted in /etc/shadow" so you can log in with the new user. Show Sample Output


    0
    useradd -m -s /bin/bash -p $(mkpasswd --hash=SHA-512 password) username
    miko · 2013-03-22 10:46:03 0
  • Put this into your ~/.bashrc to create a database for mysql with a user and password. Usage: createdb `database` `datbase-user` `database-password`.


    0
    function createdb () { mysqladmin -u root -p create $1 && mysql -u root -p -e "GRANT ALL ON $1.* TO '$2'@'localhost' IDENTIFIED BY '$3';" ; }
    thanosme · 2013-08-18 00:34:37 0
  • Here $HOME/shots must exist and have appropriate access rights and sitecopy must be correctly set up to upload new screen shots to the remote site. Example .sitecopyrc (for illustration purposes only) site shots server ftp.example.com username user password antabakadesuka local /home/penpen/shots remote public_html/shots permissions ignore The command uses scrot to create a screen shot, moves it to the screen shot directory, uploads it using screen uses xsel to copy the URL to the paste buffer (so that you can paste it with a middle click) and finally uses feh to display a preview of the screen shot. Note that $BASE stands for the base URL for the screen shots on the remote server, replace it by the actual location; in the example http://www.example.com/~user/shots would be fitting. Assign this command to a key combination or an icon in whatever panel you use. Show Sample Output


    -1
    scrot -e 'mv $f \$HOME/shots/; sitecopy -u shots; echo "\$BASE/$f" | xsel -i; feh `xsel -o`'
    penpen · 2009-03-26 12:08:39 0
  • A web server using $HOME/public_html as user directory is required, $HOME/public_html/shots must exist and have appropriate access rights and $HOSTNAME must be known to and accessible from the outside world. The command uses scrot to create a screen shot, moves it to the screen shot directory, uses xsel to copy the URL to the paste buffer (so that you can paste it with a middle click) and finally uses feh to display a preview of the screen shot. Assign this command to a key combination or an icon in whatever panel you use.


    0
    scrot -e 'mv $f \$HOME/public_html/shots/; echo "http://\$HOSTNAME/~\$USER/shots/$f" | xsel -i; feh `xsel -o`'
    penpen · 2009-03-26 11:32:09 1
  • AIX lssec does not print the password attribute by policy # lssec -c -f /etc/security/passwd -s an_user -a password 3004-697 Attribute "password" is not valid. To get the password, you have to parse the /etc/security/passwd. You can reuse this password using chpasswd: echo "otheruser:D9oKC1v3VUt/I" | chpasswd -c -e -R compat Show Sample Output


    0
    user=an_user awk "/^$user:\$/,/password =/ { if (\$1 == \"password\") { print \$3; } }" < /etc/security/passwd
    keymon · 2010-11-29 09:46:12 0
  • db2 => ? connect CONNECT [USER username [{USING password [NEW new-password CONFIRM confirm-password] | CHANGE PASSWORD}]] CONNECT RESET CONNECT TO database-alias [IN {SHARE MODE | EXCLUSIVE MODE [ON SINGLE DBPARTITIONNUM]}] [USER username [{USING password [NEW new-password CONFIRM confirm-password] | CHANGE PASSWORD}]] Show Sample Output


    0
    db2 CONNECT TO stgndv2 USER pmserver USING ********
    kaushalmehra · 2012-06-07 18:55:47 0

What Others Think

One should never enter a password into the command line. Chances are, it'll be saved in history, and, if the command takes a while, will show in the process list.
Fudo · 328 weeks ago
Well, I would complain about the use of perl first but... you can allways remove the line from the history file. useradd -m -p $(perl -e'print crypt("passwordscelta", "stigghiola")') user & history -d
foucault · 326 weeks and 2 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: