Skip to main content
Tips

Copy Files in Linux With Visual Progress

Want to see the progress of your file copying? Here are two ways to do that in the Linux terminal.

Abhishek Prakash

Warp Terminal

Unlike the graphical mode, you don't see the status of the file copying in progress with the cp command.

If it's a huge file, then the terminal just waits there for the cp command to conclude.

There is no option in the cp command to show the copy progress but that doesn't mean that you cannot do it at all.

You can utilize a dedicated CLI tool progress and see the cp command's progress:

cp bigfile destination & progress -mp $!

You may also use the rsync command to show progress while transferring files:

rsync -r --progress source_file destination_file

Let's talk about the first method first.

Using cp with progress

🤚
You need to install progress first. Use your distribution's package manager for that. In Ubuntu and Debian, you can use sudo apt install progress

The progress command is a Coreutils progress viewer. It looks for the currently running coreutils commands like cp, mv, dd, tar etc and displays the percentage of copied data.

That's the default behaviour.

For example, I created a super large file of 20 GB and started the cp command to copy it to another location. If I enter progress (in another terminal), it shows the progress of all the active Coreutil commands at that very moment.

But that's not very useful if you want to keep a track of the file copying progress in the Linux terminal.

Fret not! The progress command has several options and you can combine some of them to use it like you combine watch and free command.

To show the file transfer porogress with the cp command, use it with progress like this:

cp bigfile destination & progress -mp $!

Here's an example showing the cp command progress for copying a 20GB file.

Here,

  • The -m option is for monitoring in loop as long as the monitored process is running.
  • The option -p needs the PID of the process you want to monitor. And hence you use the special variable $! that gives you the process ID of the last background command.

Yes, you used the & to send the cp command in the background and then got its process ID with $! and used it to monitor with the progress command.

How super cool is that!

Use rsync to show file copy progress

The versatile rsync command can also be used for copying files while displaying progress with the help of the --progress flag:

rsync -r --progress source_file destination_file

Here's the same example scenario you saw in the previous method:

Show file copy progress with rsync command

Conclusion

I prefer using cp command for local file copying and rsync for file transfer between remote systems.

It is rare that I need to see the copy progress in the command line. But it's good to know that there are options that can help with this task.

Let me know if you have any questions or suggestions.

Abhishek Prakash