Create user add lines from partial passwd file

awk -F: '{print "useradd -u "$3,"-c \""$5"\"","-s "$7,$1}' passwd
Handy if you are installing a new server or recovering an old one and you have a passwd file with the accounts you want to add to the server. If you edit the file so that only the accounts that you want to add are left this line will spit out the correct useradd lines. The uid, gecos and shell will be preserved.
Sample Output
jsnuffy:x:600:600:Joe Snuffy:/home/jsnuffy:/bin/bash
hhandle:x:601:601:Harru Hoehandle:/home/hhandle:/bin/bash
ssimple:x:602:602:Sally Simple:/home/ssimple:/bin/bash

useradd -u 600 -c "Joe Snuffy" -s /bin/bash jsnuffy
useradd -u 601 -c "Harru Hoehandle" -s /bin/bash hhandle
useradd -u 602 -c "Sally Simple" -s /bin/bash ssimple

By: UnixSage
2010-06-06 11:54:35

What Others Think

create user add from partial password file and making the impressive accounts and preserved the great topics. I have found here essay rush and the useful writing techniques and great services as well,thanks.
arvvaine · 103 weeks and 4 days ago
This command to get">hack snapchat is working fine when we try to generate the snapchat password.
maaz23 · 58 weeks and 6 days ago
So get the password at online easily.
maaz23 · 58 weeks and 6 days ago
Yes, I can help you with this because I know of a app that is very famous for how to hack someone's snapchat in the market, so I am sharing its link with you here you can use them by visiting the above link.
Kaitlinfulton · 28 weeks and 6 days ago ????? ??? ????? ????? SEO - ????? ???? ????? ????? ????? ??? ????? ????? SEO - ????? ???? ????? ????? ????? ??? ????? ????? SEO - ????? ???? ????? ????? ????? ??? ????? ????? SEO - ????? ???? ????? ????? ????? ??? ????? ????? SEO - ????? ???? ????? ????? ????? ??? ????? ????? SEO - ????? ???? ????? ????? 5
seofox · 15 weeks and 3 days ago
seofox · 14 weeks and 4 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? 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.


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: