Have you ever wanted to see the speed and progress while copying files using the command line? For copying files, folders, and other data, you would probably use the ditto or “cp” command if you are familiar with the command line of the Linux or Unix operating systems. Although the ditto commands and “cp” are useful, sometimes using a simple “cp” command can be time-consuming and an exhausting operation. The “-v” (verbose) option in the “cp” command can provide you additional information about the copy process. However, one drawback is that this command does not include any progress indicator for the copying process.
In Linux, there are other alternative commands that can copy files and folders while showing the progress and speed of the copying process. Following are the alternative commands:
1. rsync Command
The “rsync” is one of the best commands which helps you copy files through the terminal. The volume of the data copied from a remote destination is reduced while using this utility. It is also utilized for creating data backups, copying data between computers, and mirroring. The “rsync” command has the following syntax:
$ rsync options Source Destination
Using the “-av” option with “rsync” is the simplest form of this command. As shown below, the given command will copy all the files present in the “testfolder” to its destination folder named “Downloads”:
$ rsync -av testfolder/ Downloads/
The output will show you the file names, sent and received file size, total file size, and copying process speed.
The “–progress” is a flag used in the “rsync” command to get the overall progress of the copied content.
$ rsync -av –progress testfolder/ Downloads/
Another flag that can be included in the “rsync” command is “–stats”. The “–stats” option provides more extensive information about the file transfer, such as the number of created, deleted, or regular transferred files, total bytes sent, and total bytes received. Write out the given command below to retrieve all this information related to your file copying process.
$ rsync -av –progress –stats testfolder/ Downloads/
2. pv Command
You can use the “pv” command for copying a single file as it provides statistics related to the progress and speed.
In the following case, “pv” will output the “inputfile” to “stdout”, which is then redirected to the “outputfile” using the “>”operator. When you do so, it will print out all the details about the speed and progress to the terminal simultaneously. File copied in this manner will have the same permissions as if you created them.
$ pv inputfile > outputfile
3. tar Command
If you want to copy multiple files or directories, then using the “tar” command in the terminal is a better option. Specify the source and destination folder in the “tar” command with the option “-C” in combination with “pv” to view the speed and progress of the process.
$ tar c testfolder | pv | tar x -C Downloads
4. dd Command
In the terminal, the “dd” command is used for copying or converting files. It is an open-source command-line tool that is freely available. In the given command below, we will show you how to utilize “dd” command to attain the copying file statistics:
Define your source folder in “if” and the destination folder in “of” and set “progress” as the status parameter.
$ sudo dd if=inputfile of=/Downloads status=progress
Execute the “dd” command and check out the information displayed in the output:
In Linux, there are several alternatives to the cp command for showing the speed and progress of the copying process of files or folders. This article discussed the rsync, pv, tar, and dd commands that copy data statistics while doing the large files transfer.