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

All commands from sorted by
Terminal - All commands - 10,549 results
rsync -avzhP <[[user@]host1:]directory1> <[[user@]host2:]directory2>
du -h --time --max-depth=1 | sort -hr
xset dpms force off
cp data.{json,yaml}
mv data.{json,yaml}
2013-04-25 07:47:32
User: bunam
Functions: mv
Tags: json yaml
2

since Mozai said that JSON is a subset of YAML ;)

cat data.json >data.yml
2013-04-25 04:09:58
User: Mozai
Functions: cat
Tags: json yaml
-1

Valid JSON is a subset of YAML; no transformation is necessary; however, YAML has many syntax features that are not valid JSON, so you can't do the reverse as easily.

xset dpms force standby
2013-04-24 22:46:51
User: doherty
Tags: bash xset
2

echo 'alias monitor_off="sleep 1; xset dpms force standby"' >> ~/.bash_aliases ; . ~/.bash_aliases # now monitor_off does what you think

ruby -ryaml -rjson -e 'puts YAML.dump(JSON.parse(STDIN.read))' < file.json > file.yaml
python -c 'import sys, yaml, json; yaml.dump(json.load(sys.stdin), sys.stdout, default_flow_style=False)' < file.json > file.yaml
2013-04-24 00:31:39
User: tebeka
Functions: python
Tags: python json yaml
3

Convert JSON to YAML.

Note that you'll need to have PyYaml installed.

python -c 'import sys, yaml, json; json.dump(yaml.load(sys.stdin), sys.stdout, indent=4)' < file.yaml > file.json
2013-04-24 00:28:55
User: tebeka
Functions: python
Tags: python json yaml
0

Converts YAML file to JSON.

Note that you'll need to install PyYAML. Also some YAML data types (like dates) are not supported by JSON).

ffmpeg -loop 1 -i image.png -i sound.mp3 -shortest video.mp4
dvgrab -t -noavc -nostop -f hdv capturefile - | ffplay -x 640 -y 360
2013-04-23 14:40:02
User: odaibanet
Tags: video,
0

Grabs video from dv firewire camera, saves it on file and plays it scaled down on ffplayer.

Useful to do Google+ Hangouts, and if the internet connection fails, there is still the recorded backup on the computer.

"capturefile" is the filename prefix that will be stored on disc.

vim ~/.inputrc
2013-04-23 02:50:11
User: ekinertac
Functions: vim
Tags: bash search
-8

This allows you to search through your history using the up and down arrows ? i.e. type "cd /" and press the up arrow and you'll search through everything in your history that starts with "cd /".

figlet -f roman message
lvextend -r -L+100G /dev/VG/LV
2013-04-20 14:29:11
User: bbelt16ag
2

this command extends your logical volume. then it does a resize2fs on it as well. added the -r switch to make it launch resize.

sdparm -s SCT=36000 --save /dev/sdb
2013-04-19 13:26:18
User: mhs
Tags: sdparm
2

So I had this 2TB Seagate external disk/USB enclosure which by default would spin-down its internal drive (it enters a standby mode) after four minutes of inactivity.. Spinning-up the inactive drive was an annoying delay when accessing files and also it severely interfered with NFS.. SCT stands for "Standby Condition Timer".

To completely disable SCT:

sdparm --clear STANDBY -6 /dev/sdb

To return to original (default) SCT settings:

sdparm -D -p 0x1a -6 /dev/sdb

To verify the settings (before and after):

sdparm -a /dev/sdb

No need for vendor-provided MSWIN tools, etc.

sudo apt-get install linux-headers-`uname -r`
2013-04-18 03:18:26
User: farazyashar
Functions: install sudo
2

Install the Linux kernel headers for currently running kernel version on Debian-based systems via apt-get

sudo sed -i 's/raspberrypi/pita1/' /etc/hosts /etc/hostname; sudo reboot
2013-04-16 07:27:41
User: egeoffray
Functions: sed sudo
0

Your computer's name is raspberrypi and you want to rename it to pita1.

This command will change both the hostname and the name used for netwrk communications.

sudo shutdown 3600 -P
2013-04-14 16:14:23
Functions: shutdown sudo
-3

You can easily stop shutdowning process by CTRL+C

firefox 'data:text/html, <html contenteditable>'
2013-04-14 02:13:03
User: LinuxMan
2

A commandline version of the notepad in a browser: http://www.commandlinefu.com/commands/view/12161/notepad-in-a-browser-type-this-in-the-url-bar

All credit to the origional author of this fantastic command, whos only failing as most of the comments pointed out was that it wasn't a command... well, now its a command. Send all upvotes to dtlp747.

sleep 10; poweroff
2013-04-13 22:07:15
User: xmuda
Functions: sleep
-10

If you are on your bed, waching a movie or if you are downloading something, but you whant to sleep. You can use these easy command to power off after X time. The time is in sec. if you whant to wait 1 H, use:

sleep 3600; poweroff

openssl aes-256-cbc -salt -in secrets.txt -out secrets.txt.enc
2013-04-13 19:33:37
User: jrdbz
1

To decrypt: openssl aes-256-cbc -d -in secrets.txt.enc -out secrets.txt.new

Reference: http://tombuntu.com/index.php/2007/12/12/simple-file-encryption-with-openssl

Optional parameter -a makes output base64 encoded, can be viewed in text editor or pasted in email

script -qf | tee >(nc -l -p 5000)
find . -type f -name "*.gz" | while read line ; do gunzip --to-stdout "$line" | bzip2 > "$(echo $line | sed 's/gz$/bz2/g')" ; done
2013-04-12 19:18:21
User: Kaurin
Functions: bzip2 find gunzip read
1

Find all .gz files and recompress them to bz2 on the fly. No temp files.

edit: forgot the double quotes! jeez!

less -p pattern file.txt