Hide

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.

Hide

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:

Hide

News

2011-03-12 - Confoo 2011 presentation
Slides are available from the commandlinefu presentation at Confoo 2011: http://presentations.codeinthehole.com/confoo2011/
2011-01-04 - Moderation now required for new commands
To try and put and end to the spamming, new commands require moderation before they will appear on the site.
2010-12-27 - Apologies for not banning the trolls sooner
Have been away from the interwebs over Christmas. Will be more vigilant henceforth.
2010-09-24 - OAuth and pagination problems fixed
Apologies for the delay in getting Twitter's OAuth supported. Annoying pagination gremlin also fixed.
Hide

Tags

Hide

Functions

All commands from sorted by
Terminal - All commands - 11,858 results
yes '' | cat -n
. ~/.profile
2009-04-22 16:56:12
User: ruchi
-5

If you edit your .profile you need to refresh it for changes to take place. Simple way to refresh is logout and login. This command is the quickest way to do it.

If you're deleting some variables, they would not get nulled with this command but just removed.

ps -L -p <pid> | wc -l
screen -ls | grep pts | gawk '{ split($1, x, "."); print x[1] }' | while read i; do gnome-terminal -e screen\ -dx\ $i; done
2009-04-22 10:36:39
User: microft
Functions: gawk grep read screen
3

connects to all the screen instances running.

sudo cat /dev/mem > /dev/dsp
vrms
2009-04-22 06:54:20
User: eastwind
-3

tell you how many Non free software is on your machine, which package it is and which restriction on freedom it has . require vrms package , vrms mean virtual Richard M. Stallman :)

boxes -d dog or cowsay -f tux $M
2009-04-22 06:01:20
User: eastwind
5

Require boxes and / or cowsay packages.

After input boxes -d dog , type your text and then press ctrl + d . Same goes for cowsay .

toilet -f big ReadMe
2009-04-22 05:48:13
User: eastwind
0

need toilet package , same goes for figlet

showfigfonts | less : give the list of font available for options

moon-buggy
2009-04-22 05:41:40
User: eastwind
-4

sudo apt-get install moon-buggy

An ascii 2D game where you control a mooncar and try to avoid moonhole by jumping (press space )

bb
2009-04-22 05:33:25
User: eastwind
0

sudo apt-get install bb

A demoscene intro in ascii art with tracker song

ldapsearch -v -H ldap://<server> -x -D cn=<johndoe>,cn=<users>,dc=<ourdomain>,dc=<tld> -w<secret> -b ou=<lazystaff>,dc=<ourdomain>,dc=<tld> -s sub sAMAccountName=* '*' | perl -pne 's/(\d{11})\d{7}/"DATE-AD(".scalar(localtime($1-11644473600)).")"/e'
2009-04-22 00:57:34
User: flux
Functions: perl
4

When Ldapsearch queries an Active directory server, all the dates are shown using a timestamp of 18 digits. This perl regexp decodes them in a more human friendly notation. 11644473600 corresponds to some microsoft epoch.

cal 09 1752
2009-04-22 00:13:19
User: flux
Functions: cal
Tags: date fun
10

The British Government entering in the Gregorian era.

ls /home | head -64 | barcode -t 4x16 | lpr
2009-04-21 22:54:45
User: flux
Functions: head ls
Tags: printing
8

64 elements max on 16 rows, 4 cols.

GNU Barcode will adapt automagically the width and the eight of your elements to fill the page.

Standard output format is PostScript.

( cat badfile.log ; tac badfile.log | tac ) > goodfile.log
2009-04-21 22:06:05
User: flux
Functions: cat tac
15

man tac

When there is a bad block in the middle of your file, you can see its begninning with `cat' and its end with `tac'. But both commands terminates with an error. So this sequence rebuilds a new file without badblock.

find . -maxdepth 1 -type f -name '*.sh' -o -name '*.txt'
apt-get moo
for i in sys dev proc; do sudo mount --bind /$i /mnt/xxx/$i; done
2009-04-20 16:52:14
User: amosshapira
Functions: mount sudo
Tags: bash mount chroot
3

The command is useful when, e.g., booting an existing system with a rescue or installation CD where you need to chroot into the hard-disk and be able to do stuff which accesses kernel info (e.g. when installing Ubuntu desktop with LVM2 you need to mount and chroot the hard disk from a shell window in order to install packages and run initramfs inside chroot).

The command assumes that /mnt/xxx is where the chroot'ed environment's root file system on the hard disk is mounted.

sudo dpkg-reconfigure tzdata
2009-04-20 02:08:23
User: hank
Functions: sudo
Tags: Ubuntu time
3

Reconfigures time zone in Ubuntu, which I cannot figure out how to do through the GUI. Worked like a charm to set my time zone to CEST from EDT.

wajig large
2009-04-19 20:26:26
User: udim
Tags: Debian wajig
14

Requires the "wajig" package to be installed.

dlocate [ package | string ]
2009-04-19 20:19:06
User: udim
Tags: Debian
4

This is the fastest method to search the Debian package database.

Requires the dlocate package. The dlocate db updates periodically, but you may force an update with

# dlocate-update

awk 'BEGIN {srand()} {print int(rand()*1000000) "\t" $0}' FILE | sort -n | cut -f 2-
2009-04-19 20:04:58
User: udim
Functions: awk cut sort
-3

Replace FILE with a filename (or - for stdin).

find -type f -printf '%P\000' | egrep -iz '\.(avi|mpg|mov|flv|wmv|asf|mpeg|m4v|divx|mp4|mkv)$' | sort -z | xargs -0 ls -1
sl
emerge -epv world | grep USE | cut -d '"' -f 2 | sed 's/ /\n/g' | sed '/[(,)]/d' | sed s/'*'//g | sort | uniq > use && grep ^- use | sed s/^-// | sed ':a;N;$!ba;s/\n/ /g' > notuse && sed -i /^-/d use && sed -i ':a;N;$!ba;s/\n/ /g' use
2009-04-19 07:54:08
User: Keruspe
Functions: cut grep sed sort uniq
Tags: Gentoo emerge USE
1

This command puts all the flags of the USE variable actually used by the packages you emerged to the file "use", and those which are unused but available to the file "notuse"

mount --bind /old/directory/path /new/directory/path
2009-04-19 01:44:59
User: dryicerx
Functions: mount
4

Like symlinked directories, you can mount a directory at a different location. For example mounting a directory from one location in to the http root without having to make your program follow symlinks or change permissions when reading.