What is the difference between scp and cp?

30,616

Solution 1

TL;DR Read the man pages:

man scp
man cp

From man scp

NAME
     scp — secure copy (remote file copy program)

SYNOPSIS
     scp [-12346BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file] [-l limit] [-o ssh_option] [-P port] [-S program] [[user@]host1:]file1 ...
         [[user@]host2:]file2

DESCRIPTION
     scp copies files between hosts on a network.  It uses ssh(1) for data transfer, and uses the same authentication and provides the same security
     as ssh(1).  scp will ask for passwords or passphrases if they are needed for authentication.

     File names may contain a user and host specification to indicate that the file is to be copied to/from that host.  Local file names can be made
     explicit using absolute or relative pathnames to avoid scp treating file names containing ‘:’ as host specifiers.  Copies between two remote
     hosts are also permitted.

from man cp

NAME
       cp - copy files and directories

SYNOPSIS
       cp [OPTION]... [-T] SOURCE DEST
       cp [OPTION]... SOURCE... DIRECTORY
       cp [OPTION]... -t DIRECTORY SOURCE...

DESCRIPTION
       Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.

       Mandatory arguments to long options are mandatory for short options too.

Solution 2

scp is really for remote copying over SSH. Eg:

scp /path/to/local/file user@server:/path/to/target/dir/

Solution 3

scp or Secure Copy is primarily used to copy between a local host and remote host, or two remote hosts, via ssh

The cp command is for copying files locally, i.e. within your host's system.

The man pages that muru has linked in comments should help you understand usage, but there are many tutorials on that internet thing too.

Solution 4

You should also learn that there is a man command. Try it! man cp, man scp, man man.

man cp starts out:

    NAME
       cp - copy files and directories

SYNOPSIS
       cp [OPTION]... [-T] SOURCE DEST
       cp [OPTION]... SOURCE... DIRECTORY
       cp [OPTION]... -t DIRECTORY SOURCE...

DESCRIPTION
       Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.

and man scp begins with:

    NAME
     scp — secure copy (remote file copy program)

SYNOPSIS
     scp [-12346BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file] [-l limit] [-o ssh_option] [-P port] [-S program] [[user@]host1:]file1 ... [[user@]host2:]file2

DESCRIPTION
     scp copies files between hosts on a network.  It uses ssh(1) for data transfer, and uses the same authentication and provides the same security as     ssh(1).  Unlike rcp(1), scp will
     ask for passwords or passphrases if they are needed for authentication.
Share:
30,616

Related videos on Youtube

BDD
Author by

BDD

Strategic Solutions Engineer with extensive public and private sector experience

Updated on September 18, 2022

Comments

  • BDD
    BDD over 1 year

    I'm really new to the command line and Ubuntu and I have recently learned that there is the scp command as well as the cp command. I tried to use an scp command to move a directory from Point A to Point B, but it didn't work. However, when I used cp, it worked just fine.

    What is the difference between the two and how do I determine when to use one over the other?

  • BDD
    BDD almost 9 years
    Well. I feel dumb. I totally forgot about the man pages. Thanks!