How to Show Progress When Copying Files in Linux Terminal

It is true that the Ubuntu today is practically usable with your mouse clicking around but at times, it is a good idea to use the terminal to do some of your things as well.

When I first get into the Linux terminal, one of my major problem is copying large file. For instance, if I were to copy few GB of file, I will have no clue whether the copy is still in progress or my Linux machine already hang using the CP command.

As a result, it is always good if there is a chance that the progress bar is shown when copying files in the terminal.

So, I finally learned from a friend of mine that I could actually copy files and show both progress and transfer speed at the same time. I use the rsync command with the following parameter to copy files:

rsync -Pa source destination

Where the parameter ‘P’ stands for progress and ‘a’ stands for ‘rlptgoD’ which means in short, preserving all the files and folders attributes such as owners, permission, groups, symbolic links, time and etc.

An example of usage is as below:

  • rsync -Pa newFile.txt /home/alan/

where this command will copy newFile.txt to /home/alan/ directory.

 

Apart from this, you can also use the rsync command to copy files from/to remote server. What you need to do is just to do a simple SSH login within the rsync command.

Here is how you do it:

  • rsync -Pa newFile.txt alan@192.168.1.100:newFile.txt

where this command will copy newFile.txt to a remote server at 192.168.1.100 with the username ‘alan’.

 

CP vs RSYNC

Both cp and rsync is capable of copying files and folders where I find both useful at different scenario.

The advantage of cp is it is as short as two letters, which means it is good for you to transfer small file and you don’t have to specify any parameter.

The advantage of rsync is it can show progress and preserving all the file attribute but you will need to type a lot more before executing the command. As a result, I find rsync is better only when you want to do file transfer that is big or remotely.

There are pros and cons for both commands and I don’t see there is any chance I can say any of them is useless.

About Alan Tay

Alan Tay is a Software Engineer who works for a Security Firm in Malaysia. Spend most of my time blogging and get in touch with all the tech stuff. Owner and founder of Open Source Buddy

Speak Your Mind

*

CommentLuv badge
This blog uses premium CommentLuv which allows you to put your keywords with your name if you have had 3 approved comments. Use your real name and then @ your keywords (maximum of 3)