Skip to content
Home » How to Show The Progress Bar In Linux’s cp and mv Commands?

How to Show The Progress Bar In Linux’s cp and mv Commands?

By default, if you do a copy command or move a file in Linux CLI, no progress bar shows how long the commands will take to complete. I think the users will feel bored because they do not know how long the commands will take to complete.

 

Problem

How to show the progress bar in Linux’s cp and mv commands?

 

Solution

The image below shows no progress bar when you copy a file in Linux CLI:

Copy the file in Linux CLI

 

To display progress bars on cp and mv commands on Linux, you need a tool made by a GitHub user named jarun, who modified the source code of Florian Zwicke. But before you can install this tool, you must install the required packages:

 

RockyLinux/AlmaLinux/CentOS

yum install -y tar curl patch make coreutils gcc libattr* libpcap* perl libacl*

 

Debian/Ubuntu

apt-get install -y tar curl patch make coreutils gcc libattr* libpcap* perl libacl*

 

OpenSUSE

zypper install -y tar curl patch make coreutils gcc libattr* libpcap* perl libacl*

 

After that, install the tool, and it is recommended to use a normal user to install the tool, but if you want to use the root user  to install this tool, run the command below:

export FORCE_UNSAFE_CONFIGURE=1
the progress bar in cp and mv commands
Error when using the root user

 

Install the tool on your server by running the command below:

curl https://raw.githubusercontent.com/jarun/advcpmv/master/install.sh --create-dirs -o ./advcpmv/install.sh && (cd advcpmv && sh install.sh)

 

After installation completes, it created two new commands under the advcpmv folder. You need to replace your original cp and mv commands with these two new commands to get the progress bar while copying files:

sudo mv ./advcpmv/advcp /usr/local/bin/cp
sudo mv ./advcpmv/advmv /usr/local/bin/mv

 

After that, run the commands below:

echo "alias cp='/usr/local/bin/cp -g'" >> ~/.bashrc
echo "alias mv='/usr/local/bin/mv -g'" >> ~/.bashrc
source ~/.bashrc

 

Try to copy a file in your Linux CLI, and there should be a progress bar when you copy the file:

the progress bar in cp and mv commands
The progress bar appears when you copy the file

 

Likewise, if you are going to move a file on Linux CLI, there will be a notification as below:

the progress bar in cp and mv commands
The notification appears when you move the file

 

Note

You should know that if you want to use this tool on a different user from the user where this tool is installed on the server (for example, you installed this tool using another user but you want to use the tool using another user), you need to use the command below using your user so that this tool can be used on that user:

echo "alias cp='/usr/local/bin/cp -g'" >> ~/.bashrc 
echo "'alias mv='/usr/local/bin/mv -g'" >> ~/.bashrc 
source ~/.bashrc

 

References

tecmint.com
ostechnix.com
stackoverflow.com

image_pdfimage_print
Visited 36 times, 1 visit(s) today
Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *