Home » Linux » Backing up and erasing media, disks, and partitions with DD Command

Backing up and erasing media, disks, and partitions with DD Command

Last updated May 18, 2021

In this article, we are going to discuss the dd command. The dd command stands for data duplicator. It is mainly used for converting and copying files. In this section, we are going to learn about backing up and erasing a media file.

Prerequisites

Besides having a terminal open, we need to make sure you have the necessary files present in the current directory to take backups, to make copies, and similar tasks.

How to do it

The dd command is mainly used for converting and copying files. The if parameter stands for input-file and is a source. of stands for output-file and is a source where we want to paste data.

Run the following command to copy the contents of one file to another:

# create a file 01.txt and add some content in that file. 
# create another file 02.txt and add some content in that file. 
$ dd if=/home/student/work/01.txt of=/home/student/work/02.txt bs=512 count=1

Run the following command to take a backup of the partition or the hard disk:

$ sudo dd if=/dev/sda2 of=/home/student/hdbackup.img

The dd command is also used to erase all of the contents of the disk. Run the following command to delete the contents:

$ sudo dd if=/home/student/work/1.sh

How it works

Now we will see how the preceding commands work:

  • We used the dd command to copy the contents of the 01.txt file into the 02.txt file.
  • To run this command, we must have super user privileges. Using the dd command, we took a backup and stored it in the hdbackup.img file.
  • Using the dd command, we erased the contents of the 1.sh file.

Related Posts

Creating a lame utility HTTP server in Linux Operating System

In this article, we will discuss the cURL tool in Linux. The cURL tool is used for transferring the data from or to a server. It supports many protocols, and http is one of them. cURL is used to transfer the data from URL. It has so many tricks to offer, such as http...

Finding binary dependencies in Linux Operating System

In this article, we are going to check the executable. We will find out which string is present in it by using the string command.PrerequisitesBesides having a terminal open, make sure you have a binary present in your directory.Find dependencies First, we...

Capturing network traffic headlessly in Linux Operating System

In this article, we are going to learn how to capture traffic. We are going to capture network traffic with a packet sniffer tool called tcpdump. This tool is used to filter or capture TCP/IP packets that are transferred or received over a network.PrerequisitesBesides...

0 Comments

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

1 × three =

Follow Us

Our Communities

More on Linux

The Ultimate Managed Hosting Platform
Load WordPress Sites in as fast as 37ms!