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

history autocompletion with arrow keys
This will enable the possibility to navigate in the history of the command you type with the arrow keys, example "na" and the arrow will give all command starting by na in the history.You can add these lines to your .bashrc (without &&) to use that in your default terminal.

delay: a simple scheduler
the "delay" utility is an invaluable tool for me. with gnu-screen it allows you to schedule something and have it run and output to the current terminal, unlike "at". You can also use it like "sleep" with seconds and also with date: delay until 13:33 friday && echo test get it from: http://onegeek.org/~tom/software/delay/current/delay.c (author: Tom Rothamel)

Print a date from 3 days ago
This command prints the Date (Not time) from 3 days ago (72 hours ago). This works on systems without GNU date (MacOSX , Solaris, FreeBSD).

do something else while waiting for an event, such as reboot
until (ssh root@10.1.1.39 2> /dev/null); do date; sleep 15; done In this case will execute "date" then "sleep 15" until we are able to ssh into server, such as after a reboot Could also be like: until ( ping 10.1.1.39 1> /dev/null); do echo "server 10.1.1.39 is down"; sleep 15; done

Quickly analyze apache logs for top 25 most common IP addresses.
This command is much quicker than the alternative of "sort | uniq -c | sort -n".

get a mysqldump with a timestamp in the filename and gzip it all in one go
Performs a mysqldump and gzip-compresses the output file with a timestamp in the resulting dump file. Inspect the file for integrity or fun with this command afterward, if you desire: $ zcat mysqldump-2009-06-12-07.41.01.tgz | less

Print a row of characters across the terminal
Print a row of characters across the terminal. Uses tput to establish the current terminal width, and generates a line of characters just long enough to cross it. In the example '#' is used. It's possible to use a repeating sequence by dividing the columns by the number of characters in the sequence like this: $ seq -s'~-' 0 $(( $(tput cols) /2 )) | tr -d '[:digit:]' or $ seq -s'-~?' 0 $(( $(tput cols) /3 )) | tr -d '[:digit:]' You will lose chararacters at the end if the length isn't cleanly divisible.

open manpage and search for a string
This will open the manpage for "foobar", and display all instances of "searched_string". You can traverse through them by pressing "n"

Ctrl+S Ctrl+Q terminal output lock and unlock
These are simple shortcuts to pause and continue terminal output, works in most terminals and screen multiplexers like screen. You can use it to catch something if things change too fast, and scroll with Shift + PgUp PgDown. On linux console ScrollLock can also be used.

Count the number of deleted files
It does not work without the verbose mode (-v is important)


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: