Can you use the DD command on a directory in Linux?

Posted on 2012-08-24
Last Modified: 2012-09-01
Is it possible to use the DD command to create and image of a directory?  I realize that the DD command is traditionally intended to create a copy of data on a piece of media and that if is in allocated or unallocated space is irrelevant.  What I am looking for is a bit stream of data from allocated data within a directory.
If I should use another command please let me know.  Any examples would be greatly appreciated.
Question by:rye004
    LVL 9

    Expert Comment


    dd if=/dev/your folder of=/where you want to output file

    Author Comment

    Thank you for your response.  I had tried your example before I posted and all I got was an empty file.  The DD command indicated that what I was trying to DD was a directory.
    LVL 27

    Accepted Solution

    Have you tried tar?
    tar -cf directory.tar Directory_To_Archive

    Open in new window

    LVL 40

    Expert Comment

    dd command cannot be used for copying / imaging a directory.

    on unix / linux, a directory is a especial file that contains info about subdirs and files under that dir.

    so, when you dd a dir then dd will just copy that especial file and not the full directory content.

    you could use command like tar

    tar -cvf /somedir/mydir.tar /path/to/mydir

    but make sure you have enough space on /somedir

    to restore it

    tar -xvf /somedir/mydir.tar

    Author Closing Comment

    Thank you for your help.  This actually makes more sense to use.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    I am a long time windows user and for me it is normal to have spaces in directory and file names. Changing to Linux I found myself frustrated when I moved my windows data over to my new Linux computer. The problem occurs when at the command line.…
    The purpose of this article is to demonstrate how we can use conditional statements using Python.
    Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
    Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now