KandZ – Tuts

We like to help…!

Linux CLI 34 🐧 scp and sftp commands

a - scp command

scp (secure copy) is used to copy files between different Linux systems
This happens securely and over SSH
syntax → scp [options] source_file destination_path
example 1 → copies the text.txt from local system to remote with 192.168.1.10 IP address and at /home/user location
example 2 → copies the text.txt from remote system with 192.168.1.10 IP address and at /home/user location to the local system
common options: -r → Recursive copy of a directory tree -v → Verbose mode
-P port → Specify the port number to be used -C → Compression option (uses zlib or bzip2 compression algorithm)
-l limit → Sets a bandwidth limit in bytes/sec for the transfer -q → quiet mode


b - sftp command

sftp (secure file transfer protocol) is used to transfer files between remote systems
This also happens securely and over SSH.
It is similar to FTP but uses encryption and authentication.
syntax → sftp [options] [user@]host[:directory]
example 3 → connects to 192.168.1.10 with user kronos
commands: rmdir dirname → deletes the dirname directory mkdir dirname → creates a directory with name dirname
rm filename → delete a file get filename /home/kronos → downloads a file to local location
put file /remote/location → uploads a file to the remote system man sftp → to see all the options and available commands

Leave a Reply