• Contact
  • Contact Us
  • Disclamer
  • Home 1
  • Home 2
  • Home 3
  • Privacy Policy
Wednesday, June 11, 2025
How VPS - How to use/setup VPS
  • Login
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
How VPS - How to use/setup VPS
No Result
View All Result
Home Operating System Linux

10 sFTP Command Examples to Transfer Files on Remote Servers in Linux

How VPS by How VPS
November 2, 2018
in Linux, Operating System
0
0
SHARES
14
VIEWS
Share on FacebookShare on Twitter

Contents

  1. 1. How to Connect to SFTP
  2. 2. Getting Help
  3. 3. Check Present Working Directory
  4. 4. Listing Files
    1. On Remote
    2. On Local
  5. 5. Upload File
  6. 6. Upload Mutiple Files
  7. 6. Download Files
  8. 7. Switching Directories
    1. On Remote
    2. On Local
  9. 8. Create Directories
  10. 9. Remove Directories
  11. 10. Exit sFTP Shell
  12. Conclusion

File Transfer Protocol (FTP) was widely used protocol to transfer files or data remotely in unencrypted format which is not secure way to communicate. As we all know that File Transfer Protocol is not at all secure because all transmissions happens in clear text and the data can be readable by anyone during sniffing the packets on the network.

10 sFTP Command Examples to Transfer Files on Remote Servers in Linux

10 sftp command examples

So, basically FTP can be used in limited cases or on the networks that you trust. Over the period of time SCP and SSH addresses this security ambiguity and added an encrypted secure layer while transferring data between remote computers.

SFTP (Secure File Transfer Protocol) runs over SSH protocol on standard port 22 by default to establish a secure connection. SFTP has been integrated into many GUI tools (FileZilla, WinSCP, FireFTP etc.).

Security Warnings: Please don’t open SSH port (Secure SHell) globally as this would be a security breaches. You can only open for specific IP from where you are going to transfer or manage files on remote system or vice versa.

  1. 5 Best Practices to Secure and Protect SSH Server
  2. 10 Wget Command Examples in Linux

This article will guide you 10 sftp command examples to use it through interactive command-line interface.

1. How to Connect to SFTP

By default, same SSH protocol is used to authenticate and establish a SFTP connection. To start an SFTP session, enter the username and remote hostname or IP address at the command prompt. Once authentication successful, you will see a shell with an sftp> prompt.

[[email protected] ~]# sftp [email protected]

Connecting to 27.48.137.6...
[email protected]'s password:
sftp>

2. Getting Help

Once, you in the sftp prompt, check the available commands by typing ‘?‘ or ‘help‘ at command prompt.

sftp> ?
Available commands:
cd path                       Change remote directory to 'path'
lcd path                      Change local directory to 'path'
chgrp grp path                Change group of file 'path' to 'grp'
chmod mode path               Change permissions of file 'path' to 'mode'
chown own path                Change owner of file 'path' to 'own'
help                          Display this help text
get remote-path [local-path]  Download file
lls [ls-options [path]]       Display local directory listing
ln oldpath newpath            Symlink remote file
lmkdir path                   Create local directory
lpwd                          Print local working directory
ls [path]                     Display remote directory listing
lumask umask                  Set local umask to 'umask'
mkdir path                    Create remote directory
put local-path [remote-path]  Upload file
pwd                           Display remote working directory
exit                          Quit sftp
quit                          Quit sftp
rename oldpath newpath        Rename remote file
rmdir path                    Remove remote directory
rm path                       Delete remote file
symlink oldpath newpath       Symlink remote file
version                       Show SFTP version
!command                      Execute 'command' in local shell
!                             Escape to local shell
?                             Synonym for help

3. Check Present Working Directory

The command ‘lpwd‘ is used to check the Local present working directory, whereas ‘pwd‘ command is used to check Remote working directory.

sftp> lpwd
Local working directory: /
sftp> pwd
Remote working directory: /tecmint/
  1. lpwd – print the current directory on your system
  2. pwd – print the current directory on the ftp server

4. Listing Files

Listing files and directories in local as well as remote system.

On Remote
sftp> ls
On Local
sftp> lls

5. Upload File

Put single or multiple files in remote system.

sftp> put local.profile
Uploading local.profile to /tecmint/local.profile

6. Upload Mutiple Files

Putting multiple files on in remote system.

sftp> mput *.xls

6. Download Files

Getting single or multiple files in local system.

sftp> get SettlementReport_1-10th.xls
Fetching /tecmint/SettlementReport_1-10th.xls to SettlementReport_1-10th.xls

Get multiple files on a local system.

sftp> mget *.xls

Note: As we can see by default with get command download file in local system with same name. We can download remote file with different name specifying the name at the end. (This applies only while downloading single file).

7. Switching Directories

Switching from one directory to another directory in local and remote locations.

On Remote
sftp> cd test
sftp>
On Local
sftp> lcd Documents

8. Create Directories

Creating new directories on local and remote locations.

sftp> mkdir test
sftp> lmkdir Documents

9. Remove Directories

Remove directory or file in remote system.

sftp> rm Report.xls
sftp> rmdir sub1

Note: To remove/delete any directory from remote location, the directory must be empty.

10. Exit sFTP Shell

The ‘!‘ command drop us in local shell from where we can execute Linux commands. Type ‘exit‘ command where we can see sftp> prompt return.

sftp> !

[[email protected] ~]# exit
Shell exited with status 1
sftp>

Conclusion

The SFTP is a very useful tool for administrating servers and transferring files to and from (Local and Remote). We hope this tuts will help you to understand the usage of SFTP in some extent.

Source: tecmint.com

Tags: Linux Commandslinux guidelinux vps setup guide
Previous Post

How to Set Time, Timezone and Synchronize System Clock Using timedatectl Command

Next Post

Linux zcat Command Examples for Newbies

Next Post

Linux zcat Command Examples for Newbies

Leave a Reply Cancel reply

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

No Result
View All Result

Recent Post

Install Imagemagick on CentOS
CentOS

Install Imagemagick on CentOS

by How VPS
June 28, 2023
0

This is how I installed Imagemagick on a vanilla CentOS server Start off by installing the prerequisites yum install php-pear...

Read more
how to Check phpinfo

How to Check phpinfo of Hosting or VPS?

June 28, 2023
Failed to download metadata for repo 'appstream' on Centos 8

How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

February 25, 2022
How to Fix MySQL Error "Plugin 'InnoDB' registration as a STORAGE ENGINE failed"?

How to Fix MySQL Error “Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed”?

November 17, 2020
How to optimize Mysql or MariaDB

How to optimize Mysql or MariaDB

November 3, 2020

Recent News

  • Install Imagemagick on CentOS
  • How to Check phpinfo of Hosting or VPS?
  • How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

Category

  • Arch
  • Authentication
  • Backups
  • BSD
  • Centmin Mod
  • CentOS
  • Control Panels
  • CoreOS
  • CWP
  • Debian
  • Directadmin
  • Encryption
  • Fedora
  • Firewalls
  • Hocvps Script
  • Hosting providers
  • Kloxo-MR
  • Linux
  • Mitigations
  • Operating System
  • Plesk
  • Reviews
  • Securing VPS/Servers
  • Security Patches
  • SSL Certificates
  • Uncategorized
  • Upgrading
  • VPS/Servers management guides
  • Vulnerability Detection
  • Web servers software
  • Webhosting Control Panel
  • About
  • Advertise
  • Careers
  • Contact

© 2025 JNews - Premium WordPress news & magazine theme by Jegtheme.

No Result
View All Result
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon

© 2025 JNews - Premium WordPress news & magazine theme by Jegtheme.

Welcome Back!

Login to your account below

Forgotten Password?

Retrieve your password

Please enter your username or email address to reset your password.

Log In