/>
X
Tech
Why you can trust ZDNET : ZDNET independently tests and researches products to bring you our best recommendations and advice. When you buy through our links, we may earn a commission. Our process

'ZDNET Recommends': What exactly does it mean?

ZDNET's recommendations are based on many hours of testing, research, and comparison shopping. We gather data from the best available sources, including vendor and retailer listings as well as other relevant and independent reviews sites. And we pore over customer reviews to find out what matters to real people who already own and use the products and services we’re assessing.

When you click through from our site to a retailer and buy a product or service, we may earn affiliate commissions. This helps support our work, but does not affect what we cover or how, and it does not affect the price you pay. Neither ZDNET nor the author are compensated for these independent reviews. Indeed, we follow strict guidelines that ensure our editorial content is never influenced by advertisers.

ZDNET's editorial team writes on behalf of you, our reader. Our goal is to deliver the most accurate information and the most knowledgeable advice possible in order to help you make smarter buying decisions on tech gear and a wide array of products and services. Our editors thoroughly review and fact-check every article to ensure that our content meets the highest standards. If we have made an error or published misleading information, we will correct or clarify the article. If you see inaccuracies in our content, please report the mistake via this form.

Close

How to use the scp command in Linux

If you've been looking for an easy way to move files between Linux machines, Jack Wallen shows you how with the help of the scp command.
Written by Jack Wallen, Contributing Writer
gettyimages-1387361694
Maskot/Getty Images

When you want to transfer a file from one Linux computer to another, you have several options: Some of these options are GUI tools, and some are not. One of the most popular methods of transferring files also happens to be one of the more secure. That method is by way of the scp command.

Scp stands for Secure Copy and is part of the SSH tool, which nearly every Linux distribution includes out of the box. That means you don't have to install any extra software to get this done.

Also: The best Linux distros for beginners

At first glance, using scp might seem a bit confusing, but it's really not. I'm going to show you how it's done, so you can push and pull files from one Linux machine to another. 

What you'll need: To do this, all you'll need are two Linux machines. It doesn't matter what distribution you're using, but you will need user accounts on both machines. (They don't have to be the same user accounts, but you have to know the passwords for each account.) This will become more clear in a moment.

Using the scp command

1. Push a file from one machine to another

Let's say you have the file zdnet_test on your local machine and you want to push it to another machine at IP address 192.168.1.30. To do this, log into the local machine and open a terminal window. Let's say you have the same username on both the local machine and the remote machine. With that in mind, to push the zdnet_test file to the remote machine, you'd issue the command:


scp /path/to/zdnet_test 192.168.1.30:/home/USER

Where /path/to is the full path to the zdnet_test file and USER is the username on the remote machine.

You will be prompted for the user's password and, upon successful authentication, the file will be copied.

1. Pushing a file when your remote username is different.

Now, let's say you have a different user on the remote machine. In that case, the command would be:

scp /path/to/zdnet_test USER@192.168.1.30:/home/USER

Where /path/to is the full path to the zdnet_test file and USER is the username on the remote machine.

Again, you'll be prompted for the user password before the file is copied.

3. Pushing the file to a different remote directory

You could also push that file to a different directory (other than the user's home directory). The one caveat to this is the user must have permission to write to the directory in question. Let's say you want to copy that file to a directory on the remote machine, named /data. As long as the remote user has access to that directory, the command would be:

scp /path/to/zdnet_test USER@192.168.1.30:/data

Where /path/to is the full path to the zdnet_test file and USER is the username on the remote machine.

Once again, you'll be prompted for the user password before the file is copied.

4. Pulling a file from a remote machine

Let's say the zdnet_test file is on a remote computer and you want to copy it to the local machine. To do that, you'd issue the command:


scp 192.168.1.30:/path/to/zdnet_test /home/USER/zdnet_test

Where /path/to is the full path to the zdnet_test file and USER is the username on the remote machine.

And, yes, again you'll be prompted for the user password before the file is copied.

Also: The best Linux laptops (and why you might want one)

Like with pushing a file, you can also define the remote user and change the path to where the file will be saved.

And that, my dear friends, is all there is to use the scp command on Linux. Enjoy this handy ability to push and pull files from one Linux machine to another, with the help of secure copy.

Editorial standards