Commands using dd (167)

  • This will output the sound from your microphone port to the ssh target computer's speaker port. The sound quality is very bad, so you will hear a lot of hissing.

    dd if=/dev/dsp | ssh -c arcfour -C [email protected] dd of=/dev/dsp
    morpheus · 2009-02-08 10:10:00 19

  • 67
    tr -c "[:digit:]" " " < /dev/urandom | dd cbs=$COLUMNS conv=unblock | GREP_COLOR="1;32" grep --color "[^ ]"
    allinurl · 2009-06-30 17:23:49 7

  • 61
    sudo dd if=/dev/mem | cat | strings
    logik · 2009-02-09 18:29:33 8
  • Read 32GB zero's and throw them away. How fast is your system? Show Sample Output

    dd if=/dev/zero of=/dev/null bs=1M count=32768
    jacquesloonen · 2009-02-16 12:22:18 15
  • If you have some drive imaging to do, you can boot into any liveCD and use a commodity machine. The drives will be written in parallel. To improve efficiency, specify a larger block size in dd: dd if=/dev/sda bs=64k | tee >(dd of=/dev/sdb bs=64k) | dd of=/dev/sdc bs=64k To image more drives , insert them as additional arguments to tee: dd if=/dev/sda | tee >(dd of=/dev/sdb) >(dd of=/dev/sdc) >(dd of=/dev/sdd) | dd of=/dev/sde

    dd if=/dev/sda | tee >(dd of=/dev/sdb) | dd of=/dev/sdc
    nerd65536 · 2009-12-11 17:34:38 2
  • This command utilizes 'pv' to show dd's progress. Notes on use with dd: -- dd block size (bs=...) is a widely debated command-line switch and should usually be between 1024 and 4096. You won't see much performance improvements beyond 4096, but regardless of the block size, dd will transfer every bit of data. -- pv's switch, '-s' should be as close to the size of the data source as possible. -- dd's out file, 'of=...' can be anything as the data within that file are the same regardless of the filename / extension. Show Sample Output

    sudo dd if=/dev/sdc bs=4096 | pv -s 2G | sudo dd bs=4096 of=~/USB_BLACK_BACKUP.IMG
    BruceLEET · 2010-07-28 22:39:46 4
  • 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. Show Sample Output

    sudo dd if=/dev/zero of=/swapfile bs=1024 count=1024000;sudo mkswap /swapfile; sudo swapon /swapfile
    dcabanis · 2009-05-27 21:10:50 1
  • read the memory from C:0000 to F:FFFF without the need auf dmidecode

    # dd if=/dev/mem bs=1k skip=768 count=256 2>/dev/null | strings -n 8
    new_user · 2010-07-02 09:38:19 0
  • This will create an exact duplicate image of your hard drive that you can then restore by simply reversing the "if" & "of" locations. sudo dd if=/media/disk/backup/sda.backup of=/dev/sda Alternatively, you can use an SSH connection to do your backups: dd if=/dev/sda | ssh [email protected] dd of=~/backup/sda.backup

    sudo dd if=/dev/sda of=/media/disk/backup/sda.backup
    bandit36 · 2009-02-27 20:23:37 2
  • This line removes the 300k header from a Nero image file converting it to ISO format

    dd bs=1k if=image.nrg of=image.iso skip=300
    rpavlick · 2010-03-30 22:07:58 0

  • 12
    dd if=/dev/sda | ssh [email protected] 'dd of=sda.img'
    newrain7803 · 2009-10-20 06:47:01 1

  • 12
    dd if=/path/inputfile | pv | dd of=/path/outpufile
    lucafaus · 2010-12-02 18:11:42 2
  • Similar to the original, but is much faster since it only needs to write the last byte as zero. A diff on testfile and will return that they are the same.

    dd if=/dev/zero seek=5242879 bs=1 count=1
    PhillipNordwall · 2011-04-04 17:56:47 3
  • This version was mentioned in the comments. Credits go to flatcap.

    pv -tpreb /dev/urandom | dd of=file.img
    marrowsuck · 2012-04-11 22:32:52 2
  • [re]verify those burned CD's early and often - better safe than sorry - at a bare minimum you need the good old `dd` and `md5sum` commands, but why not throw in a super "user-friendly" progress gauge with the `pv` command - adjust the ``-s'' "size" argument to your needs - 700 MB in this case, and capture that checksum in a "test.md5" file with `tee` - just in-case for near-future reference. *uber-bonus* ability - positively identify those unlabeled mystery discs - for extra credit, what disc was used for this sample output? Show Sample Output

    dd if=/dev/cdrom | pv -s 700m | md5sum | tee test.md5
    asmoore82 · 2009-03-09 00:11:42 1
  • 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.

    dd if=/dev/urandom of=file.img bs=4KB& pid=$!
    atoponce · 2009-04-08 05:56:47 6
  • 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

    dd if=/dev/cdrom of=whatever.iso
    0disse0 · 2009-09-05 09:19:41 3
  • piping through 'pv' shows a simple progress/speed bar for dd. This is a replacement for my otherwise favorite 'while :;do killall -USR1 dd;sleep 1;done' Show Sample Output

    dd if=/dev/nst0 |pv|dd of=restored_file.tar
    oernii2 · 2010-04-07 09:21:18 6

  • 9
    dd if=/dev/zero | pv | dd of=/dev/null
    richard · 2010-05-14 16:58:42 2
  • In addition to a swap partition, Linux can also use a swap file. Some programs, like g++, can use huge amounts of virtual memory, requiring the temporary creation of extra space.

    dd if=/dev/zero of=/swapfile bs=1M count=64; chmod 600 /swapfile; mkswap /swapfile; swapon /swapfile
    starchox · 2009-02-16 18:36:38 0
  • 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. Show Sample Output

    # cd $partition; dd if=/dev/zero of=ShredUnusedBlocks bs=512M; shred -vzu ShredUnusedBlocks
    mpb · 2009-06-21 14:17:22 6
  • Create an image of "device" and send it to another machine through the network ("target" and "port" sets the ip and port the stream will be sent to), outputting a progress bar On the machine that will receive, compress and store the file, use: nc -l -p <port> | 7z a <filename> -si -m0=lzma2 -mx=9 -ms=on Optionally, add the -v4g switch at the end of the line in order to split the file every 4 gigabytes (or set another size: accepted suffixes are k, m and g). The file will be compressed using 7z format, lzma2 algorithm, with maximum compression level and solid file activated. The compression stage will be executed on the machine which will store the image. It was planned this way because the processor on that machine was faster, and being on a gigabit network, transfering the uncompressed image wasn't much of a problem.

    dd if=<device> | pv | nc <target> <port>
    quitaiskiluisf · 2012-01-27 18:37:36 2

  • 7
    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"
    sputnick · 2009-05-29 21:56:32 0
  • Solves "tr" issues with non C-locales under BSD-like systems (like OS X)

    LC_ALL=C tr -c "[:digit:]" " " < /dev/urandom | dd cbs=$COLUMNS conv=unblock | GREP_COLOR="1;32" grep --color "[^ ]"
    zzambia · 2009-07-02 07:10:33 1
  • 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

    ssh [email protected] "cd targetdir; tar cfp - *" | dd of=file.tar
    bwoodacre · 2009-03-18 07:43:22 3
  •  1 2 3 >  Last ›

What's this? 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

Rip audio from a video file.
Replace and accordingly.

Join lines split with backslash at the end
Joins each line that end with backslash (common way to mark line continuation in many languages) with the following one while removing the backslash.

Rip DVD to YouTube ready MPEG-4 AVI file using mencoder
Rip DVD to YouTube ready AVI file, using MPEG-4 video codec and MP3 audio codec. Resizes to 320x240 and deinterlaces as needed.

Output the content of your Active Directory in a CSV file

list files recursively by size

create random string from /dev/urandom (or another length)

Use lynx to run repeating website actions
This command will tell lynx to read keystrokes from the specified file - which can be used in a cronjob to auto-login on websites that give you points for logging in once a day *cough cough* (which is why I used -accept_all_cookies). For creating your keystroke file, use: $ lynx -cmd_log yourfile

Rename duplicates from MusicBrainz Picard
Renames duplicates from MusicBrainz Picard, so you get the latest copy and not a bunch of duplicates.

Generate random valid mac addresses
First set the variable $hexchars: $hexchars="0123456789ABCDEF" Change the number in the first for loop if you need less then 1200 mac addresses

See all the commits for which searchstring appear in the git diff

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.


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: