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:
The input images are assume to have the "JPG" extension. Mogrify will overwrite any gif images with the same name! Will not work with names with spaces.
If you want avoid to be annoyed when playing your favourite video files with your video player, first run this command to stash wrong files (and test tricks to play these wrong files).
Remove the "echo" to actually archive.
Many similar commands are found on commandlinefu but I end up needing this very specific one from time to time.
To extract any of them, use the standard tar.bz2 extract command:
tar xvjf folder1.tar.bz2
This will find all the -Xmx[BIGINT] running on a system, add them up for you and give you the total.
Support several arguments.
Usage: ytmp3 "YTurl" "YTurl2" "YTurl3" "YTurlN"
Uses the shift command to let you extract the .mp3 from as many youtube urls as you like (or wherever else youtube-dl is supported)
Orginal chunk of code:
youtube-dl -q -t --extract-audio --audio-format mp3 URL
Set variable 'input' to a set of flac files.
Usage: google "[search string]"
Example: google "something im searching for"
This will launch firefox and execute a google search in a new tab with the provided search string.
You must provide the path to your Firefox binary if using cygwin to $ff or create an alias like follows:
alias firefox='/cygdrive/c/Program Files (x86)/Mozilla Firefox/firefox.exe'
Most Linux flavors with Firefox installed will use just ff="firefox" and even OSX.
Quickly remove the conflicting line (key) from current users known_hosts file when there is an SSH host conflict. Very nice when you get tired of writing out full commands. Ideally you would place this into your .bash_profile
Usage: rhost [n]
Example: rhost 33 (removes line 33 from ~/.ssh/known_hosts)
Function assumes the $HOME exists, you could alternatively use "~/.ssh/known_hosts"
Mac OSX likes a space for sed -i "$1" d
Automatically drops mount points that have non-numeric sizes (e.g. /proc). Tested in bash on Linux and AIX.
basic find implementation for systems that don't actually have find, like an android console without busybox installed.
The expression $(( $RANDOM * 6 / 32767 + 1 )) generates a random number between 1 and 6, which is then inserted into the escape sequence \e[3_m to switch the foreground color of the terminal to either red, green, yellow, blue, purple or cyan.
The color can be reset using the escape sequence \e[0m.
The full list of colors can be found here: https://wiki.archlinux.org/index.php/Color_Bash_Prompt#List_of_colors_for_prompt_and_Bash
This command takes all CR2 files in the current directory and convert them into JPG
Using PHP shell to URL decode a string.
[root@dhcppc1 windows]# cat /var/log/honeylog.log
Connection from 192.168.1.71 port 21 [tcp/ftp] accepted
Connection from 192.168.1.65 port 21 [tcp/ftp] accepted
[root@dhcppc1 windows]# nc 192.168.1.65 21
220 ProFTPD 1.3.3c Server [ProFTPD]
FAILED FTP ATTEMPT - PORT 21
*You can not run it if you have activated the ftp server.
grep по ps aux
change gpeXX by the culprit you discovered on phase 1
In case of this example, the culprit is the biggest number, ie, gpe1C
/sys/firmware/acpi/interrupts/ff_gbl_lock: 0 enabled
/sys/firmware/acpi/interrupts/gpe01: 0 enabled
/sys/firmware/acpi/interrupts/gpe06: 0 enabled
/sys/firmware/acpi/interrupts/gpe17: 2 enabled
/sys/firmware/acpi/interrupts/gpe18: 0 enabled
/sys/firmware/acpi/interrupts/gpe1C: 19 enabled
This procedure,if solved this universal issue all linix distros are experimenting for more than 2 years, may be included at startup, via cron. But try first commandline.
Need to encrypt something from the command line? I've used this before to encrypt passwords with a master password that was shared amongst a team.
~$ echo -n 'jA0EAwMCPdknsznAww5gySL1/quqhXg6QgQkIz5abzGP5EZgTbXCFU+y6dP8ySWovytc' | base64 --decode | gpg --decrypt
gpg: CAST5 encrypted data
Enter passphrase: secret
gpg: encrypted with 1 passphrase
Copies a directory structure from /home/ to /backups/home (notice that the destination does not have a trailing slash)
Prints an easy-to-copy color code for each color.
Really helpfull when play with files having spaces an other bad name. Easy to store and access names and path in just a field while saving it in a file.
This format (URL) is directly supported by nautilus and firefox (and other browsers)
outputs a f=220Hz guitar string sound (fifth string A)