All commands (14,187)

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. 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.

Share Your Commands


Check These Out

Rename files in batch

Convert mysql database from latin1 to utf8
MySQL: CHARSET from latin1 to utf8

list files recursively by size

Unzip and untar a *.tar.gz file in one go to a specific directory
A *.tar.gz file needs to be unzipped & then untarred. Previously I might have unzipped first with $gunzip -d file.tar.gz and then untarred the result with $tar -xvf file.tar (Options are extract, verbose, file) Using the -z (decompress) option on tar avoids the use of gzip (or gunzip) first. Additionally the -C option will specify the directory to extract to.

c_rehash replacement
When you don't have c_rehash handy. Really simple - if you have a .pem file that doesn't really contain a x509 cert (let's say, newreq.pem), it will create a link, simply called '.0', pointing to that file.

find which lines in a file are longer than N characters
Filter out lines of input that contain 72, or fewer, characters. This uses bash only. ${#i} is the number of characters in variable i.

rename all images in folder with prefix of date and time from exif data
imagemagick is required

Listen Digitally Imported Radio from CLI (without premium!)
This commands does just two things: fakes user agent (the one was taken from recent Android app) and sends the (possibly) listener ID (it can be any - I put "1" here because it works like a charm - after the name of stream ?1 as you can see). Look for the list of stations here: http://pub7.di.fm Or here: https://goo.gl/pdhhpQ Best regards, sxiii :)

Don't spam root. Log your cronjob output to syslog
This command will log the output of your simple cronjobs to syslog, and syslog will take it from there. Works great for monitoring scripts which only produce simple output. Advantages: * This can be used by regular users, without modifying system files like /etc/syslog.conf * Reduce cron spam to root@localhost (Please stop spaming the sysadmins) * Uses common tools like syslog (and logrotate) so that you don't need to maintain yet another krufty logfile. * Still ensures that the output is logged somewhere, for posterity. Perhaps it's stored the secure, central syslog server, for example. * Seems to work fine on Ubuntu, CentOS, FreeBSD & MacOSX

Set laptop display brightness
Run as root. Path may vary depending on laptop model and video card (this was tested on an Acer laptop with ATI HD3200 video). $ cat /proc/acpi/video/VGA/LCD/brightness to discover the possible values for your display.


Stay in the loop…

Follow the Tweets.

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.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

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: