KevsRobots Learning Platform

Introduction to the Linux Command Line on Raspberry Pi OS

52% Percent Complete

Transferring Files Over a Network

Learn how to securely transfer files between machines using scp and rsync.

By Kevin McAleer,    2 Minutes


cover image

Introduction

Transferring files over a network is a common task, especially when working with multiple devices. In this lesson, you’ll learn how to securely transfer files between machines using scp and rsync.


Learning Objectives

  • Transfer files securely between machines using scp.
  • Use rsync for efficient file transfers and synchronization.

Transferring Files with scp

The scp (secure copy) command is used to transfer files between two machines over a secure connection. For example, to copy a file from your Raspberry Pi to another machine:

scp example.txt [email protected]:/home/pi/

To copy a file from another machine to your Raspberry Pi:

scp [email protected]:/home/pi/example.txt /home/pi/

Synchronizing Files with rsync

The rsync command is a powerful tool for efficiently transferring and synchronizing files between machines. It only transfers the differences between the source and the destination, making it faster than scp for large directories.

rsync -avh /home/pi/Projects/ [email protected]:/home/pi/Projects/

The -avh flags stand for archive mode, verbose output, and human-readable output, respectively.


Summary

In this lesson, you learned how to securely transfer files between machines using scp and rsync. These tools are essential for managing files across multiple devices, especially in networked environments.


< Previous Next >