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.
If you have a new feature suggestion or find a bug, please get in touch via http://commandlinefu.uservoice.com/
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:
Convert Text to HTML
Should work on all systems that use dpkg and APT package management.
Useful for deleting old unused log files.
Delete loopback file device
lofiadm -d /dev/lofi/1
If you use newsgroups then you'll have come across split files before. Joining together a whole batch of them can be a pain so this will do the whole folder in one.
Make ogg file from wav file
Rip audio tracks from CD to wav files in current dir
add (server-start) in .emacs
I'm working in a group project currently and annoyed at the lack of output by my teammates. Wanting hard metrics of how awesome I am and how awesome they aren't, I wrote this command up.
It will print a full repository listing of all files, remove the directories which confuse blame, run svn blame on each individual file, and tally the resulting line counts. It seems quite slow, depending on your repository location, because blame must hit the server for each individual file. You can remove the -R on the first part to print out the tallies for just the current directory.
Find Word docs by filename in the current directory, convert each of them to plain text using antiword (taking care of spaces in filenames), then grep for a search term in the particular file.
(Of course, it's better to save your data as plain text to make for easier grepping, but that's not always possible.)
Requires antiword. Or you can modify it to use catdoc instead.
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
A common mistake in Bash is to write command-line where there's command a reading a file and whose result is redirected to that file.
It can be easily avoided because of :
1) warnings "-bash: file.txt: cannot overwrite existing file"
2) options (often "-i") that let the command directly modify the file
but I like to have that small function that does the trick by waiting for the first command to end before trying to write into the file.
Lots of things could probably done in a better way, if you know one...
This just combines multiple mp3's into one mp3 file. Basically it is a easy join for mp3's
That command bypass the entry limit specifing page results size, when the search arrive to the limit ldapsearch magically reiterate it from the last entry.
Output manpage as plaintext using cat as pager: man -P cat commandname
And redirect its stdout into a file: man -P cat commandname > textfile.txt
Example: man -P cat ls > man_ls.txt
This is better than doing a "for `find ...`; do ...; done", if any of the returned filenames have a space in them, it gets mangled. This should be able to handle any files.
Of course, this only works if you have rename installed on your system, so it's not a very portable command.