1 agosto, 2024

What is and how to use the DD command in Linux?

The DD command on Linux, aka Data Duplicator or data duplicator, is a low level tool that allows you to make backup copies, clone disks and partitions, create self-booting disks, as well as make backup of the first sector of the disk and save it in a backup file, among others.

This command also allows the transfer of certain dataas well as the conversion of some preset encodings and characters.

Its use avoids unnecessary installation of programs that perform tasks that can be executed with a single line of code from the DD command in Linux. However, you must be careful when using this tool, because if it is executed incorrectly can cause serious problems in the system, such as the loss of valuable information and data, so it is recommended to do backup and test on virtual machines to avoid these problems.

Another problem with this command is that makes a copy of the entire partition, including the empty spaceso it requires a large storage space.

The interesting thing with dd in Linux is that a partition is given as input and as output, it can be another partition, an external drive or a file.

Syntax of the DD command in Linux

There is a basic syntax of the dd command that is written like this:

sudo dd if=origin of=destination

Where sudo It refers to command to have the administrator user permission either root. While dd is the command Data Duplicator. The syntax continues with if what does it mean input file or input file, that is, what you want to copy, followed by of which refers to output file or output file, that is, the destination file where the data is to be copied.

Regarding the options of origin and destinationthese can be equipment such as readers of CD either DVD, disk, partition, pendrive, as well as backup files, the disk image, among others. These options do not include folders or subfolders of the system.

DD commands in Linux

He Data Duplicator allows the use of certain options that perform certain functions in the system, for example:

lsblk : By writing this command in the terminal, you can identify the devices that are connected.
info dd : just like the command man ddwill allow you to consult all the information about the Data Duplicator.
-ibs : sets the number of octets (set of 8 bits) that will be read from the input file during the dump process.
-obs : Indicates how many octets will be written at a time to the output file by the dump process.
-bs : Specifies the number of octets that will be read and written at the same time during the dump process.
-count = [octetos] : sets the number of octets that will be dumped from «if» to «of«.
-cbs – Indicates the number of bytes required at the conversion block size for conversions blocks and unblock.
-skip : This command is used to skip blocks of the source file before proceeding with the copy action.
-seek : is used in order to skip blocks of the destination file before the copy operation.
conv=mode[, modo,…] : allows you to carry out conversion operations as indicated. Multiple conversions can be performed, which must be separated by commas. Some examples of conversions supported by this command are:

blocks: converts the line into a block or record, by completing the read lines with blank spaces up to the size indicated by the command -cbs.
unblock: This conversion is responsible for replacing the last white spaces with a line feed character of the record that has the size indicated by –cbs. It is the inverse conversion of the option blocks.
ascii: used to convert EBCDIC characters to American Standard Code for Information Interchange ASCII.
ebcdic: used to convert characters in ASCII format to Extended Binary Coded Decimal Interchange Code EBCDIC.
swab: is responsible for exchanging each pair of bytes of the input, while the last byte is copied directly.
noerror– This conversion is used to avoid stopping the process in the face of read errors at the source.
notrunc: used for the file used as the destination.
ukase: is responsible for exchanging lowercase letters for uppercase letters.
lcase: has the function of changing uppercase letters to lowercase.

What is the next step?

Now that you know what the DD command is in Linux, what its uses are, its syntax, commands and converters, Do not hesitate to continue your training through our DevOps & Cloud Computing Full Stack Bootcampwhere in just 6 months you will be able to learn about this and other Linux tools, as well as methodologies that will allow you improve and accelerate your development processes in the IT sector.

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *