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

Create a backdoor on a machine to allow remote connection to bash
This will launch a listener on the machine that will wait for a connection on port 1234. When you connect from a remote machine with something like : nc 192.168.0.1 1234 You will have console access to the machine through bash.

Make .bashrc function to backup the data you changed last houres
The original overwrites any previous backups, and only saves exactly the last hours worth, but not 1 hour + 1 minute. This version creates or appends files, and backs up everything since the last backup (using the backups timestamp as the reference), plus it uses TMPDIR if set.

Get AWS temporary credentials ready to export based on a MFA virtual appliance
You might want to secure your AWS operations requiring to use a MFA token. But then to use API or tools, you need to pass credentials generated with a MFA token. This commands asks you for the MFA code and retrieves these credentials using AWS Cli. To print the exports, you can use: `awk '{ print "export AWS_ACCESS_KEY_ID=\"" $1 "\"\n" "export AWS_SECRET_ACCESS_KEY=\"" $2 "\"\n" "export AWS_SESSION_TOKEN=\"" $3 "\"" }'` You must adapt the command line to include: * $MFA_IDis ARN of the virtual MFA or serial number of the physical one * TTL for the credentials

Advanced python tracing
Trace python statement execution and syscalls invoked during that simultaneously

Tells you where a command is in your $PATH, but also wether it's a link and to what.
You may also use the $(which foo) variant instead of backticks. I personnaly have an alias ll='ls -l'.

resize(1/2) the image using imagemagick

send incoming audio to a Icecast server (giss.tv)
easy way to setup an "internet radio sation", pre-requisite, create an account at an icecast server, in this example, just created beforehand an account at giss.tv. Change the word password, with the respective real password you created at server. Make sure to have installed rec, oggnec, oggfwd and tee. I have a mixer connected at line in, so I can mix music and microphone. This also will produce a local recorded copy of the session, it will be called "streamdump.ogg"

Go up multiple levels of directories quickly and easily.
Change to your taste. Much quicker than having to add 'cd' every time. Add it to your .bashrc or .bash_profile.

Exclude inserting a table from a sql import
Starting with a large MySQL dump file (*.sql) remove any lines that have inserts for the specified table. Sometimes one or two tables are very large and uneeded, eg. log tables. To exclude multiple tables you can get fancy with sed, or just run the command again on subsequently generated files.

List hostnames of all IPs


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: