Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When copying files using cp, is it possible to display the progress and speed of the transfer? Otherwise, is there any alternative command line utility that can achieve this?

share|improve this question

12 Answers 12

up vote 122 down vote accepted

While cp hasn't got this functionality, you can use pv to do this:

pv my_big_file > backup/my_big_file

Note: this method will lose the file's permissions and ownership. Files copied this way will have the same permissions as if you'd created them yourself and will belong to you.

In this example, pv basically just outputs the file to stdout*, which you redirect to a file using the > operator. Simultaniously, it prints information about the progress to the terminal when you do that.

This is what it looks like:

stefano@ubuntu:~/Data$ pv my_big_file > backup/my_big_file
 138MB 0:00:01 [73.3MB/s] [=================================>] 100% 

You may need to  Install pv (alternatively, type sudo apt-get install pv) on your system.

*: The technical bit

There are three important streams of data in a unix-like system: stdout (standard output), stderr (standard error) and stdin (standard input). Every program has all three, so to speak. The pipe-operator redirects a programs output to another programs input. The > operator redirects a programs standard output to a file. cp basically does nothing fancier than

cat source > destination

(where cat just reads a file and prints it to stdout). pv is just like cat, but if you redirect it's output stream somewhere else, it will print progress information to stdout instead.

Take a look at man pv to learn more about it.

Another option, as alt textDoR suggests in this answer, is to use rsync instead:

rsync -ah --progress source-file destination

alt text

This will preserve the files permissions/ownership while showing progress.

share|improve this answer
It may or may no be significant (depending on the situation), but pv does not handle permissions the same way as cp does... (based on one quick test I tried: pv didn't copy the execute bit across.. rsync did. – Peter.O Dec 14 '10 at 15:55
IMO: alias cp="rsync -avz" cp is outdated. – Marco Ceppi Dec 26 '10 at 1:26
If you're like me, and forget about pv, you can go snooping in /proc/PID of cp/fd and /proc/PID of cp/fdinfo to figure out progress. (It's up to you to infer speed.) I use this technique to watch updatedb. – Thanatos Dec 26 '10 at 1:30
@MarcoCeppi I copied you alias to my dot file but that didn't work out very well. -z makes copying files 3 times slower on my computer so I delete that option. – hrzhu May 17 '15 at 2:51
Yes, -z should probably only be used for network copies; compressing and decompressing the data for a local copy is pure overhead. – Matthew Read Jun 17 '15 at 15:17

If you want to see if your files are transferring correctly you could use gcp and gcp is like cp but by default gives you a progress bar so that you can see what is being copied. As the program's wiki notes, gcp has several useful features such as

  • transfer progression indication
  • continuous copying on error (skip to next file)
  • copy status logging: gcp logs all its actions so that it is possible to know which files have been successfully copied
  • name mangling to handle target filesystem limitations (for example deletion of incompatible characters "*" or "?" on FAT)

However, even when the progress bar has reached 100% when using the tool, you must wait until your terminal prompt reappears before safely removing your media so that you can ensure that the transfer process has successfully finished.

gcp is used to copy files and has options such as --preserve so that various attributes and permissions can be preserved and --recursive so that whole directories can be copied. More information on its options can be found by entering man gcp or by going to the Ubuntu manpages online. A tutorial is also available on this site.

Install gcp from the repositories with

sudo apt-get install gcp

(Note: in Ubuntu 12.10 the new automount point is, for example, /media/user/usbdisk)

You can copy a file to your media by entering

gcp /home/mike/file.mp4 /media/usb

and copy a folder to your media with

gcp -rv ~/Podcasts /media/Mik2

Sample output from gcp with the progress bar:

gcp ~/Videos_incIplayer/mars.flv /media/Mik2
Copying 168.57 MiB 100% |########################################################|   7.98 M/s Time: 00:00:22

You can of course specify multiple files or folders to copy to your disk, and there are a lot of other options covered in man gcp.

share|improve this answer
Got error with it over ssh dbus.exceptions.DBusException: org.freedesktop.DBus.Error.NotSupported: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11 – msa7 Jan 17 at 23:29

There isn't. See here as to why. Although it does more than you need, rsync has one with --progress parameter. The -a will keep permissions,etc, and -h will be human readable.

rsync -ah --progress source destination
share|improve this answer
This works great in the current Ubuntu (14.10). It also supports the -r flag to recurse directories. It can even be aliased as a direct replacement for cp: alias cp="rsync -ah --progress" – rustyx Dec 23 '14 at 21:04
Works swell on OS X, with the bonus of being able to use tools included with the system. – Ivan X Apr 24 '15 at 20:11

I get a kick out of using cURL for this exact purpose. The man page lists the "FILE" protocol as supported, so just use it like any other protocol in a URL:

curl -o destination FILE://source

Speed, progress, time remaining, and more -- all in a familiar format.

share|improve this answer
This is great especially in environments where you are prohibited from installing new tools and where rsync is unavailable. – user190264 Sep 5 '13 at 7:00
+1 nice trick!. – Harikrishnan Jun 30 '15 at 10:53
Brilliant, this has got to be a must-known hack! – ionreflex Oct 20 '15 at 18:13

While it doesn't display speed, when copying multiple files, the -v option to the cp command will provide you with progress info. e.g.

cp -rv old-directory new-directory
share|improve this answer
Progress info? This is just verbose output. To provide progress info you would at least need to now how many files, or even which files, needs to be copied. – Julian F. Weinert Jul 3 '15 at 20:21

The kernel knows most of the data, like speed, and often also percentage. Modern kernels expose this via their /proc filesystem.

showspeed from uses that info. It can attach to already running programs, and give periodict updates like this:

$ dd if=bigfile of=/tmp/otherbigfile &
$ showspeed dd
dd looks like a process name. pid=4417 matches av0=dd.
p/4417/fd/0r /home/jw/bigfile 113MB/s (12%, 2.3GB)  9m:35
p/4417/fd/1w /tmp/otherbigfile 182MB/s (2.6GB)
p/4417/fd/0r /home/jw/bigfile 285MB/s (15%, 3.0GB)  8m:08
p/4417/fd/0r /home/jw/bigfile 115MB/s (16%, 3.2GB)  8m:01
p/4417/fd/0r /home/jw/bigfile 107MB/s (17%, 3.4GB)  7m:39
p/4417/fd/1w /tmp/otherbigfile 104MB/s (3.5GB)
p/4417/fd/0r /home/jw/bigfile 139MB/s (19%, 3.7GB)  7m:37
p/4417/fd/0r /home/jw/bigfile 116MB/s (20%, 3.9GB)  7m:18
p/4417/fd/1w /tmp/otherbigfile  67MB/s (4.0GB)
p/4417/fd/1w /tmp/otherbigfile 100MB/s (4.1GB)
share|improve this answer
Nice one. How does it work out percentages though? I guess only in case of file s open as read only? And it will probably not work in case of scattered access. – j_kubik Dec 22 '14 at 17:29
In this case you can also use another terminal to run pkill -USR1 dd to make dd show its status, another option would be watch -n 1 pkill -USR1 dd to make it show its progress periodically (every second). – Yaron Mar 16 '15 at 9:23

While pv can deal with local cp tasks, using dd with pv can deal with both local (cp) and remote (scp) tasks.

dd if=path/to/source.mkv | pv | dd of=path/to/dest.mkv

Please ensure the path/to/dest.mkv exits by touch path/to/dest.mkv

This can show the progress, but if you want the percentage information,

dd if=path/to/source.mkv | pv -s 100M | dd of=path/to/dest.mkv

Replace 100M above with the real size of your source file.

Here Comes the Remote Part

While scp can hardly show current progress, using dd with pv is a piece of cake.

ssh onemach@myotherhost dd if=path/to/source.mkv | pv -s 100M | dd of=path/to/dest.mkv
share|improve this answer

There's a new tool called cv that can find any descriptor related to a running command and show progress and speed:

cv -w

outputs the stats for all running cp,mv etc. operations

share|improve this answer
watch cv -q is even neater – wiak Jan 19 '15 at 0:42
It only show progress for an individual files, it does realise whether a cp is copying a directory recursively or not. – Flimm Mar 31 at 9:27
It war renamed to progress. Great tool! – sebastian Jun 25 at 14:42

As many said, cp does not include this functionality.

Just to throw my $0.02, what I usually do with trivial copying situations (i.e. no -R):

  1. See how big the file is and remember

  2. Start copying

  3. Open another terminal

  4. Run watch ls -lh DIR on the directory where the target is

This can keep me updated on target file size, with quite a minimum hassle.

As an alternative for less trivial situations, e.g. recursively copying directories, you can use watch du -hs DIR to see summary of DIR size. However du can take long to compute and can even slow down the copying, so you might want to use -n INTERVAL argument to watch so that trade-off is acceptable.

Update: In case you use wild-cards with command used with watch du, e.g. watch du -hs backup/*, don't forget to quote:

watch "du -hs backup/*"

otherwise the wild-cards will be expanded only once, when watch is started so du will not look at new files / subdirectories.

share|improve this answer
Does not answer the "speed" part, though... – Alois Mahdal Nov 16 '12 at 13:21

Use a shell script:

   strace -q -ewrite cp -- "${1}" "${2}" 2>&1 \
      | awk '{
        count += $NF
            if (count % 10 == 0) {
               percent = count / total_size * 100
               printf "%3d%% [", percent
               for (i=0;i<=percent;i++)
                  printf "="
               printf ">"
               for (i=percent;i<100;i++)
                  printf " "
               printf "]\r"
         END { print "" }' total_size=$(stat -c '%s' "${1}") count=0

This will look like:

% cp_p /home/echox/foo.dat /home/echox/bar.dat
66% [===============================>                      ]


share|improve this answer

Depending on what you want to do, Midnight Commander (mc) might be the answer. I'm surprised it's not been mentioned yet.

Tools like pv or rsync are good to display progress of transfer of one huge file, but when it comes to copying whole directories/trees, mc calculates the size and then displays the progress very nicely. Plus it's available out of the box on majority of systems.

share|improve this answer
"it's available out of the box on majority of systems." ... not on any default Ubuntu installation. – muru Jan 30 at 17:58

If you have rsync 3.1 or higher (rsync --version), you can copy (cp -Rpn) while preserving permissions and ownership, recurse directories, "no clobber," and display overall progress (instead of just progress by file), copy rate, and (very rough) estimated time remaining with:

sudo rsync -a --info=progress2 --no-i-r /source /destination

Note that sudo is only needed if dealing with directories/files you don't own. Also, without the --no-i-r, the percentage may reset to a lower number at some point during the copy. Perhaps later versions of rsync will default to no-i-r with info=progress2, but it does not in the current version of 3.1.2.

I've found that the percentage and time remaining are grossly overestimated when copying to a directory that already contains files (ie. like when you would typically use cp -n "no clobber").

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.