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

Find usb device in realtime
Using this command you can track a moment when usb device was attached.

Search and play MP3 from Skreemr
This use the Screemr search engine to play mp3 songs

Count occurrences per minute in a log file
The cut should match the relevant timestamp part of the logfile, the uniq will count the number of occurrences during this time interval.

Backup with versioning
Apart from an exact copy of your recent contents, also keep all earlier versions of files and folders that were modified or deleted. Inspired by EVACopy http://evacopy.sourceforge.net

Use QEMU to create a hardware dual-boot without rebooting
After downloading an ISO image, assuming you have QEMU installed, it’s possible to boot an ISO image in a virtual machine and then install that ISO from within the virtual machine directly to a physical drive, bypassing the need to reboot. Simply pass the ISO image as the -cdrom parameter, followed by “format=raw,file=/dev/sdb” (replace /dev/sdb with the drive you want to install to) as the hard drive parameter (making absolutely certain to specify the raw format, of course). Once you boot into the ISO image with QEMU, just run the installer as if it were a virtual machine — it’ll just use the physical device as an install target. After that, you’ll be able to seamlessly boot multiple distros (or even other operating systems) at once.

Create md5sum of a directory

Blackhole any level zones via dnsmasq
Explanation It creates dnsmasq-com-blackhole.conf file with one line to route all domains of com zones to 0.0.0.0 You might use "address=/home.lab/127.0.0.1" to point allpossiblesubdomains.home.lab to your localhost or some other IP in a cloud.

clone directory structure
dir1 and all its subdirs and subdirs of subdirs ... but *no files* will be copied to dir2 (not even symbolic links of files will be made). To preserve ownerships & permissions: $ cp -Rps dir1 dir2 Yes, you can do it with $ rsync -a --include '*/' --exclude '*' /path/to/source /path/to/dest too, but I didn't test if this can handle attributes correctly (experiment rsync command yourself with --dry-run switch to avoid harming your file system) You must be in the parent directory of dir1 while executing this command (place dir2 where you will), else soft links of files in dir2 will be made. I couldn't find how to avoid this "limitation" (yet). Playing with recursive unlink command loop maybe? PS. Bash will complain, but the job will be done.

convert ascii string to hex
You can use "decode()" in a similar manner: $ python -c 'print "68656c6c6f".decode("hex")'

Copy from host 1 to host 2 through your host


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: