FTP (File Transfer Protocol), is a protocol commonly used for the transfer of files between a client and a server. In this guide, you will learn how to use Linux FTP commands with practical examples. Without much further ado, let’s jump right in.
VSFTPD (Very Secure File Transfer Protocol Daemon) installed and properly configured. It’s also crucial to point out that you must have read permissions from the source file and write permissions on the FTP server. This enables you to transfer files to and fro in a secure/encrypted manner.
1. Establishing an FTP connection
To establish an FTP connection with a remote server, use the syntax below on the terminal
# ftp ip-address
For example ,
# ftp 126.96.36.199
Upon establishing a connection, you will thereafter be prompted for a username and a password
If the username and password details were correct, you will get a ‘login successful’ notification on the terminal alongside the FTP system type.
2. Commonly used FTP commands
Once in the ftp prompt, let’s examine some of the commonly used command options.
? or help– This displays all available FTP commands
ls– This lists all the files and directories in the current remote directory
lcd– This dislays the current directory in the local machine
put– Uploads or copies a file from the local machine to the remote FTP server
mput– Uploads or copies multiple files from the local machine to the remote FTP server
get– Downloads or copies files from the remote FTP server to the local machine
mget– Downloads or copies mutiple files from the remote FTP server to the local machine
mkdir– Creates a new directory in the current remote directory
rmdir– Deletes a directory in the current remote directory
delete– Delete a directory in the current remote directory
3. Uploading files using FTP command
To upload or copy a file to an FTP server, first ensure that you are connecting to the FTP server from the directory containing the files you want to upload.
Once logged in, use the syntax
ftp> put file_name
ftp> put hello.sh
To upload multiple files , use the
mput command as shown.
ftp> mput file1 file2 ...
ftp> mput hello.sh output.txt myoutput.txt
You will be prompted for confirmation for each of the files awaiting upload. Press
4. Downloading files using FTP command
To download a file from the FTP server , use the
get command as shown
ftp> get file_name
ftp> get install.sh
For multiple files, use the
mget command as shown
ftp> mget file1 file2 ...
For instance ,
ftp> mget file1.txt file2.txt file3.txt
5. Getting help
To list all the options that are available for use with the ftp command, execute.
6. A note about GUI FTP clients
One of the drawbacks of transferring files via the terminal is time wasted uploading or downloading files one by one. FileZilla is a free and opensource FTP client that allows you to upload or download files and directories over TLS and SFTP. If you have a bulk of files or directories that need to be uploaded or downloaded, then using a GUI based FTP client is highly recommended. Other free GUI FTP clients include
- Core FTP