FTP (File Transfer Protocol) needs no presentations: it is among the most used file transfer methods between one or more clients and a server. By design it supports both anonymous access and authentication, but in its most basic form it doesn’t provide data encryption, that’s why it is often secured via TLS.
A lot of FTP client applications are available on Linux, as for example Filezilla (graphical) or lftp (command line). Sometimes, however, we may want to access an FTP server programmatically, perhaps to schedule file transfers. One easy way to do this is by using a programming language like Python. In this tutorial we will learn how to use the ftplib library to interact with an FTP server.
In this tutorial you will learn:
- How to create an instance of the ftplib.FTP class
- How to list files on a remote FTP server
- How to upload files in binary and “lines” mode
- How to download files in binary and “lines” mode
- How to create,delete and rename directories and files
- How to change working directory