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:
Uses the extremely cool utilities netcat and expect.
"expect" logs in & monitors for server PING checks.
When a PING is received it sends the PONG needed to stay connected.
IRC commands to try: HELP, TIME, MOTD, JOIN and PRIVMSG
The "/" in front of IRC commands are not needed, e.g. type JOIN #mygroup
Learn about expect: http://tldp.org/LDP/LGNET/issue48/fisher.html
The sample output shows snippets from an actual IRC session.
Please click UP button if you like it!
Bash process substitution which curls the website 'hashbang.sh' and executes the shell script embedded in the page.
This is obviously not the most secure way to run something like this, and we will scold you if you try.
The smarter way would be:
Download locally over SSL
> curl https://hashbang.sh >> hashbang.sh
Verify integrty with GPG (If available)
> gpg --recv-keys 0xD2C4C74D8FAA96F5
> gpg --verify hashbang.sh
Inspect source code
> less hashbang.sh
> chmod +x hashbang.sh
Streams youtube-dl video to mplayer.
syt 'youtube.com/link' 'anotherlinkto.video'
Uses mplayer controls
Linux offers an interesting option to restrict the use of dmesg. It is available via /proc/sys/kernel/dmesg_restrict.
You can check the status with:
Alternatively you can use sysctl:
sudo sysctl -w kernel.dmesg_restrict=1
To make your change persistent across reboot, edit a fille in /etc/sysctl.d/.
usage = crontest "/path/to/bin"
This version of this function will echo back the entire command so it can be copied/pasted to crontab. Should be able to be automagically appended to crontab with a bit more work. Tested on bash and zsh on linux,freebsd,aix
The "-u USER" is optional if root user is used
VPS server hosts suspect DOS attack if PPS is too high. This limits packets at the interface level. Do "sudo apt-get install iptables-persistent" to make persistent, or, if you already have, reconfigure with "sudo dpkg-reconfigure iptables-persistent"
Extracts yours bookmarks out of sqlite with the format:
Updated according to flatcap's suggestion, thanks!
Prior to working on/modifying a file, use the 'install -m' command which can both copy files, create directories, and set their permissions at the same time. Useful when you are working in the public_html folder and need to keep the cp'd file hidden.
for f in input/*; do BN=$(basename "$f"); ffmpeg -i "$f" -vn "temp/$BN.flac"; sox "temp/$BN.flac" "temp/$BN-cleaned.flac" noisered profile 0.3; ffmpeg -i "$f" -vcodec copy -an "temp/$BN-na.mp4"; ffmpeg -i "temp/$BN-na.mp4" -i "temp/$BN-cleaned.flac" "output/$BN"; done
This was over the 255 character limit and I didn't feel like deliberately obfuscating it.
1. Create 'input', 'output' and 'temp' directories.
2. Place the files that you want to remove the hiss/static/general noise from in the input directory.
3. Generate a noise reduction profile with sox using 'sox an_input_file.mp4 -n trim x y noiseprof profile', where x and y indicates a range in seconds that only the sound you want to eliminate is present in.
4. Run the command.
There are lots of different cow options to use, this script will show them all
If you want to create fast a very big file for testing purposes and you do not care about its content, then you can use this command to create a file of arbitrary size within less than a second. Content of file will be all zero bytes.
The trick is that the content is just not written to the disk, instead the space for it is somehow reserved on operating system level and file system level. It would be filled when first accessed/written (not sure about the mechanism that lies below, but it makes the file creation super fast).
Instead of '1G' as in the example, you could use other modifiers like 200K for kilobytes (1024 bytes), 500M for megabytes (1024 * 1024 bytes), 20G for Gigabytes (1024*1024*1024 bytes), 30T for Terabytes (1024^4 bytes). Also P for Penta, etc...
Command tested under Linux.
Clears your clipboard if xsel is installed on your machine.
If your xsel is dumb, you can also use
xsel --clear --clipboard
Remove duplicate lines whilst keeping order and empty lines
This is the way to get access to your Firefox history...
For all users of https://addons.mozilla.org/de/firefox/addon/speed-dial/