Ftp is very popular file transfer protocol over computer networks and internet. Ftp provides simple but efficient commands and features to download and upload files over network. In this tutorial we will look most used FTP commands.
If you need to install FTP server look following tutorial.
Install Ftp Client For CentOS, Fedora, RHEL
Ftp command is not installed by default most of the distributions. We can install ftp command with the following command.
$ yum install ftp -y
Install Ftp Client For Ubuntu, Debian
We can install ftp command for the Ubuntu and Debian like below.
$ apt install ftp
Connection FTP Server
First step to connect an ftp server is providing the ip address or domain name of the server to the ftp command. In this example we will connect IP address . The user name and password will be asked. We can use anonymous account which user name and password is
$ ftp 192.168.122.156
If the authentication is successful we will get
230 Login Successful response from ftp server.
Show Connection Status
After connecting an ftp server we may need to check the connection status and detailed information about the connection. We can use
Remote ftp servers will provide a lot of files and folders. We can list these files and folders with
dir command like below.
List Current Working Directory
We can list current working directory on the remote ftp server with
Change Remote Current Working Directory
We generally need to change current working directory. We will use
cd command in order to change current working directory on ftp server. In this example we will change to the directory named
Change Local Current Working Directory
We also have a local current working directory too. This will be used to store downloaded files and looking for upload files. We will use
lcd . In this example we change local current working directory to the
Download or Get File From FTP Server
Now we can start the show. The most popular command for ftp is
get is used to download files from remote ftp server to the local system. File will be download tot the current local working directory. In this example we will download the
Download or Get Multiple Files From FTP Server
mget command in order to download multiple files from ftp server.
mget backup.tar.gz oldbackup.tar.gz
Also we can use glob
*.* to download all files in the current working directory.
Put Or Send File To The Ftp Server
We will use
put command in order to send or upload local files. In this example we will upload file named
backup.tar.gz . The file must be located in the current local working directory if not change local current working directory accordingly.
Create Directory On Ftp Server
We can create a directory on the remote ftp server without uploading anything. We will use
mkdir command for this. In this example we will create a directory named
Delete File In The Ftp Server
We can use
delete command in order to remove or delete files on the remote ftp server. In this example we will delete the file named
Delete Folder or Directory From Ftp Server
We can remove empty directories from ftp server with the
rmdir command. In this example we will remote directory named
Disconnect or Exit From Ftp Server
We can exit from ftp server interactive shell with the command