Home Linux Tips & Tricks Advanced Copy – Add Progress Bar To cp And mv Commands In Linux

Advanced Copy – Add Progress Bar To cp And mv Commands In Linux

By sk
Published: Last Updated on 46.8K views

The GNU cp and GNU mv tools are used to copy and move files and directories in GNU/Linux operating system. One missing feature in these two utilities is they don't show you any progress bar. If you copy a large file or directory, you really don't know how long the copy process would take to complete, or the percentage of data copied. You will not see which file is currently being copied, or how many were already copied. All you will see is just the blinking cursor and the hard drive LED indicator. Thanks to Advanced Copy, a patch for Gnu Coreutils, we can now add progress bar to cp and mv commands in Linux and show the progress bar while copying and/or moving large files and directories.

What is Advanced Copy?

Advanced Copy is a mod for the GNU cp and GNU mv programs. It adds a progress bar and provides some information on what's going on while you copy or move files and folders. Not only the progress bar, it also shows the data transfer rate, estimated time remaining and the file name that is currently being copied. At the end you will see a short summary on how many files are copied and how long it took to copy the files.

Install 'Advanced Copy' Patch To Add Progress Bar To cp And mv Commands in Linux

The cp and mv commands are part of the GNU coreutils. So you need to download the latest GNU coreutils from here.

$ wget http://ftp.gnu.org/gnu/coreutils/coreutils-8.32.tar.xz

Extract the downloaded archive using command:

$ tar xvJf coreutils-8.32.tar.xz

This command will extract coreutils archive in a folder named coreutils-8.32 in the current directory. Cd into it:

$ cd coreutils-8.32/

Download the Advanced Copy patch using the following command:

$ wget https://raw.githubusercontent.com/jarun/advcpmv/master/advcpmv-0.8-8.32.patch

Finally, apply the patch by running the following commands one by one:

$ patch -p1 -i advcpmv-0.8-8.32.patch
$ ./configure
$ make

Now two new patched binaries namely cp and mv will be created in the coreutils-8.32/src folder. Just copy them to your $PATH like below:

$ sudo cp src/cp /usr/local/bin/cp
$ sudo cp src/mv /usr/local/bin/mv

That's it. The cp and mv commands have progress bar functionality now.

Whenever you want a progress bar while copying or moving files and directories, just add -g flag like below:

$ cp -g archlinux.iso mydownload/

Or use --progress-bar flag:

$ cp --progress-bar archlinux.iso mydownload/

Sample output:

Copying at  25.7 MiB/s (about 0h 0m 1s remaining)
archlinux.iso                                                          568.1 MiB / 646.0 MiB
[=========================================================================>                  ] 87.9 %
Add Progress Bar To cp And mv Commands in Linux
Add Progress Bar To cp And mv Commands in Linux

At the end of the copy process, you will see how many files were copied, how long it took to copy the file(s), and the data transfer rate per second. Nice, isn't?

1 files (646.0 MiB) copied in 11.8 seconds ( 54.7 MiB/s).

To copy a directory and its sub-directories recursively, simply add -R flag:

$ cp -gR directory1/ directory2/

Similarly, to move files using mv command, run:

$ mv -g archlinux.iso mydownload/

Or, use --progress-bar flag:

$ mv --progress-bar archlinux.iso mydownload/

To move directories with mv command, use:

$ mv -g directory1/ directory2/

You can also create aliases to save a few key strokes. To do so, edit ~/.bashrc file:

$ nano ~/.bashrc

Add the following lines at the end:

alias cp='/usr/local/bin/cp -gR'
alias mv='/usr/local/bin/mv -g'

Press Ctrl+o and Ctl+x to save and close the file.

Now run the following command to take effect the changes:

$ source ~/.bashrc

From now on, you can just use cp or mv commands without -g (or --progress-bar) flag.

Please note that the original programs are not overwritten. You can still call them at any time via /usr/bin/cp or /usr/bin/mv.

Adding progress bar functionality to cp and mv commands is a good idea if you often copy or move a lot of large files and directories. You can now see what exactly is going on while copying and moving files, instead of staring at the screen.


The original author sent the patch to the team, that maintains the GNU CoreUtils. They won't merge this patch, because mv and cp are feature complete.


Related read:

You May Also Like


Jalal November 1, 2020 - 10:36 am

Pretty good and easy.
Thank you so much for the great topic,

Chr Fau November 1, 2020 - 5:16 pm

@author, I assume that you don’t know command pv.

sk November 1, 2020 - 5:28 pm Reply
JT November 1, 2020 - 9:59 pm

When running sudo cp src/mv /usr/local/bin/mv I received this error:
cp: cannot create regular file ‘/usr/local/bin/cp’: Text file busy

Thinking this is due to me using the cp command to cp src/mv
-Any workaround?

sk November 1, 2020 - 10:06 pm

That’s odd. I never had that issue. Make sure you are in coreutils-8.32 directory. Rename the old file i.e. /usr/local/bin/mv and try again.

Marco November 17, 2020 - 11:24 pm

I’ve got this error when executing the make command:
[root@server coreutils-8.32]# make
make all-recursive
make[1]: Entering directory `/packs/AdvancedCopy_Linux/coreutils-8.32′
Making all in po
make[2]: Entering directory `/packs/AdvancedCopy_Linux/coreutils-8.32/po’
make[2]: Nothing to be done for `all’.
make[2]: Leaving directory `/packs/AdvancedCopy_Linux/coreutils-8.32/po’
Making all in .
make[2]: Entering directory `/packs/AdvancedCopy_Linux/coreutils-8.32′
CC src/cp.o
In file included from src/cp.c:28:0:
src/copy.h:241:8: error: duplicate member ‘progress_bar’
bool progress_bar;
src/cp.c: In function ‘do_copy’:
src/cp.c:704:20: error: redeclaration of ‘start_time’ with no linkage
struct timeval start_time;
src/cp.c:614:20: note: previous declaration of ‘start_time’ was here
struct timeval start_time;
src/cp.c: In function ‘main’:
src/cp.c:1225:9: error: duplicate case value
case ‘g’:
src/cp.c:1221:9: error: previously used here
case ‘g’:
make[2]: *** [src/cp.o] Error 1
make[2]: Leaving directory `/packs/AdvancedCopy_Linux/coreutils-8.32′
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/packs/AdvancedCopy_Linux/coreutils-8.32′
make: *** [all] Error 2
[root@server coreutils-8.32]#

Anyone who has a possible answer to fix this.

vince November 30, 2020 - 7:52 pm

404 File not found on wget

sk November 30, 2020 - 8:09 pm

I just checked on my Ubuntu system. There is no 404 error. Both files (coreutils and advanced copy) packages are available.

Kelcso January 23, 2021 - 10:17 pm

That’s it very cool 🙂
working after reboot?

sk January 23, 2021 - 10:23 pm

Yes, it does.

Christopher Conrad Nystrom January 24, 2021 - 9:42 am

Why not submit your patch to the gnu coreutils team?

sk January 24, 2021 - 12:12 pm

The mv and cp commands are feature complete. The maintainers didn’t accept the patch. It is mentioned in the Advanced Copy github page.


Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. By using this site, we will assume that you're OK with it. Accept Read More