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.

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.

UpGuard checks and validates configurations for every major OS, network device, and cloud provider.

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 by lordtoran from sorted by
Terminal - Commands by lordtoran - 16 results
whatinstalled () { local cmdpath=$(realpath -eP $(which -a $1 | grep -E "^/" | tail -n 1) 2>/dev/null) && [ -x "$cmdpath" ] && dpkg -S $cmdpath 2>/dev/null | grep -E ": $cmdpath\$" | cut -d ":" -f 1; }
2016-11-08 16:13:10
User: lordtoran
Functions: cut grep tail which

Put this one-line function somewhere in your shell init, re-login and try

whatinstalled <command>

This is an elaborate wrapper around "dpkg -S", with numerous safeguards. Symlinks and command aliases are resolved. If the searched command is not an existing executable file or was installed by some other means than dpkg/apt, nothing is printed to stdout, otherwise the package name.

alias bman='man --html=x-www-browser'
2016-10-23 17:59:47
User: lordtoran
Functions: alias
Tags: man groff

An easy alias for opening a manpage, nicely HTML formatted, in your set internet browser.

If you get a "command exited with status 3" error you need to install groff.

echo "Gold price is" $(wget https://rate-exchange-1.appspot.com/currency\?from=XAU\&to=USD -q -O - | jq ".rate") "USD"
2015-11-11 14:20:06
User: lordtoran
Functions: echo wget
Tags: wget finance jq

Returns the current price of a troy ounce of gold, in USD. Requires the "jq" JSON parser.

wget -O - http://list.iblocklist.com/\?list\=ydxerpxkpcfqjaybcssw\&fileformat\=p2p\&archiveformat\=gz | gunzip > ~/ipfilter.p2p
2015-10-11 13:04:08
User: lordtoran
Functions: gunzip wget

Downloads Bluetack's level 1 IP blocklist in .p2p format, suitable for various Bittorrent clients.

cd ~/.minetest/mods && git clone --recursive https://github.com/$1/$2.git
2015-09-30 19:24:59
User: lordtoran
Functions: cd

Where $1 = author and $2 = mod name

You need to be running a daily build of Minetest (for example from the 'minetestdevs/daily-builds' PPA), or some bleeding edge mods will not work or crash the game.

Update a mod by entering its subdirectory under ~/.minetest/mods and doing

git pull && git submodule update --recursive --remote --init
sudo aa-complain /etc/apparmor.d/usr.bin.chromium-browser
2015-09-30 18:56:28
User: lordtoran
Functions: sudo

If AppArmor is installed with all profiles enforced, Chromium may refuse to start, printing a "failed to launch zygote process" error on stderr.

This command switches the Chromium profile from enforce to complain mode, effectively un-sandboxing the browser, but depending on the system setup it may be a smaller deal than a nonfunctional application.

pkill imwheel && imwheel &
sudo sh -c "aptitude update; aptitude -DrVWZ full-upgrade; aptitude autoclean; exit"
2015-09-28 23:48:05
User: lordtoran
Functions: sh sudo

This has been my "sysupgrade" alias since ca. 2006, first used on Debian Sid, then Sabayon, and it still does its duty on Mint nowadays without breaking stuff.

pkill plasma-desktop && plasma-desktop
2015-09-28 23:36:24
User: lordtoran

This can help with serious GUI lockups in KDE. It will only restart Plasma + widgets, not your session, so all your programs will stay running.

sudo sh -c "rm /usr/share/mime/packages/kde.xml && update-mime-database /usr/share/mime"
wallpaper -w 800 -x 16384 -a 1.7 -b 1.85 *
2015-09-28 23:18:39
User: lordtoran

List images between 800 and 16384 pixels wide that can be displayed sized and trimmed on a widescreen display.

Requires the "wallpaper" utility.

echo "BTC rate is" $(wget https://api.bitcoinaverage.com/ticker/global/EUR/ -q -O - | jq ".last") "?"
2015-09-28 23:03:59
User: lordtoran
Functions: echo wget
Tags: wget bitcoin jq btc

Returns the global weighted BTC rate in EUR. Requires the "jq" JSON parser.

^Z <...> %
2011-11-20 00:12:47
User: lordtoran
Tags: job control

Press ^Z, do what you need to do on the shell, then input % to resurrect the suspended job.

file <filename>
2011-11-19 23:39:29
User: lordtoran
Functions: file

Some shell newbies don't know this very handy file management related command so I decided to include it here.

You need to have the "file" package installed.

if [[ $EUID -ne 0 ]]; then echo 'Root permissions required! Exiting.'; exit; fi
2011-11-19 23:06:52
User: lordtoran
Functions: echo

This example code is intended to be used as a root permissions check in a script. It makes use of the $EUID (effective user ID) environment variable which is fully su- and sudo-safe.

play -c 2 -n synth pinknoise band -n 2500 4000 tremolo 0.03 5 reverb 20 gain -l 6
2011-11-19 22:40:42
User: lordtoran
Tags: audio sox noise

This generates some powerful but relatively unobtrusive waterfall-like noise. Good if you need to get serious stuff done while your next-door neighbor is throwing a very loud party.

You need the sox package installed.