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
mv commands in Linux and show the progress bar while copying and/or moving large files and directories.
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
Now two new patched binaries namely
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
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/
$ cp --progress-bar archlinux.iso mydownload/
Copying at 25.7 MiB/s (about 0h 0m 1s remaining) archlinux.iso 568.1 MiB / 646.0 MiB [=========================================================================> ] 87.9 %
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
$ cp -gR directory1/ directory2/
Similarly, to move files using
mv command, run:
$ mv -g archlinux.iso mydownload/
$ 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
$ nano ~/.bashrc
Add the following lines at the end:
alias cp='/usr/local/bin/cp -gR' alias mv='/usr/local/bin/mv -g'
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
mv commands without
Please note that the original programs are not overwritten. You can still call them at any time via
Adding progress bar functionality to
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 the screen.