What's this?

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.

Get involved!

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.

Universal configuration monitoring and system of record for IT.

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:



May 19, 2015 - A Look At The New Commandlinefu
I've put together a short writeup on what kind of newness you can expect from the next iteration of clfu. Check it out here.
March 2, 2015 - New Management
I'm Jon, I'll be maintaining and improving clfu. Thanks to David for building such a great resource!

Top Tags



Psst. Open beta.

Wow, didn't really expect you to read this far down. The latest iteration of the site is in open beta. It's a gentle open beta-- not in prime-time just yet. It's being hosted over at UpGuard (link) and you are more than welcome to give it a shot. Couple things:

  • » The open beta is running a copy of the database that will not carry over to the final version. Don't post anything you don't mind losing.
  • » If you wish to use your user account, you will probably need to reset your password.
Your feedback is appreciated via the form on the beta page. Thanks! -Jon & CLFU Team

Commands using dd from sorted by
Terminal - Commands using dd - 143 results
ssh [email protected]_A dd if=/dev/dvd0 > dvddump.iso
2009-09-11 18:08:36
User: kamathln
Functions: dd ssh
Tags: ssh dvd dump

You can use this to directly dump from machine A (with dvd drive) to machine B (without dvd drive) . I used this to copy dvd using my friend's machine to my netbook. Above command is to be issued on machine B.

Advantages :

1) No wasting time dumping first to machine A and then copying to Machine B.

2) You dont need to use space on Machine A. In fact, this will work even when Machine A doesnt have enough hdd space to dump the DVD.

Use -C ssh option on slow networks (enables compression).

you can replace "dd if=/dev/dvd" with any ripping command as long as it spews the iso to stdout.

dd if=/dev/zero of=/dev/fd0 bs=512 count=1
2009-09-09 23:43:22
User: andrew112358
Functions: dd

Overwrites the boot sector. Since this doesn't overwrite any data, you can usually recover by re-creating the partition table exactly the same as before you zeroed it. This can also help sometimes if you install a new drive in a Windows machine which can't read it.

dd if=/dev/cdrom of=whatever.iso
2009-09-05 09:19:41
User: 0disse0
Functions: dd
Tags: backup dd iso dvd

A dear friend of mine asked me how do I copy a DVD to your hard drive? If you want to make a copy of the ISO image that was burned to a CD or DVD, insert that medium into your CD/DVD drive and (assuming /dev/cdrom is associated with your computer?s CD drive) type the following command

sudo dd if=/dev/hda1 of=/dev/hdb2
2009-09-05 09:16:52
User: 0disse0
Functions: dd sudo

This command clone the first partition of the primary master IDE drive to the second partition

of the primary slave IDE drive (!!! back up all data before trying anything like this !!!)

echo capitalize | { dd bs=1 count=1 conv=ucase 2> /dev/null; cat ;}
dd bs=1 seek=2TB if=/dev/null of=ext3.test
dd if=/dev/urandom count=200 bs=1 2>/dev/null | tr "\n" " " | sed 's/[^a-zA-Z0-9]//g' | cut -c-16
no_of_files=10; counter=1; while [[ $counter -le $no_of_files ]]; do echo Creating file no $counter; dd bs=1024 count=$RANDOM skip=$RANDOM if=/dev/sda of=random-file.$counter; let "counter += 1"; done
2009-07-31 16:34:47
User: rajaseelan
Functions: dd echo file
Tags: bash dd

Create a bunch of random files with random binary content. Basically dd dumps randomly from your hard disk to files random-file*.

while true ; do IFS="" read i; echo "$i"; sleep .01; done < <(tr -c "[:digit:]" " " < /dev/urandom | dd cbs=$COLUMNS conv=unblock | GREP_COLOR="1;32" grep --color "[^ ]")
2009-07-22 03:59:07
Functions: dd echo grep read sleep tr true
Tags: color

Same as above but slooooow it down

time dd if=/dev/zero of=blah.out oflag=direct bs=256M count=1
2009-07-15 07:17:32
User: olorin
Functions: dd time

Let dd use direct I/O to write directly to the disk without any caching. You'll encounter very different results with different block sizes (try with 1k, 4k, 1M, ... and appropriate count values).

dd if=/dev/zero bs=256M count=1 | nc [remoteIP] [remotePort] and on the other host nc -l port >/dev/null
2009-07-14 20:30:52
User: tkunz
Functions: dd host

Note, the [remotePort] should be opened in the firewall first. First, start the destination box listening, then fire off the sending box. Data from the /dev/zero device in memory of the source machine is read out using dd, sent over the network with nc, and read back in from the other side of the network with nc, going to the /dev/null device. Essentially, it is a memory-network-memory copy operation, the output of dd will tell you how fast your network really is performing.

time (dd if=/dev/zero of=blah.out bs=256M count=1 ; sync )
2009-07-14 20:19:23
User: tkunz
Functions: dd sync time

Depending on the speed of you system, amount of RAM, and amount of free disk space, you can find out practically how fast your disks really are. When it completes, take the number of MB copied, and divide by the line showing the "real" number of seconds. In the sample output, the cached value shows a write speed of 178MB/s, which is unrealistic, while the calculated value using the output and the number of seconds shows it to be more like 35MB/s, which is feasible.

# dd if=/dev/sda | gzip -c | ssh [email protected] 'dd of=/mnt/backups/sda.dd'
LC_ALL=C tr -c "[:digit:]" " " < /dev/urandom | dd cbs=$COLUMNS conv=unblock | GREP_COLOR="1;32" grep --color "[^ ]"
2009-07-02 07:10:33
User: zzambia
Functions: dd grep tr
Tags: color

Solves "tr" issues with non C-locales under BSD-like systems (like OS X)

tr -c "[:digit:]" " " < /dev/urandom | dd cbs=$COLUMNS conv=unblock | GREP_COLOR="1;32" grep --color "[^ ]"
# cd $partition; dd if=/dev/zero of=ShredUnusedBlocks bs=512M; shred -vzu ShredUnusedBlocks
2009-06-21 14:17:22
User: mpb
Functions: cd dd shred

This command securely erases all the unused blocks on a partition.

The unused blocks are the "free space" on the partition.

Some of these blocks will contain data from previously deleted files.

You might want to use this if you are given access to an old computer and you do not know its provenance.

The command could be used while booted from a LiveCD to clear freespace space on old HD.

On modern Linux LiveCDs, the "ntfs-3g" system provides ReadWrite access to NTFS partitions thus enabling this method to also be used on Wind'ohs drives.

NB depending on the size of the partition, this command could take a while to complete.

dd if=/dev/zero of=testfile.txt bs=1M count=10
2009-06-17 17:06:16
User: mstoecker
Functions: dd
Tags: dd size test file

This will create a 10 MB file named testfile.txt. Change the count parameter to change the size of the file.

As one commenter pointed out, yes /dev/random can be used, but the content doesn't matter if you just need a file of a specific size for testing purposes, which is why I used /dev/zero. The file size is what matters, not the content. It's 10 MB either way. "Random" just referred to "any file - content not specific"

stty cbreak -echo; KEY=$(dd bs=1 count=1 2>/dev/null); stty -cbreak echo
2009-06-09 13:15:49
User: inof
Functions: dd stty

This shell snippet reads a single keypress from stdin and stores it in the $KEY variable.

You do NOT have to press the enter key!

The key is NOT echoed to stdout!

This is useful for implementing simple text menus in scripts and similar things.

dd if=/dev/zero of=/dev/sdb bs=446 count=1
2009-06-07 10:29:49
User: dcabanis
Functions: dd
Tags: dd grub boot usb

If you don't want your computer to try to boot form a USB stick that used to be used as a boot device (maybe for a live linux distro), you will have to remove the boot loader from your stick other wise the boot will fail each time the device is attached to your PC.

dd if=/dev/sda5 bs=2048 conv=noerror,sync | gzip -fc | lftp -u user,passwd domain.tld -e "put /dev/stdin -o backup-$(date +%Y%m%d%H%M).gz; quit"
sudo dd if=/dev/zero of=/swapfile bs=1024 count=1024000;sudo mkswap /swapfile; sudo swapon /swapfile
2009-05-27 21:10:50
User: dcabanis
Functions: dd mkswap sudo swapon

Create a temporary file that acts as swap space. In this example it's a 1GB file at the root of the file system. This additional capacity is added to the existing swap space.

dd if=/dev/mem of=file.dump bs=1024 skip=0 count=1
Boot up destination machine with Knoppix live CD and run nc -l -p 9000 | dd of=/dev/sda Then on the master dd if=/dev/sda | nc <dest-ip> 9000 You can monitor bandwidth usage to see progress: nload eth0 -u M
2009-05-07 05:26:58
User: lv4tech
Functions: dd

This is a bit to bit copy so if you have a 500GB hard disk it will take a long time even if have Gigabit Ethernet

dd if=/dev/urandom of=file.img bs=4KB& pid=$!
2009-04-08 05:56:47
User: atoponce
Functions: dd

Running this code will execute dd in the background, and you'll grab the process ID with '$!' and assign it to the 'pid' variable. Now, you can watch the progress with the following:

while true; do kill -USR1 $pid && sleep 1 && clear; done

The important thing to grasp here isn't the filename or location of your input or output, or even the block size for that matter, but the fact that you can keep an eye on 'dd' as it's running to see where you are at during its execution.

ssh [email protected] "cd targetdir; tar cfp - *" | dd of=file.tar
2009-03-18 07:43:22
User: bwoodacre
Functions: dd ssh

This invokes tar on the remote machine and pipes the resulting tarfile over the network using ssh and is saved on the local machine. This is useful for making a one-off backup of a directory tree with zero storage overhead on the source. Variations on this include using compression on the source by using 'tar cfvp' or compression at the destination via

ssh [email protected] "cd dir; tar cfp - *" | gzip - > file.tar.gz