• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
sharadchhetri

sharadchhetri

Tutorials On Linux, Unix & Open Source

  • Home
  • Linux Commands
  • Resources
    • Learn Linux
  • My WordPress plugins

SCP file and directory in linux and Unix like operating system

September 23, 2013 by Sharad Chhetri Leave a Comment

SCP stands for secure copy.It is based upon SSH (Secure Shell) protocol.SCP is used for securely transferring the files between local and remote system.
Note: If SSH service is not running or deny by firewall or IPTABLES of system then SCP will also not work.

Syntax:
scp SOURCE-FILE-LOCATION TARGET-LOCATION

(1) SCP file from local to remote system

Run the below given command from your system

scp filename remote-username@remote-ip-address:/path/to/transfer/file

eg.


scp test.txt sharad@192.168.1.19:/tmp

(2) SCP Directory from local to remote system

Run the below given command from your system

scp -r directory-name remote-username@remote-ip-address:/path/to/transfer/directory

eg.


scp  -r testdir sharad@192.168.1.19:/tmp

(3) SCP file from remote to local system

Run the below given command from your system

scp remote-username@remote-ip-address:/path/of/target-FILE /path/in/your/localSystem

eg.


scp sharad@192.168.1.19:~/test.txt  ~/Desktop

(4) SCP directory from remote to local system

Run the below given command from your system

scp remote-username@remote-ip-address:/path/of/target-DIRECTORY /path/in/your/localSystem

eg.


scp -r sharad@192.168.1.19:~/testdir  ~/Desktop

If SSH port no. is changed from port no. 22 to other one

SSH port no. = 2211

(Note: SSH port no. might be different in your case hence give your ssh port no. instead of 2211)

Syntax:
scp -P port.no SOURCE-FILE-LOCATION TARGET-LOCATION

(1A) SCP file from local to remote system

Run the below given command from your system

scp -P port.no. filename remote-username@remote-ip-address:/path/to/transfer/file

eg.


scp-P 2211 test.txt sharad@192.168.1.19:/tmp

(2A) SCP Directory from local to remote system

Run the below given command from your system

scp -P port.no -r directory-name remote-username@remote-ip-address:/path/to/transfer/directory

eg.


scp  -p 2211 -r testdir sharad@192.168.1.19:/tmp

(3A) SCP file from remote to local system

Run the below given command from your system

scp -P port.no remote-username@remote-ip-address:/path/of/target-FILE /path/in/your/localSystem

eg.


scp -P 2211 sharad@192.168.1.19:~/test.txt  ~/Desktop

(4A) SCP directory from remote to local system

Run the below given command from your system

scp -P port.no remote-username@remote-ip-address:/path/of/target-DIRECTORY /path/in/your/localSystem

eg.


scp -P 2211-r sharad@192.168.1.19:~/testdir  ~/Desktop

Share this:

  • Twitter
  • Facebook
  • More
  • Print
  • Email
  • LinkedIn
  • Reddit
  • Tumblr
  • Pinterest
  • Pocket
  • Telegram
  • WhatsApp
  • Mastodon

Related posts:

  1. shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
  2. scp command not found in CentOS and Red Hat
  3. print working directory ( pwd , PWD , OLDPWD ) in Linux / Unix
  4. Centralize authorized_keys file on Linux / Unix system
  5. How to remove CONTROL-M characters from a file : Linux / Unix
  6. NOTICE: nagios.cmd file not found. Please specify the location of this file in your /etc/vshell.conf file
  7. How to find when Operating system was installed in linux CentOS and Red Hat
  8. Find Linux Operating System architecture installed on system
  9. run command in remote linux / unix system by using ssh
  10. plugins/python/uwsgi_python.h:2:20: fatal error: Python.h: No such file or directory

Filed Under: Linux, SSH Tagged With: scp, ssh

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Our Social Media Presence

  • Facebook
  • GitHub
  • Twitter

Linux Command

What is Linux Internal And External Command

Linux Basic Commands With Examples For Every Beginner

tr command to convert lines to space , tab and vertical tab

smbpasswd command not found on CentOS 7 and RHEL 7

Solution : semanage command not found

Unix / Linux : How to print duplicate lines from file

More Posts from this Category

You Might Like These Articles!

simplecodesyntax wordpress plugin

SimpleCodeSyntax : My Another WordPress Plugin

Install Nginx

How To Install Nginx On Ubuntu 22.04 LTS

Install Latest Git package in Ubuntu Operating System

How To Always Install Latest Git Package In Ubuntu Operating System

Bash script for installing VirtualBox on Ubuntu 22.04 LTS Desktop

Install VirtualBox On Ubuntu 22.04 LTS Desktop (Bash Script)

libfuse

dlopen(): error loading libfuse.so.2 – Got Error On Ubuntu

Failed to open/create the internal network

VirtualBox Error: Failed to open/create the internal network

Always Useful Tips And Tricks

How to download package using apt-get command in ubuntu

The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form

Keep logs of user after sudo su – : Secondary Logging

Read the file inside compressed .gz files without extract

How to find swap partition or file in linux

error command ‘gcc’ failed with exit status 1 in Ubuntu

Non interactive ,without typing password do ssh to Server : By sshpass

Explore 90+ Article On "Linux Tips And Tricks"

Copyright © 2023 ยท
The material in this site cannot be republished either online or offline, without our permission.
Proudly Blogging From Bharat.

  • Contact
  • About Me
  • My WordPress plugins
  • Privacy Policy