Why would you want to use FTP from the Linux terminal? It’s quick, easy, consistent, and works well enough as an FTP client. If it’s not already installed, it’s just a quick installation command away. In my experience, it’s usually already there.
If I’m going to be transferring a bunch of files or editing files, I’ll just use a GUI FTP client. My choice FTP client has been Filezilla for quite a long time now. It does the trick and I just keep moving my profile/config to new computers as I get them. Being easy to migrate is a definite selling point for me.
So, what is FTP? It stands for File Transfer Protocol. It’s not encrypted, so many folks have moved to SFTP – which is actually not related to FTP at all. It just shares similar functionality. Even though FTP traffic isn’t secure, it’s still fairly widely used.
An FTP server is probably not installed by default on your desktop Linux system. However, I’ve written how to Install An FTP Server With VSFTPD which should get you sorted if you need one.
The application will be using is “FTP” which describes itself like:
ftp — Internet file transfer program
And you may find that your version of terminal-based FTP is maintained by your distro maintainers. The FTP command and flagsr should still be pretty universal throughout. Still, be sure to check the man page – especially if things seem weird.
FTP From The Linux Terminal:
Obviously, this requires an open terminal.
Press
Once you have the terminal open the command is basically this:
1 | ftp <server> |
You can connect via domain name, hostname, or even IP address. It’ll look like this, or pretty close:
There are many commands available, so you should probably check man ftp
to see what’s on offer. We’re just going to cover a few of the more useful commands.
You’ll find that ‘ls’ works to list files, just like you’re used to, as does ‘cd’. If you want to change your local directory, that is your working directory on your machine and not the working directory on the server, you need to use the ‘lcd’ command – like so:
1 | lcd ~/Downloads |
Note: Read More About Paths
After you’ve logged in and learned to navigate, it’s time to do something. If you want to download something, you use the ‘get’ command:
1 | get <file_name> |
That will download the file from the server to the local directory. To do the opposite, that is upload something from your current local directory, you would use the ‘put’ command, like so:
1 | put <file_name> |
If you want to get or put more than one file, the commands are ‘mget’ and ‘mput’ respectively. They look like this:
1 2 | mget <file_name1> <file_name2> <file_name3> mput <file_name1> <file_name2> <file_name3> |
Note: It may give a warning about using passive mode. If that’s the case, add the -p flag to your connection command – like ftp -p hostname
.
Just like with your regular terminal file management, you can ‘mkdir’, ‘rmdir’, and even use ‘pwd’ to be reminded of your present working directory. Files can also be deleted with the delete <file_name>
command.
Closure:
And there you have it, an article that explains how to use FTP from the Linux terminal. It is important to note that the FTP command transmits data without encryption. If security is a concern, use SCP or SFTP.
Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your own site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.