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

Restore mysql database uncompressing on the fly.
This way you keep the file compressed saving disk space. Other way less optimal using named pipes: mysql -uroot -p'passwd' database <

check open ports without netstat or lsof

Start a quick rsync daemon for fast copying on internal secure network
"Sample output" shows a minimalistic configuration file.

delete a particular line by line number in file
deletes line 3 in known_hosts text file

Assign top-level JSON entries to shell variables
A recursive version might be useful too. /dev/tty is used to show which shell variables just got defined.

Sysadmin day date of any given year
Calculate the date of Sysadmin day (last Friday of July) of any given year

Check syntax of all Perl modules or scripts underneath the current directory
Finds all *.p[ml]-files and runs a perl -c on them, checking whether Perl thinks they are syntactically correct

Create a random password encrypted with md5 with custom lenght
This was useful to generate random passwords to some webpage users, using the sample code, inside a bash script

A signal trap that logs when your script was killed and what other processes were running at that time
trap is the bash builtin that allows you to execute commands when the current script receives a particular signal. Uses $0 for the script name, $$ for the script PID, tee to output to STDOUT as well as a log file and ps to log other running processes.

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"


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: