All commands (14,187)

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. 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.

Share Your Commands


Check These Out

Execute a command on logout
Execute a command on shell logout,and run it until is finished,then shell is closed.

Install pip with Proxy
Installs pip packages defining a proxy

Grab the first 3 octets of your ip addresses
For machines that have many ip blocks spanning different Class C's, this will show which ones.

cleanup /tmp directory
Cleans all files in /tmp that have been accessed at least 2 days ago.

Force machine to reboot no matter what (even if /sbin/shutdown is hanging)
This will cause your machine to INSTANTLY reboot. No un-mounting of drives or anything. Very handy when something has gone horribly wrong with your server in that co-location facility miles away with no remote hands! Suspect this works with all 2.2, 2.4 and 2.6 Linux kernels compiled with magic-syskey-request support.

Blink Caps Lock on HDD activity
Some computers these days don't have an HDD activity light, but they still have a useless caps-lock, so why not re-purpose that light to show HDD activity? Requires setleds and dstat and probably needs to run as root.

Create a file of a given size in linux
if the fs support sparse file,using truncate can create sparse file. http://en.wikipedia.org/wiki/Sparse_file

Check if a domain is available and get the answer in just one line
Returns nothing if the domain exists and 'No match for domain.com' otherwise.

Show crontabs for all users
added echo "### Crontabs for $user ####"; to make clear whose crontab is listed.

Get the Nth argument of the last command (handling spaces correctly)
Bash's history expansion character, "!", has many features, including "!:" for choosing a specific argument (or range of arguments) from the history. The gist is any number after !: is the number of the argument you want, with !:1 being the first argument and !:0 being the command. See the sample output for a few examples. For full details search for "^HISTORY EXPANSION" in the bash(1) man page.    Note that this version improves on the previous function in that it handles arguments that include whitespace correctly.


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: