How to Monitor Linux Command Progress (Using pv and progress)

Instead of flying blindly, use the Linux pv and progress Commands to track the progress of an command. These utilities give you progress bars for commands that normally don’t have. You will also see an estimated time to complete.

When you’re sitting in the seat backs on an airplane with no video screens on a long-haul flight, knowing how far along your journey is is not easy. They know when you left. You know how long the flight is likely to take. But how do you know if you are on schedule, on time, or way behind schedule? If you don’t want to see the in-flight movie, you can usually toggle your video screen to show a map with your aircraft’s location. You will also get some statistics such as: B. an expected time of arrival (ETA) which is great.

Launching a command from the terminal window can sometimes feel like a long haul flight without a screen. You have nothing to say if everything is okay or if the process has got stuck or how close at the end it is. A blinking cursor is not very informative.

the pv and progress Commands give you some stats and a little bit of visual feedback. You can see how close the process should be completed. This means that you receive an ETA for your ongoing processes. Compared to staring at a cursor, this definitely wins.

Install PV

You need to install pv.

To install pv On Ubuntu, use this command:

sudo apt-get install pv

To install pv At Fedora use this command:

sudo dnf install pv

To install pv On Manjaro, use this command:

sudo pacman -Syu pv

pv. use

pv stands for Pipe viewer. Piping needs to be included in the command somewhere. Here is a example where we pass through an ISO image zip to create a compressed ZIP file of the ISO.

In order to slow down the commands enough to take a screenshot, some of the files in the examples for this article were saved on an old, slow external USB stick called SILVERXHD.

pv /media/dave/SILVERXHD/gparted-live-1.0.0-1-amd64.iso | zip >

The information pv gives us to see in the bottom line of the display.

The following information is displayed from left to right:

  • The data transferred so far.
  • Time has passed so far.
  • The data transfer rate (throughput).
  • A progress bar and a completed percentage.
  • The estimated time to complete (ETA).

Copy a file with pv

How to copy a file with the output of pv, use this command:

pv /media/dave/SILVERXHD/gparted-live-1.0.0-1-amd64.iso > gparted.iso

We get a progress report as the file is copied.

Copy a file with pv into a terminal window

Multiple files with pv. copy

How to copy multiple files and folders with pv We have to use a little trick. We use tar to move the files for us.

tar -c help-files/ | pv | tar -x -C Documents/

the tar -c help-files/ Part of the command instructs tar create (-c) an archive of the files in the help-files folder. That is passed through pv so that we can get an indication of the progress. It is then routed back in tar for the last part of the command. The archive is extracted (-x) and the directory is changed (-C) to documents before extraction.

Therefore, the files and folders in Help files are copied to the “Documents” folder with a progress indicator.

The output is a little different this time.

We don’t get an ETA. The progress bar now shows a moving indicator. It shows that the process is active, but it doesn’t grow from left to right like a traditional progress bar. pv is limited to showing the information it can extract from the routed process.

Using pv and tar to create an archive

Copying files with pv and tar does not leave us an archive file. A kind of “virtual” archive is created by tarthat is fed back directly into the grid tar to extract the files. If our goal is to copy files then we have achieved it. But what if we want to create an archive file?

We can still use it tar to create an archive file and get a progress report from pv. The options with tar are -c (Create archive), -z (compress with gzip) and -f (File name of the archive).

Notice that we are using - as the filename, which causes tar use stdoutand write its output to the terminal window. We do not see this output because it is being passed through pv.

The actual name of the archive will be the filename from which we pipe the output pv into it. In this case it is “help-files.tgz”.

tar -czf - ./help-files/ | pv > help-files.tgz

We get the same progress bars as before and the archive file is created for us.

How to compress and extract files using the tar command on Linux

The PV display options

There are a number of options that you can use pv change the details of his report.

If you use either of these options, all other options are disabled. So if you want to use three of the display options, you must specify those three options.

Using pv without options is the same as using the -pterb Options.

  • -p: shows the percentage completed. This is the progress bar and the percentage of completion.
  • -t: shows the elapsed time.
  • -e: Displays the ETA.
  • -r: Displays the data transfer rate.
  • -b: Display of the number of bytes (previously transmitted data).
  • -n: Displays the percentage as an integer. This prints the percentage completed as an integer, with each new update on a new line.

Let’s repeat the last command and pass the -p (Percentage complete) option too pv.

tar -czf - ./help-files/ | pv - p > help-files.tgz

This will disable all other display options. pv returns only the percentage of the completed item.

because pv does not get a percentage completed number of tar, the progress bar is replaced by a moving display. There is no percentage.

Use of PV with toilet

We can use pv to route a text file (or files) wc. wc then counts the line breaks, characters and words and pv will give us a progress report.

Here we direct all “.page” files in the help-files directory wc.

When wc is complete, we can see the number of carriage returns (lines), characters and words from all of the “.page” files in the help-files folder.

Install the progress command

the progress Command gives the same kind of useful information how pv, but it works with a specific set of Linux commands.

To install progress In Ubuntu, use this command:

sudo apt-get install progress

To install progress in Fedora, use this command:

sudo dnf install progress

sudo    dnf install progress in a terminal widow

To install progress In Manjaro, use this command:

sudo pacman -Syu progress

The command progress works with

Tap progress in a terminal window and press Enter gives you a list of commands that progress works with.


Use progress with pipes

There are two techniques we can use to monitor commands progress. The first is to use pipes.

the tar Command can be found in the list of supported commands included in the progress can monitor, so we use tar.

The options we use are the standard -c (Create archive), -z (compress with gzip) and -f (Filename) options. We are going to create a compressed archive of everything in the help-files folder, and the archive will be called “help.tgz”.

We initiate that progress and use the -m (Monitor) option like this progress keep reporting the process until it is completed.

tar -czf help.tgz ./help-files/ | progress -m

The terminal window shows the progress of the tar Command when creating the archive.

As each file is processed, it is listed with the following information:

  • The process ID.
  • The process name.
  • Percentage complete.
  • Processed data and total size of the file.
  • Data rate (throughput).
  • Estimated Time Remaining (ETA).

You will be surprised to see a second record. This first record is for tar. The second is for gzip. tar Calls gzip to perform the compression. because gzip is in the list of supported commands, progress reports about it.

Use progress in continuous monitoring mode

You can use progress in a real-time continuous monitoring mode by using the -M (Monitor) option.

Enter the following command in a terminal window:

progress -M

progress reports that no monitoring commands are being executed. However, you do not return to the command line. progress waits for a command to start that it can monitor. It will then automatically start reporting on it.

In another terminal window, type a command from the list of commands that progress can monitor.

We will use cat. Commands that pass too quickly are not registered with progress, so we are listing the contents of a very long text file.


In the terminal window with progress in it you can see statistics for the cat Command as it executes and works towards its completion.

When cat finishes listing the file progress returns to its waiting state.

Whenever any of the commands he can report on is doing a sizeable job, progress will monitor and report on it automatically.

That’s pretty neat.

100% completed

Stop worrying about long-running instructions and take a break from looking at your cursor pv and progress .

Linux commands
Filestar · pv · cat · tac · chmod · grep · difference · sed · With · man · pushed · popd · fsck · Test disk · seq · fd · pandoc · CD · $ PATH · awk · join · jq · wrinkles · unique · Journalctl · tail · stat · ls · fstab · echo · fewer · chgrp · chown · rev · look · Strings · Type · rename · Postal code · unzip · assemble · ummount · To install · fdisk · mkfs · rm · rmdir · rsync · df · gpg · weather · Nano · mkdir · from · ln · Patch · Convert · rclon · Scraps · srm
Processesalias · screen · above · kind · renice · progress · strace · system · tmux · chsh · story · at · Batch · for free · which · dmesg · chfn · User mod · ps · chroot · xargs · tty · pinkie finger · lsof · vmstat · Time out · Wall · Yes sir · kill · sleep · sudo · it is · Time · groupadd · User mod · groups · lshw · switch off · start anew · Stop · switch off · passwd · lscpu · crontab · date · bg · fg
Networkingnetstat · Ring · Trace route · ip · ss · who is · fail2ban · bmon · she · finger · nmap · ftp · curl · wget · who · who am I · w · iptables · ssh-keygen · ufw

Best Linux Laptops for Developers and Enthusiasts

Related Posts