10 sFTP Command Examples to Transfer Files on Remote Linux
Jul 09, 2025 am 09:20 AMFile Transfer Protocol (FTP) was a widely used protocol to transfer files or data remotely in an unencrypted format which is not a secure way to communicate.
As we all know that File Transfer Protocol is not at all secure because all transmissions happen in clear text and the data can be readable by anyone during sniffing the packets on the network.
So, basically, FTP can be used in limited cases or on the networks that you trust. Over the period of time, SCP (Secure Copy) and SSH (Secure Shell) addresses this security ambiguity and added an encrypted secure layer while transferring data between remote computers.
[ You might also like: Best Command-Line FTP Clients for Linux ]
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 the SSH port (Secure SHell) globally as this would be a security breach. You can only open for specific IP from where you are going to transfer or manage files on the remote system or vice versa.
- How to Secure and Harden OpenSSH Server
- How to Change SSH Port in Linux
- How to Sync Files Using Rsync with Non-standard SSH Port
- 5 Best Practices to Secure and Protect SSH Server
- 10 Wget Command Examples in Linux
This article will guide you to 10 sftp command examples to use through the interactive command-line interface in the Linux terminal.
1. How to Connect to SFTP
By default, the same SSH protocol is used to authenticate and establish an SFTP connection. To start an SFTP session, enter the username and remote hostname or IP address at the command prompt. Once authentication is successful, you will see a shell with an sftp> prompt.
[root@tecmint ~]# sftp [email?protected] Connecting to 27.48.137.6... [email?protected]'s password: <strong>sftp></strong>
2. Getting Help
Once, you are in the sftp prompt, check the available commands by typing ‘?‘ or ‘help‘ at the 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 the pwd command is used to check the Remote working directory.
sftp> lpwd Local working directory: / sftp> pwd Remote working directory: /tecmint/
- lpwd – print the current directory on your system
- pwd – print the current directory on the ftp server
4. Listing Files with sFTP
Listing files and directories in local as well as a remote system ftp server.
On Remote
sftp> ls
On Local
sftp> lls
5. Upload File Using sFTP
Put single or multiple files in remote system ftp server.
sftp> put local.profile Uploading local.profile to /tecmint/local.profile
6. Upload Multiple Files Using sFTP
Putting multiple files on in remote system ftp server.
sftp> mput *.xls
6. Download Files Using sFTP
Getting single or multiple files in a 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 the same name. We can download remote files with a different name by specifying the name at the end. (This applies only while downloading the single file).
7. Switching Directories in sFTP
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 Using sFTP
Creating new directories on local and remote locations.
sftp> mkdir test
sftp> lmkdir Documents
9. Remove Directories Using sFTP
Remove directory or file in a remote system.
sftp> rm Report.xls
sftp> rmdir sub1
Note: To remove/delete any directory from a remote location, the directory must be empty.
10. Exit sFTP Shell
The ‘!‘ command drops us in a local shell from where we can execute Linux commands. Type ‘exit‘ command where we can see sftp> prompt return.
sftp> ! [root@sftp ~]# 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 to some extent.
The above is the detailed content of 10 sFTP Command Examples to Transfer Files on Remote Linux. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

While writing program files or normal text files, programmers and writers sometimes want to know the difference between two files or two versions of the same file. When you compare two computer files on Linux, the difference between their contents is

There are three ways to create empty files in the command line: First, the simplest and safest use of the touch command, which is suitable for debugging scripts or placeholder files; Second, it is quickly created through > redirection but will clear existing content, which is suitable for initializing log files; Third, use echo"> file name to create a file with an empty string, or use echo-n""> file name to avoid line breaks. These three methods have their own applicable scenarios, and choosing the right method can help you complete the task more efficiently.

Linux's cost of ownership is usually lower than Windows. 1) Linux does not require license fees, saving a lot of costs, while Windows requires purchasing a license. 2) Linux has low hardware requirements and can extend the service life of the device. 3) The Linux community provides free support to reduce maintenance costs. 4) Linux is highly secure and reduces productivity losses. 5) The Linux learning curve is steep, but Windows is easier to use. The choice should be based on specific needs and budget.

Are you looking for good software to write mathematical equations? If so, this article provides the top 5 equation editors that you can easily install on your favorite Linux distribution.In addition to being compatible with different types of mathema

dutree is a free, open-source, fast command-line tool for analyzing disk usage, written in the Rust programming language. It was created by combining durep (disk usage reporter) and tree (list directory content in tree-like format) command-line tools

ifconfig in short “interface configuration” utility for system/network administration in Unix/Linux operating systems to configure, manage, and query network interface parameters via command-line interface or in a system configuration scripts

Eclipse is a free integrated development environment (IDE) that programmers around the world use to write software, primarily in Java, but also in other major programming languages using Eclipse plugins.The latest release of Eclipse IDE 2023?06 does

Linux administrators should be familiar with the command-line environment. Since GUI (Graphical User Interface) mode in Linux servers is not commonly installed.SSH may be the most popular protocol to enable Linux administrators to manage the servers
