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

Backup a file with a date-time stamp
$ buf myfile.txt This is useful when you are making small but frequent changes to a file. It keeps things organised and clear for another administrator to see what changed and at what time. An overview of changes can be deduced using a simple: $ ls -ltr

Dump mySQL db from Remote Database to Local Database
You can use this to dump you database from remote db to your local db.

A function to find the newest file of a set.
Usage example: $newest Desktop/* Replace "-nt" with "-ot" for oldest. Run $shopt -s dotglob first to include dotfiles.

Which processes are listening on a specific port (e.g. port 80)
swap out "80" for your port of interest. Can use port number or named ports e.g. "http"

Remove today's installed packages

Slow down IO heavy process
Some IO intensive process make the system unresponsive. This function periodically starts/stops a process, which hopefully releases some resources for other activities. This function is useful when ionice is not available

Colorize grep output

Use curl to save an MP3 stream
I use this with cron to timeshift radio programs from a station's live stream. You will get an error message at the end like "curl: (28) Operation timed out after 10000 milliseconds with 185574 bytes received"; to suppress that but not other error messages, you can append "2>&1 | grep -v "(28)"" to the end of the command.

tee to a file descriptor
the tee command does fine with file names, but not so much with file descriptors, such as &2 (stderr). This uses process redirection to tee to the specified descriptor. In the sample output, it's being used to tee to stderr, which is connected with the terminal, and to wc -l, which is also outputting to the terminal. The result is the output of bash --version followed by the linecount

diff process output
Execute a process or list of commands in the given interval and output the difference in output.


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: