Linux / UNIX FTP Commands Tutorial

I switched from MS-Windows to Mac computer running OS X UNIX systems. I need to transfer and download file using ftp for my personal website. Can you provide me a list of FTP commands that may be sent to an FTP server, to upload and download files using UNIX / Linux ftp command line client?

Tutorial details
Difficulty level Easy
Root privileges No
Requirements ftp command
Est. reading time 15m
File Transfer Protocol (FTP) is a network protocol used to copy a file from one computer to another over the Internet or LAN. FTP follows a client-server architecture which utilizes separate control and data connections between the ftp client and server. The default port for ftp is 21.

WARNING! These examples uses outdated insecure ftp protocol / client and if executed you are open to various attacks including password snooping. I strongly recommend that you use sftp, the secure version of FTP. Just type sftp instead of ftp and all of the following commands should work with sftp client too.

ftp: Internet File Transfer Program

Use the following syntax to connect to transfer files to and from a remote network ftp site:


You must know ftp username and password for user-based password authentication or with anonymous user access use ftp as both username and password. In this example, you are connecting to with anonymous user access (open the terminal and type the following command):
$ ftp
Sample session:

Connected to
220 FTP server (Version 6.00LS) ready.
Name ( ftp
331 Guest login ok, send your email address as password.
230 Guest login ok, access restrictions apply.
Remote system type is UNIX.
Using binary mode to transfer files.

When you enter your own loginname and password for the server, it returns the prompt


You need to type all commands in front of the ftp> prompt.

Task: List Current File

Type the ls command at ftp> prompt:
ftp> ls
Sample outputs:

229 Entering Extended Passive Mode (|||60692|)
150 Opening ASCII mode data connection for '/bin/ls'.
total 10
drwxrwxr-x  2 0     5      512 Jul 19  2007 .snap
drwx------  2 0     0     2048 Jul 19  2007 lost+found
drwxr-xr-x  3 1006  1006   512 Sep 21  2009 pub
drwxr-xr-x  3 1006  1006   512 Jun  5  2007 sup
drwxr-xr-x  4 1006  0      512 Sep 18  2009 www
226 Transfer complete.

The above will list the names of the files in the current remote directory (the last name is file or dir name).

Task: Change Directory

To change directory on the remote machine use cd command:
ftp> cd dirName
To change to pub directory, enter:
ftp> cd pub
Sample outputs:

250 CWD command successful.

Task: Download / Copy file

To copy one file at a time from the remote ftp server to the local system use get command:

get fileName
get fileName newFileName

In this example, download file resume.pdf in the current remote directory to (or on top of) a file with the same name, resume.pdf, in your current local directory:
ftp> get resume.pdf
Sample outputs:

local: resume.pdf remote: resume.pdf
229 Entering Extended Passive Mode (|||55093|)
150 Opening BINARY mode data connection for 'resume.pdf' (53077 bytes).
100% |*********************************************************************| 53077       12.58 KiB/s    00:00 ETA
226 Transfer complete.
53077 bytes received in 00:04 (12.57 KiB/s)

In this example, copies file data.tar.gz in the current remote directory to (or on top of) a file named backup.tar.gz in your current local directory:
ftp> get data.tar.gz backup.tar.gz

Change Local Directory

To change directory on your local system, enter:
ftp> lcd /path/to/new/dir
ftp> lcd /tmp

Sample outputs:

Local directory now: /tmp

Print local directory:
ftp> lpwd
Sample outputs:


The lpwd command prints current download directory for local systems. However, to find out the pathname of the current directory on the remote ftp server, enter:
ftp> pwd
Sample outputs:

Remote directory: /pub/FreeBSD

Task: Download Multiple Files

You need to use mget command as follows to copy multiple files from the remote ftp server to the local system. You may be prompted for a yes/no (Y/N) answer before transferring each file (you can disable prompt by passing the -i option to ftp client). To download all files, enter:
ftp> mget *
To download all perl files (ending with .pl extension), enter:
ftp> mget *.pl

Task: Turn On / Off Interactive Prompting

The ftp command prompt sets interactive prompting; “on” which enables prompting so that you can verify of each step of the multiple commands, “off” allows the commands to act unimpeded:
ftp> prompt on
ftp> mput *.php
ftp> prompt off
ftp> mget *.py

Task: Delete File

To delete a file in the current remote directory use delete command:
ftp> delete fileName
ftp> delete output.jpg

Task: Upload One File

To copy one file at a time from the local systems to the remote ftp server, enter:
ftp> put fileName
In this example, upload logo.jpg, enter:
ftp> put logo.jpg

Task: Upload Multiple Files

To copy multiple files from the local system to the remote ftp server use mput command. Again, you may be prompted for a yes/no (y/n) answer before transferring each file. In this example, upload all files from the current system:
ftp> mput *
ftp> mput *.pl

Task: Create a Directory

To make a new directory, enter:
ftp> mkdir dirName
ftp> mkdir scripts
ftp> cd scripts
ftp> pwd

Task: Delete a Directory

To remove or delete a directory, enter:
ftp> rmdir dirName
ftp> rmdir images
ftp> ls

Task: Set The Mode Of File Transfer

To set the mode of file transfer to ASCII, enter:
ftp> ascii
Please note that ascii is the default and good for text files. To set the mode of file transfer to binary, enter:
ftp> binary
The binary mode is recommended for almost all sort of files including images, zip files and much more. The binary mode provides less chance of a transmission error.

Task: Connect To Another FTP Server

To open a connection with another ftp server, enter:
ftp> open
The above command opens a new FTP connection with You must provide a username and password for a account. However, a username and password can be skipped for an anonymous FTP connection.

Task: Exit the FTP Session

Type quit or bye, enter:
ftp> quit
ftp> bye
Sample outputs:

221 Goodbye.

How Do I Find Out More Information About The FTP Commands?

Type ? or help to get more information about the FTP commands:
ftp> ?
ftp> help

Sample outputs:

Commands may be abbreviated.  Commands are:

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

To get a short description about each command, enter:
ftp> help commandName
ftp> help chmod

Sample outputs:

chmod      	change file permissions of remote file

ftp> help ls
Sample outputs:

ls         	list contents of remote path

FTP Through A Browser

If you do not want to type the commands, than use a browser such as Safari, Firefox and type the following:

Sample outputs:

UNIX / Linux FireFOX - FTP through a browser

Fig.01: FTP through a browser

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 13 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf ncdu pydf
File Managementcat tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
13 comments… add one
  • prerna verma Oct 9, 2011 @ 6:32

    what to do when you forget the username & password that is necessary to enter and work in linux? please tell I stuck in a problem like this.

    • Travis Dec 23, 2013 @ 18:39

      Use /init/bash=1in the last line of the kernel statement in the grub.conf file to reset the password.

  • Rafer Jun 13, 2012 @ 0:51

    The prompt feature of the mput command can be disabled by invoking ftp with the -i option. In this instance, all file names that match the pattern in your mput command will be transferred
    without confirmation.

  • Carlos Rodrigues Sep 26, 2012 @ 8:41

    Thanks for the information!
    Very helpfull.

  • Srikanth Samineni Mar 19, 2014 @ 8:12


    I have a strange issue. Any one can help me out

    Source server is AIX and destination server is Solaris and communication is through ftp. We have a script with the following syntax:


    ftp -n -i -v $HOST < user ops@zeusftp @#
    331 Password required for ops@zeusftp.
    530 Login incorrect.
    Login failed.

    If i modify the script as follows it is working fine

    ftp> user zeusftp
    331 Password required for zeusftp.
    230 User zeusftp logged in.

    I want to know how the syntax ops@zeusftp works. Anyone can help me out pls..

    • Srikanth Samineni Mar 19, 2014 @ 8:13


      • Srikanth Samineni Mar 19, 2014 @ 8:15

        ftp -n -i -v $HOST

        • Srikanth Samineni Mar 19, 2014 @ 9:24

          sorrry typo error while posting the script

          ftp -n -i -v $HOST

  • Deovrat Jalgaonkar Nov 3, 2014 @ 7:27

    Thanks You Very Much For Writing Such A Great Tutorial.

  • Immortal Jun 16, 2015 @ 7:50

    How to stop the ftp ( vsftpd) server from prompting for username/password while opening from the browser? For instance when I open, I am being prompt for username/password. I just want users to freely download the software from the internet.


  • alexpimania Aug 5, 2015 @ 21:54

    This is so awesome!
    I never new that it was that easy to connect to a FTP server and copy files with the same commands as the terminal.

    So how would you implement this method in a shell script?

    Thanks in advance.


  • tausif(joseph) Nov 22, 2015 @ 8:39

    can someone help me to know how to login to ftp server without the password
    thanks and regrads.

  • hariskar Mar 10, 2017 @ 8:37

    The edit command is not supported in my ftp (I wonder why). Any advice on how I can edit a remote text file easily? Maybe a script?

    Thank you!

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum