How to Show Progress Bar for Linux Commands

Many Linux commands like dd, cp, rsync, and mv are progressive, but have no progress bars showing as they run. There is not built in way to check the progress of ongoing operations. In this article, we’ll look at certain Linux tools and options which allow you to monitor the progress of data being transferred.

1) PV Command

Pv is command line - based tool that allows you to monitor the progress of data being transferred using pipe. The pv command gives you a visual view of the following information.

Time elapsed

Percentage completed using a progress bar.

Current throughput rate.

Total data transferred.

ETA (Estimated Time).

Installing Pv

You can install pv on your distro using the following commands

Fedora, CentOS and RHEL

# yum install pv

Debian, Ubuntu and Linux Mint

# apt-get install pv

Gentoo Linux

# emerge --ask sys-apps/pv

FreeBSD Linux

# cd /usr/ports/sysutils/pv/
# make install clean

Pv Usage with Examples

The general syntax for pv is pv [Options] [File]

The -p switch turns the progress bar on, -t switch activates the total elapsed time pv has been running for, the -e switch provides the ETA to completion based on the transfer rate and data size, the -r switch shows the current rate of the transfer and finally the -b switch shows the total amount of data transferred so far.

Monitor the progress of creating an archive using gzip

In this example, we use pv with gzip in the following example:

pv -tpre ~/Desktop/testfile.iso | gzip > ~/Desktop/testfile.gz

213MiB 0:00:14 [17.8MiB/s] [=========> ] 32% ETA 0:00:29

In this example, we provide the switches and the file in question, and then pipe it to gzip with a redirection to the file we want to archive.

Using pv and dialog commands to create a dialog progress bar

2) Progress

Progress, formerly known as cv, is a tool which displays the percentage of copied data from coreutils basic commands like p, mv, dd, tar, gzip/gunzip, cat, etc. It can also provide additional information such as ETA and throughout.

Installing Progress

Progress Usage with Examples

The general syntax for progress is watch progress -q. This lets you monitor all current and upcoming transfers in a terminal window. Now, any coreutils utility you invoke like cp and mv will be detected and indicated in the progress window.

Monitoring Downloads

progress -wc google-chrome

The -c switch can be used to monitor a command name like google-chrome or firefox

3) Rsync

Rsync is used to sync files locally and remotely. Rsync can be used to copy files and also has the ability to show the progress without the use on an external application.

Installing Rsync

Fedora, CentOS and RHEL

# yum install rsync

Debian, Ubuntu and Linux Mint

# apt-get install rsync

Rsync Usage with Examples

You need to use rsync with the -P or --progress option to show progress during file transfer. The basic syntax for rsync is

checking whether mknod can create fifo without root privileges... configure: error: in `/home/xxx/coreutils-8.21': configure: error: you should not run configure as root (set FORCE_UNSAFE_CONFIGURE=1 in environment to bypass this check) See `config.log' for more details

Run the following command to fix that error and rerun the ./configure command again:

# export FORCE_UNSAFE_CONFIGURE=1

Replace the original cp and mv commands with these two new commands

# cp src/cp /usr/local/bin/cp
# cp src/mv /usr/local/bin/mv

Advanced Copy Usage with Examples

The cp and mv commands stay same, the only change is adding the -g or -progress-bar switch to the cp command. The -R switch is used to copy directories recursively. Here is an example of the command:

$ cp -gR /home/linoxide /home/linoxide/Desktop

Or

# cp -R --progress-bar home/linoxide /home/linoxide/Desktop

We’ve seen a couple tools and how they can be used to monitor progress on commands. The pv command is easy to setup and can monitor any command line activity. The progress utility is limited to only coreutils commands. Rsync has the inbuilt ability to monitor file transfers and advanced copy is a patch applied to only the cp and mv commands to show progress. Based on your trial, you can decide which of these is best for you.

Eyram Amedzor2:00 am

SHARE ON

About Eyram Amedzor

Kwaku Eyram has been a working with computers and software for more than 10 years. He's an all-round geek and very fluid with Linux, Android and Windows operating systems. Asides being a tech enthusiast, Kwaku doubles as a tech support personnel and a tech writer. He currently has interest in IoT, web development and information security.

Hand-picked related articles

The word kill itself shows its clear meaning and purpose. In Linux, kill command is used for terminating the process. The command kill sends the specified signal to the specified process or the process group. First we need find PID [...]

Eclipse is a free integrated development environment IDE which is used by programmers around to write software mostly in Java but also in other major programming languages via Eclipse plugins. Eclipse is not only good at developing applications but you [...]