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.

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 0 comments... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
0 comments… add one

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum