Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Using the FTP CLI Utility

From John's Wiki

To use the FTP command line utility run the command below.

ftp example.com
Connected to example.com.
220 ProFTPD Server (example.com FTP server)
Name (example.com): YOUR_USERNAME               
331 Password required for YOUR_USERNAME
Password:
230 User YOUR_USERNAME logged in
Remote system type is UNIX.
Using binary mode to transfer files.
  • Then enable passive mode:
ftp> passive
Passive mode on.
  • You can list files with ls or dir:
ftp> ls
227 Entering Passive Mode.
150 Opening BINARY mode data connection for file list
app.js	bin 	public_ftp   
backup	public_html  www_logs
226 Transfer complete
  • Pull a file down from the server with the get command:
ftp> get app.js
local: app.js remote: app.js
227 Entering Passive Mode (66,39,65,154,129,77).
150 Opening BINARY mode data connection for app.js (338 bytes)
226 Transfer complete
338 bytes received in 0.00 secs (1.2446 MB/s)
  • Then disconnect and you can see you have the file on your client machine:
ftp> exit
221 Goodbye.

blue@Home:$~> cat app.js
const http = require('http');

const hostname = '127.0.0.1';
const port = 3000;
...
  • You run commands on your local machine through the ftp shell by prefixing a ! char:
ftp> !cat blah.txt
blah blah blah
  • To upload a file to a server use the put command:
ftp> put blah.txt
local: blah.txt remote: blah.txt
227 Entering Passive Mode (66,39,65,154,129,91).
150 Opening BINARY mode data connection for blah.txt
226 Transfer complete
5 bytes sent in 0.00 secs (256.9901 kB/s)
  • And then if we check on the remote machine via ftp we can see:
john@server:$~> cat blah.txt
fart
  • To see a help menu for ftp run help:
ftp> help
Commands may be abbreviated.  Commands are:

!           edit        lpage       nlist       rcvbuf      struct
$           epsv        lpwd        nmap        recv        sunique
account     epsv4       ls          ntrans      reget       system
append      epsv6       macdef      open        remopts     tenex
ascii       exit        mdelete     page        rename      throttle
bell        features    mdir        passive     reset       trace
binary      fget        mget        pdir        restart     type
bye         form        mkdir       pls         rhelp       umask
case        ftp         mls         pmlsd       rmdir       unset
cd          gate        mlsd        preserve    rstatus     usage
cdup        get         mlst        progress    runique     user
chmod       glob        mode        prompt      send        verbose
close       hash        modtime     proxy       sendport    xferbuf
cr          help        more        put         set         ?   
debug       idle        mput        pwd         site
delete      image       mreget      quit        size
dir         lcd         msend       quote       sndbuf
disconnect  less        newer       rate        status
  • Help for specific command:
ftp> help lcd
lcd         change local working directory