fbpx scp Command on Linux: Copy Files via SSH | Certificação Linux

scp Command in Linux: Copy Remote Files Securely over SSH

📅 12/06/2021 ⏱ 2 min ✍️ Uira Ribeiro
Linuxcommands
scp Command in Linux: Copy Remote Files Securely over SSH
Exam Pass App — mais de 7.000 questões LPI, offline, em 5 idiomas, disponível no Android e na App Store
Available on
Google Play
Available on
App Store

The scp command in Linux copies files to/from remote computers using the SSH protocol, securely. 

scp can be used to send or receive files, depending on whether the source or destination is a remote copy path.

A remote path has the following syntax: user@address:/directory.

Examples:

To copy the local file /home/uira/arquivo to servidor.com using the uira user credentials:

$ scp /home/uira/arquivo [email protected]:/tmp

To copy the file /home/www/arquivo from servidor.com to the local directory /home/uira:

$ scp [email protected]:/home/www/arquivo /home/uira

You can also use "." to represent the current directory:

$ scp [email protected]:/home/www/arquivo .

Wildcards can also be used:

$ scp /home/uira/*.js [email protected]:/var/www/html/js

It is important that the user has write permissions in the destination directory.

scp can be used with the following options:

  • -C Compresses files during transfer;
  • -p Preserves file permissions and access and modification dates;
  • -r Recursively copies subdirectories and files;

scp can also be used to make copies directly between two remote machines:

$ scp -rcv usuario1@maquina1:/arquivos usuario2@maquina2:/backup

Learn much more about Linux in our online course. You can enroll here. If you already have an account, or want to create one, just log in or create your user here.

Liked it? Share

Uira Ribeiro

Prof. Uirá Ribeiro

Chair do Board do Linux Professional Institute

After years of watching professionals waste hours on simple tasks because they didn't know the right Linux tools, I decided to teach.
Today I'm the author of most of LPI's official Learning Materials and mentor to over 14,000 certified students.

See my full story →

That was just one piece. The course teaches the whole path — from your first command to exam day.

Certificação Linux — a plataforma líder em certificações Linux no Brasil
WhatsApp