1/5
File
Transfer
Commands
in Linux
Oscar Mulo
Linux Expert
2/5
ftp
(File Transfer Protocol)
ftp is a standard network protocol used to transfer files between
a client and a server. It's one of the oldest file transfer methods
but is not secure, as data (including passwords) is transmitted
in plaintext.
Connect to an FTP Server:
bash
ftp <hostname or IP address>
Example:
bash
ftp ftp.example.com
Download a File:
bash
get <filename>
Example:
bash
get file.txt
Upload a File:
bash
put <filename>
Example:
bash
put file.txt
List Files:
bash
ls
3/5
scp
(Secure Copy Protocol)
scp allows you to securely transfer files between hosts over SSH.
It encrypts both the files and the authentication process,
making it a secure alternative to ftp.
Copy a File from Local to Remote:
bash
scp <local_file> <remote_user>@<remote_host>:
<remote_directory>
Example:
bash
scp file.txt user@remote_host:/home/user/
Copy a File from Remote to Local:
bash
scp <remote_user>@<remote_host>:<remote_file>
<local_directory>
Example:
bash
scp user@remote_host:/home/user/file.txt /local/dir/
Copy an Entire Directory:
bash
scp -r <local_directory> <remote_user>@<remote_host>:
<remote_directory>
Example:
bash
scp -r /local/dir user@remote_host:/home/user/
4/5
Other Useful Commands
for File Transfer
rsync:
An advanced file transfer tool that syncs directories and files
between two locations. It’s faster and more efficient than scp
for transferring large files or keeping directories in sync.
Example:
bash
rsync -avz <source> <destination>
sftp
Secure File Transfer Protocol, similar to ftp, but it runs over SSH
for secure data transmission.
Example:
bash
sftp user@remote_host