0
0
Linux CLIscripting~30 mins

scp and rsync for file transfer in Linux CLI - Mini Project: Build & Apply

Choose your learning style9 modes available
Secure File Transfer with scp and rsync
📖 Scenario: You work as a system administrator. You need to securely copy files from your local machine to a remote server. You will use scp and rsync commands to transfer files efficiently.
🎯 Goal: Learn how to use scp and rsync commands to transfer files from your local machine to a remote server securely and efficiently.
📋 What You'll Learn
Create a sample file to transfer
Set a variable with the remote server address
Use scp to copy the file to the remote server
Use rsync to copy the file to the remote server with progress shown
Display the final confirmation message
💡 Why This Matters
🌍 Real World
System administrators and developers often need to transfer files securely between computers. Using scp and rsync helps automate and speed up this process.
💼 Career
Knowing how to use scp and rsync is essential for roles involving server management, backups, deployment, and automation.
Progress0 / 4 steps
1
Create a sample file to transfer
Create a file called sample.txt with the exact content: Hello, this is a test file for transfer.
Linux CLI
Need a hint?

Use the echo command with redirection > to create the file.

2
Set the remote server address variable
Create a variable called REMOTE_SERVER and set it to user@192.168.1.100:/home/user/
Linux CLI
Need a hint?

Use = to assign the string to the variable without spaces.

3
Use scp to copy the file to the remote server
Use the scp command to copy sample.txt to the remote server using the REMOTE_SERVER variable.
Linux CLI
Need a hint?

Use double quotes around $REMOTE_SERVER to expand the variable correctly.

4
Use rsync to copy the file with progress and print confirmation
Use the rsync command with -avh --progress options to copy sample.txt to the remote server using the REMOTE_SERVER variable. Then print Transfer complete! using echo.
Linux CLI
Need a hint?

Use rsync -avh --progress sample.txt "$REMOTE_SERVER" and then echo "Transfer complete!".