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

Commands by Bonster from sorted by
Terminal - Commands by Bonster - 27 results
function :h { vim +":h $1" +'wincmd o' +'nnoremap q :q!<CR>' ;}
2013-04-04 08:12:28
User: Bonster
Functions: vim
-1

simple function i found somewhere to open vim help page from the shell

use :h like you would in vim

tree -L 1 -ChDit | tac
2012-07-28 13:47:41
User: Bonster
4

Go look at sample output first

This is kind of like the ls command but displays by modify time with size, date and color.

The newest files at the bottom of the screen (reverse using tac)

atool -x filename
2012-06-14 21:40:57
User: Bonster
0

easy extract files without remembering all the commands for different formats.

atools does other things also like listing archives content, converting from one format to another ...etc. Supports whatever is install on your system such as tar, zip, rar, 7z, rpm, deb, cab , ace, jar ...etc

for i in ?.ogg; do mv $i 0$i; done
2012-05-15 02:52:52
User: Bonster
Functions: mv
18

from

1.ogg

2.ogg

3.ogg

10.ogg

11.ogg

to

01.ogg

02.ogg

03.ogg

10.ogg

11.ogg

alias vless='/usr/share/vim/vimcurrent/macros/less.sh'
2012-04-28 23:01:25
User: Bonster
Functions: alias
7

use vim like less command pager but with color highlighting = pretty :p

also u can use /usr/share/vim/vim73/macros/less.sh

unoconv -f pdf filename.doc
2012-04-07 12:38:51
User: Bonster
6

convert to pdf and many other formats and vise versa

to get a list of supported formats, run

unoconv --show
xfwm4 --replace
inxi -F
alias o='xdg-open "$@" 2>/dev/null'
2011-12-26 08:52:22
User: Bonster
Functions: alias
-3

use xdg-open without looking at error messages

examples msg:

(nautilus:3955): Gtk-WARNING **: Theme parsing error: Notebook.css:21:15: Junk at end of value

unace x [file]
pastebinit [file]
2011-12-22 14:21:47
User: Bonster
-12

paste file to pastebin (other similar sites available, read man page).

make sure to have 'pastebinit' install

alias gtasks='chromium-browser --app=https://mail.google.com/tasks/ig'
2011-12-05 22:11:00
User: Bonster
Functions: alias
-4

requires a gmail account, it opens Google tasks in a self contain window, to write your todo list and have it sync online yay =)

tpb() { wget -U Mozilla -qO - $(echo "http://thepiratebay.org/search/$@/0/7/0" | sed 's/ /\%20/g') | grep -o 'http\:\/\/torrents\.thepiratebay\.org\/.*\.torrent' | tac; }
2011-10-26 12:15:55
User: Bonster
Functions: echo grep sed wget
3

usage: tpb searchterm

example: tpb the matrix trilogy

This searches for torrents from thepiratebay and displays the top results in reverse order,

so the 1st result is at the bottom instead of the top -- which is better for command line users

mplayer -rtsp-stream-over-tcp -user-agent QuickTime/7.6.4 http://trailers.apple.com/movies/HDmovie-h720p.mov
alias calc='python -ic "from math import *; from random import *"'
2011-10-24 08:15:41
User: Bonster
Functions: alias
0

use python as calculator, press ctrl+d to exit

reminder: when doing factions add atleast one decimal number like so

22.0/7 or 22/7.0

awk '{a[i++]=$0} END {for (j=i-1; j>=0;) print a[j--] }'
2011-10-23 10:28:23
User: Bonster
Functions: awk
1

awk reverse order of lines (emulates "tac")

gsettings set org.gnome.desktop.background picture-uri file://"$(find ~/Wallpapers -type f | shuf -n1)"
2011-10-21 12:24:58
User: Bonster
Functions: set
3

Change Random Wallpaper on Gnome 3

sudo aptitude remove -P $(dpkg -l|awk '/^ii linux-image-2/{print $2}'|sed 's/linux-image-//'|awk -v v=`uname -r` 'v>$0'|sed 's/-generic//'|awk '{printf("linux-headers-%s\nlinux-headers-%s-generic\nlinux-image-%s-generic\n",$0,$0,$0)}')
2011-04-25 05:19:57
User: Bonster
Functions: awk sed sudo
-1

Same as 7272 but that one was too dangerous

so i added -P to prompt users to continue or cancel

Note the double space: "...^ii␣␣linux-image-2..."

Like 5813, but fixes two bugs: [1]This leaves the meta-packages 'linux-headers-generic' and 'linux-image-generic' alone so that automatic upgrades work correctly in the future. [2]Kernels newer than the currently running one are left alone (this can happen if you didn't reboot after installing a new kernel).

(sp-sc sop://broker.sopcast.com:3912/80562 8908 10999 &>/dev/null &); sleep 10; wait $(vlc http://localhost:10999); killall sp-sc
2011-04-06 00:08:38
User: Bonster
Functions: killall sleep wait
0

requires sp-auth installed

This command will auto kill sp-sc after vlc is closed, so u wont have to do it manually

plowdown http://www.megaupload.com/?d=abc1234567
2011-04-01 09:52:39
User: Bonster
3

you need to have plowshare installed

http://code.google.com/p/plowshare/

plowshare supports Megaupload, Rapidshare, 2Shared, 4Shared, ZShare, Badongo, Divshare.com, Depositfiles, Netload.in, Sendspace, Usershare, x7.to and some others file sharing services.

lynx --dump http://www.seeon.tv/channels| grep "/channels"|awk '{print $2}'|sort -u|while read links; do lynx --dump "$links"|awk '/view/ {print $2}'|sort -u; done
2011-04-01 05:58:20
User: Bonster
Functions: awk grep read sort
-1

This shows a list of channels from seeon.tv website to watch shows and movies

java -jar /path/to/filename.jar
2011-04-01 05:44:56
User: Bonster
-1

Use this to make a launcher for Java apps ( .jar files ) such as with jdownloader

catfish --fileman=nautilus --path=/home/<username> --hidden --method=find
2011-04-01 05:33:00
User: Bonster
0

Change the launcher of catfish to use a different file manager

Example:

using Find

catfish --fileman=nautilus --path=/home/ --hidden --method=find

using Locate

catfish --fileman=pcmanfm --path=/ --hidden --method=locate

Update Locate DB

sudo updatedb

gconftool-2 --set "/apps/metacity/general/action_middle_click_titlebar" --type string "minimize"
wineserver -k
2011-03-30 08:32:20
User: Bonster
6

kills all wine running apps and processes.

Make a hotkey for it when running wine games in fullscreen and it locks. This is a great way to escape from it.