How to Measure and Show Progress of the “dd” command in Linux?
The “dd” command in Linux is used to convert and copy files from one place to another. However, by default, this command is not programmed to show the progress of the ongoing operation. If you are copying large files from one place to another, this can be quite troublesome for you because you want to monitor progress continuously. For that, you need to tweak the “dd” command a little so that it is capable of measuring and showing the progress. Today, we will learn how we can achieve this goal using a Linux Mint 20 system.
Methods of Measuring and Showing the Progress of the “dd” Command in Linux Mint 20:
For measuring and showing the progress of the “dd” command in Linux Mint 20, the following two methods can be followed. However, before discussing these methods, you should ensure that the “dd” command is installed on your Linux system. This can be checked with the command shown below:
You can confirm from the output of the command shown in the following image that the “dd” command is installed on our Linux system.
Now you can head on to any of the following two methods.
Method # 1: Using the “progress” Flag to Measure and Show the Progress of the “dd” Command in Linux Mint 20:
For using the “progress” flag with the “dd” command to show its progress in Linux Mint 20, you will have to execute the command shown below:
$ dd if=PathOfFileToBeCopied of=PathOfOutputFile status=progress
Here, PathOfFileToBeCopied should be replaced with the path and name of the file whose contents are to be copied, and PathOfOutputFile should be replaced with the path and name of the file to which these contents are to be copied.
The progress of the “dd” command is shown in the following image. However, since the file that we were trying to copy in our example was very small in size, it just took us a second to complete the copying process of this file. That is why we could not capture its real progress. Nevertheless, if you choose a file with a larger file size, you will easily witness its ongoing copying progress.
Method # 2: Using the “pv” Command to Measure and Show the Progress of the “dd” Command in Linux Mint 20:
For using the “pv” command with the “dd” command to show its progress in Linux Mint 20, you will have to perform the following steps:
Step # 1: Install the “pv” Command on your System:
First, you need to install the “pv” command on your Linux system since it is not installed by default. To install this command, you will have to execute the command shown below in your terminal:
Once the “pv” command is installed on your Linux system, you will be able to pair it up with the “dd” command to show its progress.
Step # 2: Use this Command to Show the Progress of the “dd” Command on your System:
After installing the “pv” command, you will have to execute it as follows:
$ dd if=PathOfFileToBeCopied | pv | dd of= PathOfOutputFile
Here, PathOfFileToBeCopied should be replaced with the path and name of the file whose contents are to be copied, and PathOfOutputFile should be replaced with the path and name of the file to which these contents are to be copied.
The progress of the “dd” command is shown in the following image. However, since the file that we were trying to copy in our example was very small in size, therefore, it just took us a second to complete the copying process of this file. That is why we could not capture its real progress. Nevertheless, if you choose a file with a larger file size, you will easily witness its ongoing copying progress.
Conclusion
The two methods demonstrated in this tutorial are perfect for enabling the “dd” command to measure and show its progress in Linux. You can choose any of these at your convenience.