≡ Menu

Linux Copy Command Examples

How do I copy files under Linux operating systems?

You need to use the cp command to make copies of existing file. The syntax is as follows:

 cp source.file destination.file


 cp /path/to/file1 /path/to/file2

For example, make a copy of /etc/passwd as /tmp/password.file, enter:

 cp /etc/passwd /tmp/password.file
cat /tmp/password.file

To copy file to another system, use scp command:

scp /path/to/file1 user@server1:/tmp

For example, copy /home/vivek/data.txt to server called server1 and into a directory called /home/sales, enter:

scp /home/vivek/data.txt roja@server1:/home/sales

You must know roja users’ password in order to copy a file.

Copy All Files

To copy all files from /data/sales/*.txt to /backup directory, enter:

cp -avr /data/sales/*.txt /backup


  • -a : Archive mode and save file permission
  • -v : Verbose mode (show progress)
  • -r : Copy directories recursively

scp vs cp command

  • The scp copies files between hosts on a network.
  • The cp copies files between two directories on same host.
Share this tutorial on:

Like this? Follow us on Twitter OR support us by using Patreon

{ 0 comments… add one }
Security: Are you a robot or human?

Leave a Comment

You can use these HTML tags and attributes: <strong> <em> <pre> <code> <a href="" title="">

   Tagged with: , , , , , , , , ,