commandlinefu.com is the place to record those command-line gems that you return to again and again.
Delete that bloated snippets file you've been using and share your personal repository with the world. 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.
You can sign-in using OpenID credentials, or register a traditional username and password.
First-time OpenID users will be automatically assigned a username which can be changed after signing in.
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.
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:
Wow, didn't really expect you to read this far down. The latest iteration of the site is in open beta. It's a gentle open beta-- not in prime-time just yet. It's being hosted over at UpGuard (link) and you are more than welcome to give it a shot. Couple things:
Short command, easy to remember
Probably only works with GNU du and modern perls.
Change Seville for your prefered city.
parse `lsmod' output and pass to `dot' drawing utility then finally pass it to an image viewer
Nothing special required, just wget, sed & tr!
Create a binary clock.
Sometimes you need to use a port that is already opened by some program , and you don't know who to "kill" for it to release - so, now you do !
This recursively downloads all images from a given website to your /tmp directory. The -nH and -nd switches disable downloading of the directory structure.
If you spend most of your time in front of the terminal, leave is a useful reminder. Leave can have absolute form: leave 1555 reminds you to leave at 3:55PM
cp /work/host/phone/ui/main.cpp /work/target/phone/ui/main.cpp
The entire command line typed so far.
Ever ask yourself "How much data would be lost if I pressed the reset button?"
Scary, isn't it?
Tee can be used to split a pipe into multiple streams for one or more process to work it. You can add more " >()" for even more fun.
Knock on ports to open a port to a service (ssh for example) and knock again to close the port. You have to install knockd.
See example config file below.
logfile = /var/log/knockd.log
sequence = 3000,4000,5000
seq_timeout = 5
command = /sbin/iptables -A INPUT -i eth0 -s %IP% -p tcp --dport 22 -j ACCEPT
tcpflags = syn
sequence = 5000,4000,3000
seq_timeout = 5
command = /sbin/iptables -D INPUT -i eth0 -s %IP% -p tcp --dport 22 -j ACCEPT
tcpflags = syn
History usually only gives the command number and the command. This will add a timestamp to the history file.
Note: this will only put the correct timestamp on commands used after the export is done. You may want to put this in your .bashrc
I have a bash alias for this command line and find it useful for searching C code for error messages.
The -H tells grep to print the filename. you can omit the -i to match the case exactly or keep the -i for case-insensitive matching.
This find command find all .c and .h files
Very handy to bring the word currently under the cursor into a :s command in Vim.
If the cursor was on the word "eggs":
:s/ ==> :s/eggs
youtube-dl has this functionality built in. If you're running an older version of youtube-dl, you can update it using `youtube-dl -U` (although if you have an older version, it probably doesn't download youtube videos anyway.)
youtube-dl --help will show you other options that may come in useful.
Find files in a specific date range - in this case, the first half of last year.
-newermt = modification time of the file is more recent than this date
GNU find allows any date specfication that GNU date would accept, e.g.
find . -type f -newermt "3 years ago" ! -newermt "2 years ago"
find . -type f -newermt "last monday"
Instead of opening your browser, googling "whatismyip"...
Also useful for scripts.
dig can be found in the dnsutils package.
This uses Bash's "process substitution" feature to compare (using diff) the output of two different process pipelines.
Forwards localhost:1234 to machine:port, running all data through your chain of piped commands. The above command logs inbound and outbound traffic to two files.
Tip: replace tee with sed to manipulate the data in real time (use "sed -e 's/400 Bad Request/200 OK/'" to tweak a web server's responses ;-) Limitless possibilities.