In my previous article i have explained about the Ping command of unix/linux with different examples. In this article i will try to explain the FTP Command in unix in detail with real examples in day to day life.FTP stands for File transfer protocol which is used to transfer the file from one server to another server location.FTP command is so useful as it allows you to store and retrieve files from any computer in the world.There are 2 types of FTP :
1.FTP : which is a simple File Transfer Protocol
2.SFTP:which is Secured File Transfer Protocol
FTP is most preferred protocol for data transfer among the computers.
1.Log in and establishing connection with the remote host computer.
2.Upload the Files
3.Download the Files.
4.Navigating through the different directorties
5.Browsing contents through directories.
I will explain the different usages of FTP Command with real world examples.The FTP commands are applicable to SFTP also so wherever FTP is mentioned user can use that same commands for SFTP also.
The basic question is how to connect to FTP server.You can open the connection with the remote host with using the IP of target PC or hostname of the PC. To check the hostname of the PC following command is used :
Example :
$hostname
Output :
PC102323
User can use 2 different commands to connect through FTP server.
Syntax :
Command 1 :
$FTP IP/Hostname
Example:
$FTP 10.20.208.110
User can directly connect through the FTP command using the Hostname or IP address.
Command 2 :
$FTP
ftp>Open IP/Hostname
User can connect to FTP server and then use open command to connect with the FTP server.The server will ask the username and password while connecting to the server.
After connecting to FTP server the question is how to download the file in FTP.When user connect to the FTP server the set of commands need to use for different operations.To download the file from FTP server the GET command is used.
There are 2 modes available to download the file. One is Binary mode (for non-text files) and ascii mode (for text files).
Example :
To download the file and save it with another name.The File named complexsql.html is saved as complexsql1.html.
Change mode to ASCII:
ftp>ascii
ftp> get compexsql.html complexsql1.html Fetching /home/complexsql.html to complexsql1.html /home/complexsql.html
When user needs to download the non text files then there is need change the mode from ASCII mode to binary mode..
ftp> binary 200 Type set to I.
User needs to use the PUT command to upload the file to FTP server.
Example:
ftp> put filename ftp> put complexsql.html
You can view all the files and directories of FTP server using ls command.
Example:
ftp>ls
It will list all files on ftp server.
If you want to check the different FTP commands just connect to FTP server and use help command or ? command to check different FTP commands.
Syntax :
ftp > Help Command Name
Example:
ftp> Help Put
The above command will show the Put command help.
Just like a simple unix command of changing directory.User can change the directory using cd command.There are 2 directories one is remote directory and other directory is local directory.
ftp> pwd
“/home” is current directory.
ftp> cd directory1
CWD command successful.
“/home/directory1” is current directory.
ftp> pwd 257
“/home/directory1” is current directory.
User can use lcd command to change local directory.
Note :
ftp> !
$ pwd /home/Amiet/
FTP $ exit exit
ftp> lcd /tmp Local directory now /tmp
ftp> !
$ pwd
/tmp
User can download the multiple files using the mget command.User can use the globs to download multiple files.
Example :
If user want to download all jpg files from ftp server then use mget with * .
ftp> mget *.jpg
The above command will download all the jpg files from remote server. After downloading the files if user wants to show the files which are downloaded then use mls command as follows :
ftp> mls.jpg
User can upload the multiple files using mput command of FTP.The mput command works similar to mget command.
Example :
Following command will upload all the jpg files from local server to remote server.
ftp> mput *.jpg
After opening the FTP connection user needs to close it to connect with another connection.User needs to use the close command to close FTP connection.
ftp> open ftp.complexsql.com
Already connected to complexsql.com, use close first.
ftp> close
221 Goodbye.
ftp> open ftp.anonymous.com
These are some important examples of FTP command which are very useful in our day to day life.Kindly comment in comment section if you have any suggestions.
In my previous articles I have given the roles and responsibilities of L1,L2 and L3…
In my previous articles i have given the hierarchy of production support in real company…
In this article i would like to provide information about production support organization structure or…
In my previous article I have given roles for L1 and L2 support engineer with…
I have started this new series of how to become application support engineer. This article…
In this series we are starting with Roles and responsibilities of L1 support engineer .…