FTP (File Transfer Protocol) is a standard network protocol for file transferring between server and client computer. FTP is built on client-server architecture, usually use port 21 for standard port or port 22 for secure ftp. FTP server is installed on server machine and FTP client use on the client machine. There are many FTP client tools commercial or even free and open source. The FTP client tools help you transfer files easily even with drag and drop. The famous one is Filezilla that work on all platform.
But on the server, or a machine that you remote from SSH (Secure Shell) or CLI (Command Line Interface) there is no such tools like Filezilla. There is no GUI (Graphic User Interface) FTP client tools. I once, stuck because i always use Filezilla. And then i learn to use FTP from command line, and in fact it is very easy. So i write this article to remind me and sharing with you too.
How to use FTP from command line:
To connect to the host:
ftp [-pinegvd ] [host ]
-p : Use passive mode for data transfers.
-i : Turns off interactive prompting during multiple file transfers.
-n : Restrains ftp from attempting auto-login upon initial connection.
-e : Disables command editing and history support, if it was compiled into the ftp executable.
-g : Disables file name globbing.
-v : Switch verbose on
-d : Enables debugging.
I usually use:
ftp -vn [host]
To input username and password:
To list the directory:
To change directory:
ftp> cd [remote directory path]
To download file:
ftp> get remote-file [local-file ] #For single file ftp> mget remote-files #For multiple files
To upload file:
ftp> put local-file [remote-file ] #For single file ftp> mput local-files #For multiple files
For delete remote file:
ftp> delete remote-file #For single file ftp> mdelete remote-files #For multiple files
That’s the basic command the frequently use by me. For more info you can get the help with this command:
ftp -h #or man ftp
Thanks for reading this article, any suggestion is welcome.