Comments on How to use the Linux ftp command to up- and download files on the shell

In this tutorial, I will show you how to use the Linux ftp command on the shell. I will show you how to connect to an FTP server, up- and download files and create directories. While there are many nice desktops FTP clients available, the ftp command is still useful when you work remotely on a server over an SSH session and e.g. want to fetch a backup file from your FTP storage.

17 Comment(s)

Add comment

Please register in our forum first to comment.

Comments

By: dgrb at: 2015-12-01 22:54:02

FTP is not secure, as it transmits usernames and passwords in plaint text. Anyone using a network sniffer can discover them.

No sensible site even enables FTP anymore.

Use SFTP or scp, but plesase DON'T use FTP...

By: till at: 2015-12-02 07:21:49

Seems as if you haven't heard of FTPS yet. FTPS is FTP over SSL/TLS and all current FTP servers support FTPS, so FTP is a secure protocol when your server supports TLS and nobody can sniff any passwords as the connection is fully encrypted. just start the ftp connection with ftps://yourserver.tld instead of ftp://yourserver.tld and you are safe from password sniffing.

By: Sado at: 2015-12-02 14:37:27

You might want to cover the ftp-ssl command as well, it's great for connecting to FTPS sites.

 

ftp-ssl -pivz secure "$FTP_HOST" 990

By: tina at: 2015-12-08 10:16:38

#you can automate this in a script too , just an example below, ofc one need to parameterize HOST USER FILE, to #be functional in a script eg with getopts or something 

read -s -p "password:" passwd

function getfiles {

HOST='someftpserver'

USER='myftpuser'

FILE="somefile" 

ftp -p -v -n $HOST <<END_SCRIPT

quote USER $USER

quote PASS $passwd

type binary

cd /go/to/some/dir

get $FILE

bye

END_SCRIPT

#exit 0

}

getfiles

By: jshock at: 2016-02-12 19:13:38

How do you login if your usrname is an email address? For example "ftp [email protected]@ftp.ftpserver.org" won't work. Once ftp sees the @ it assumes the rest is the server address. Quotes, escape character \ and unicode @ don't work either.

By: Younis Raza at: 2016-04-08 17:32:22

Thank you for the FTP tutorial and I could easily follow it. Now would you be kind to let me know how to download sub directories like images, css, includes and so on...?

By: shey samson at: 2016-05-05 05:02:26

It was great to stumble upon this post.

By: ano at: 2016-10-15 20:49:29

Thank's ! <3

By: Peter Perhac at: 2016-10-29 21:50:17

This was briliant. Succint, to the point, easy to skim, works. Thanks!

By: charles R at: 2017-04-03 04:33:45

How can I to send a file via ftp using specific port automatically.

I tried of differet way but not work.

Ex,

ftp -n <ip> <<END_SCRIPT

quote USER  

quote PASS 

cd /path/dest 

bin

prompt

put /dir/to/orig/file.txt

bye

END_SCRIPT

By: daulet at: 2017-11-17 14:21:11

Sorry what will be command to get files by specific date. for example i want to dowload files which were uploaded in Dec 1 for example

By: Anand at: 2017-12-13 10:32:12

To connect to the FTP server when we have domain name and port as well.We can use following command:

ftp domainName port

eg: ftp abc.int.pn 2121

By: hhgiese at: 2019-02-14 10:33:04

How can I supress the output of the LCD command (because it is not usefull in log-file)?

By: Abhinay at: 2020-01-28 17:01:17

How do you use the follwing command: put /path/fileIs the file name is something dynamic like : $(date -d yesterday +"%Y%m%d")_Admin_DEV.csv

By: Tyrone at: 2020-08-27 13:58:25

After I enter the put command then the file path. I keep receiving "not a plain file" or I get "No containing directory". What am I doing wrong? 

By: new at: 2020-09-24 21:40:23

unable to open a .txt file from ftp...Please tell how to do that...The terminal says tat ia ma alerady connected to the ftp disconnect from there first....

 

By: unnikrishnan at: 2022-12-29 03:02:09

Nice article..short and simple. Thank you