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. Simultaneously, it prints information about the progress to the terminal when you do that.
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 > redirection operator redirects program output to a file. Without arguments, as you see above, > redirects a program's 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 DoR suggests in this answer, is to use rsync instead:
There isn't. See here as to why. Although it does more than you need, rsync has a --progress parameter. The -a will keep permissions,etc, and -h will be human readable.
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)
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.
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").
While
cp
hasn't got this functionality, you can usepv
to do this: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. Simultaneously, it prints information about the progress to the terminal when you do that.This is what it looks like:
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
>
redirection operator redirects program output to a file. Without arguments, as you see above,>
redirects a program's standard output to a file.cp
basically does nothing fancier than(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 DoR suggests in this answer, is to use rsync instead:
This will preserve the files permissions/ownership while showing progress.
There isn't. See here as to why. Although it does more than you need,
rsync
has a--progress
parameter. The-a
will keep permissions,etc, and-h
will be human readable.The output will look something like this:
If you want to see if your files are transferring correctly you could use
gcp
andgcp
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 asHowever, 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 enteringman gcp
or by going to the Ubuntu manpages online. A tutorial is also available on this site.Install
gcp
from the repositories with(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
and copy a folder to your media with
Sample output from
gcp
with the progress bar: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
.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:
Speed, progress, time remaining, and more -- all in a familiar format.
There is a tool called
progress
in the repositories that is able to examine various different commands and display progress info for them.Install it using the command
This tool can be used like that:
Output:
While it doesn't display speed, when copying multiple files, the
-v
option to thecp
command will provide you with progress info. e.g.The kernel knows most of the data such as speed, and often also percentage. Modern kernels expose this via their /proc filesystem.
showspeed from https://github.com/jnweiger/showspeed uses that info. It can attach to already running programs and give periodic updates like this:
While
pv
can deal with localcp
tasks, usingdd
withpv
can deal with both local (cp
) and remote (scp
) tasks.Please ensure the
path/to/dest.mkv
exits bytouch path/to/dest.mkv
This can show the progress, but if you want the percentage information,
Replace
100M
above with the real size of your source file.Here Comes the Remote Part
While
scp
can hardly show current progress, usingdd
withpv
is a piece of cake.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: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").
dd status=progress
Option added in GNU Coreutils 8.24+ (Ubuntu 16.04):
The terminal shows a line of type:
that gets regularly updated.
See also: How do you monitor the progress of dd?