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.
Prerequisite
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 38.76.11.174
Upon establishing a connection, you will thereafter be prompted for a username and a password
Output
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 commandsls
– This lists all the files and directories in the current remote directorylcd
– This dislays the current directory in the local machineput
– Uploads or copies a file from the local machine to the remote FTP servermput
– Uploads or copies multiple files from the local machine to the remote FTP serverget
– Downloads or copies files from the remote FTP server to the local machinemget
– Downloads or copies mutiple files from the remote FTP server to the local machinemkdir
– Creates a new directory in the current remote directoryrmdir
– Deletes a directory in the current remote directorydelete
– 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
For example
ftp> put hello.sh
Output
To upload multiple files , use the mput
command as shown.
ftp> mput file1 file2 ...
For example
ftp> mput hello.sh output.txt myoutput.txt
You will be prompted for confirmation for each of the files awaiting upload. Press y
.
Output
4. Downloading files using FTP command
To download a file from the FTP server , use the get
command as shown
ftp> get file_name
For example
ftp> get install.sh
Output
For multiple files, use the mget
command as shown
ftp> mget file1 file2 ...
For instance ,
ftp> mget file1.txt file2.txt file3.txt
Output
5. Getting help
To list all the options that are available for use with the ftp command, execute.
help
OR
?
Output
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
- WinSCP
- Core FTP
- Coffecup