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:
Same functionality without using bash functions.
Repair each node in sequence. Make sure you change the IP replacements to match your environment
When bootstrapping or repairing a node this is a simple way to keep tabs on what a node is actively doing.
Pass the files path to finfo(), can be unix path, dos path, relative or absolute. The file is converted into an absolute nix path, then checked to see if it is in-fact a regular/existing file. Then converted into an absolute windows path and sent to "wmic". Then magic, you have windows file details right in the terminal. Uses: cygwin, cygpath, sed, and awk. Needs Windows WMI "wmic.exe" to be operational. The output is corrected for easy...
finfo "/cygdrive/c/Program Files/notepad.exe"
Send microphone audio to another computer using netcat and arecord.
Connect to the stream using "nc [other ip] 3333|aplay"
You can set up two-way communication by piping audio the reverse direction on another port:
arecord -D hw:0,0 -f S16_LE -c2|nc -l 3333 &;nc -l 3334|aplay
$ip=[machine1_ip];arecord -D hw:0,0 -f S16_LE -c2|nc $ip 3334 &;nc $ip 3333|aplay
Generates a bash array and uses it to select a random image from ~/wallpapers.
Prompts for network name (SSID) and password, and generates (as qr-wifi.png) a WiFi QR code (e.g. "WIFI:S:mynet;T:WPA;P:mypass;;" for mynet/mypass). Dependencies [sudo apt-get install]: qrencode zenity
Watch a dig in progress
The glob pattern * expands to all files, no need for the 'ls' command.
The quotes around "$i" make sure filenames with spaces in them are handled correctly.
mplayer determines if it is a media file and plays it, or gives errors and the loop asks if this file has to be removed.
Note: %~nI expands %I to a file name only (cf. http://technet.microsoft.com/en-us/library/bb490909.aspx)
Requires ImageMagick to be installed; mogrify is the lesser-known sibling to convert -- it overwrites your original images, but allows you to work on batches of files without resorting to a loop.
Old drive with lots of music or unsorted drive? This command will play all mp3 files in a folder and after playing one song or pressing q, it will ask you if you want to delete the file.
The mogrify command is also part of the ImageMagick suite, and is made to make changes to files in place.
I sometimes have use an usb stick to distribute files to several standalone "internet" pc's. I don't trust these machines period. The sticks I have do not have a write protection. So as a added security measure I fill the unused space on the (small) usb stick with a file with randomly generated bits. Any malware that tries to write to this stick will find no space on it.
Tested on slackware 14
Note: you may need root access to write to the device. This depends on your mount options.
This lists the number of ogg/mp3/wav/flac files in each subdirectory of the current directory. The output can be sorted by piping it into "sort -n".
Then you can remove the specific entry:
iptables -D INPUT 10
Just make sure these are set:
Else your changes won't stick when you restart iptables.
Shows all available keyboard bindings in bash. Pretty printing.
This command starts up the time synchronization service.
This command restarts mysql service.
Prepend text to a file. It doen't need temporary files, ed or sed.
Fetches latest stable release version from first entry between tags
You can omit the -d to see what's inside directories. In that case, you may want -a to see dotfiles inside those directories. (Otherwise you don't need -a since you're explicitly looking at them.)