Applies to: OpenSSH sftp (Linux, macOS, Windows 10 and 11), the ftp client (tnftp) and lftp

put is not a Linux command you run on its own. It is a command inside file transfer programs such as sftp, ftp and lftp: you connect to a server first, then use put to upload a file from your computer to it. Its opposite is get, which downloads.

Use SFTP when you can: it runs over SSH and encrypts everything, including your password. Plain ftp sends the password unencrypted.

Upload with sftp

  1. Connect (add -P PORT if SSH doesn't use port 22):
    sftp user@server.example.com
  2. Go to the target folder on the server, and to the source folder on your computer:
    sftp> cd public_html
    sftp> lcd ~/website
    Commands that start with l work on your own computer: lcd, lls, lpwd.
  3. Upload:
    sftp> put index.html                 # same name on the server
    sftp> put index.html home.html       # upload under another name
    sftp> put *.html                     # several files (wildcards work)
    sftp> put -r css                     # a whole folder with its subfolders
    sftp> reput backup.tar.gz            # resume an interrupted upload
    sftp> exit

Other useful options: put -p keeps the file's modification time and permissions. OpenSSH's sftp has no mput; put with a wildcard does the same job.

Without typing commands each time: put the commands in a file and run it in batch mode. This needs an SSH key, because batch mode can't ask for a password:

printf 'cd public_html\nput -r site/*\n' > upload.txt
sftp -b upload.txt user@server.example.com

Upload with ftp

The classic ftp client (on Ubuntu and Debian the ftp package installs tnftp) uses put for one file and mput for several:

ftp server.example.com
ftp> binary               # transfer files unchanged
ftp> put index.html
ftp> prompt off           # don't ask "mput a.html?" for every file
ftp> mput *.html
ftp> bye

It can't upload folders and doesn't encrypt anything. Many servers now refuse plain FTP logins (our cPanel servers support FTP over TLS), so use lftp or SFTP instead.

Upload with lftp (FTP over TLS)

lftp speaks FTP with TLS encryption and can upload whole folders:

lftp -u username ftp.example.com
lftp> cd public_html
lftp> put index.html
lftp> mput *.html
lftp> mirror -R css css      # upload the local css folder (-R = reverse, local to server)
lftp> bye

Install it with sudo apt install lftp (Ubuntu, Debian) or sudo dnf install lftp (AlmaLinux, Rocky Linux). We tested all the commands on this page with OpenSSH 9.6, tnftp and lftp on Ubuntu 24.04.

On Windows

Windows 10 and 11 include the OpenSSH client, so sftp user@server.example.com and the same put commands work in PowerShell or Command Prompt. For a graphical program, use FileZilla or WinSCP.

Common errors

  • "No such file or directory" on put: the file isn't in your current local folder. Check with lpwd and lls, or give the full path.
  • "Permission denied": you can't write to that folder on the server. Check with pwd where you are, and upload inside your own folders.
  • Connection refused or times out: the SSH port may be different or SSH access may not be enabled for your account.

More on SFTP: how to use SFTP to transfer files and SFTP with cPanel hosting.

Ucartz services for this topic

Was this answer helpful? 0 Users Found This Useful (0 Votes)