What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again.

Delete that bloated snippets file you've been using and share your personal repository with the world. 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.

If you have a new feature suggestion or find a bug, please get in touch via http://commandlinefu.uservoice.com/

Get involved!

You can sign-in using OpenID credentials, or register a traditional username and password.

First-time OpenID users will be automatically assigned a username which can be changed after signing in.

Universal configuration monitoring and system of record for IT.

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:



May 19, 2015 - A Look At The New Commandlinefu
I've put together a short writeup on what kind of newness you can expect from the next iteration of clfu. Check it out here.
March 2, 2015 - New Management
I'm Jon, I'll be maintaining and improving clfu. Thanks to David for building such a great resource!

Top Tags





Commands using passwd from sorted by
Terminal - Commands using passwd - 16 results
export NEWUSER=newuser; mkdir /home/$NEWUSER; useradd -d /home/$NEWUSER -s /bin/bash -G sudo $NEWUSER; passwd $NEWUSER
sudo passwd <username>
getent passwd `whoami` | cut -d ':' -f 5
2013-12-05 01:37:44
User: timhughes
Functions: cut getent passwd

Doesn't require finger and should work whatever the underlying auth mechanism is

getent passwd | cut -d: -f1 | sort
echo -e "new_password\nnew_password" | (passwd --stdin $USER)
getent passwd $(whoami) | echo "$(perl -ne '/^([^:]+):[^:]+:[^:]+:[^:]+:([^ ]+) ?([^,]+)?,([^,]*),([^,]*),([^:,]*),?([^:,]*)/ and printf "MECARD:N:$3,$2;ADR:$5;TEL:$4;TEL:$6;EMAIL:$1@"')$HOSTNAME;;" | qrencode -o myqr.png
2011-07-25 12:59:57
User: Strawp
Functions: echo getent passwd
Tags: perl qr qrencode

If your contact information was entered when your user account was created (it gets added to /etc/passwd) then this gets that info and creates a QR code for you automatically

getent passwd $(whoami) | cut -f 5 -d: | cut -f 1 -d,
getent passwd | awk -F: '($3>600) && ($3<10000) && ($3>maxuid) { maxuid=$3; } END { print maxuid+1; }'
passwd -d $USER
2010-05-07 07:15:09
User: TheFox
Functions: passwd

-d, --delete

Delete a user?s password (make it empty). This is a quick way to disable a password for an account. It will set the named account passwordless.

zenity --title passwd --width 800 --height 600 --text-info --filename /etc/passwd
2010-04-16 04:20:52
User: rkulla
Functions: passwd

I use zenity because it's a rewrite of gdialog and also replaces gmessage and has more useful options.

Using --text-info allows you to select and copy the text to your clipboard.

To see a file in a list dialog: cat /etc/passwd | zenity --width 800 --height 600 --list --column Entries

If you don't have zenity, you'll have to download it via apt-get install zenity, etc.

awk -F":" '{ print $1 }' /etc/passwd | while read UU ; do STATUS=$(passwd -S ${UU} | grep locked 2>/dev/null) ; if [[ ! -z ${STATUS} ]] ; then echo "Account ${UU} is locked." ; fi ; done
while IFS=: read u x; do passwd -e "$u"; done < /etc/passwd
2009-11-20 21:49:34
User: cfajohnson
Functions: passwd read

This assumes that te original's 'passwd -e' forces a user to change password; it doesn't in the versions I have.

getent passwd|cut -d: -f1|xargs -n1 passwd -e
2009-11-18 19:46:15
User: romulusnr
Functions: cut getent passwd xargs

Alternately for those without getent or only want to work on local users it's even easier:

cut -d: -f1 /etc/passwd|xargs -n1 passwd -e

Note that not all implementations of passwd support -e. On RH it would be passwd -x0 (?) and on Solaris it would be passwd -f.

for i in `cat /etc/passwd | awk -F : '{ print $1 }';`; do passwd -e $i; done
echo "encryptedpassword"|openssl passwd -1 -stdin
for name in larry moe schemp; do useradd $name; echo 'password' | passwd --stdin $name; chage -d 0 $name; done
2009-03-15 12:02:39
User: atoponce
Functions: chage echo passwd useradd

This command is a bit Linux specific, as --stdin doesn't exist for passwd on many Unix machines. Further, useradd is high level in most distributions and Unix derivatives except for the Debian family of distros, where adduser would be more appropriate. The last bit, with chage, will force the user to change their password on new login.