- How to disable Mod security rule for a domain in cPanel server
- How to change main domain of a cPanel reseller account with an existing domain name?
- How to upload and download files using FTP(file transfer protocol) – ftp command line options
- 7+ useful head command’s switches with example – Unix/Linux
- 15+ switches of usermod command with example – Unix/Linux
FTP stands for ‘file trasfer protocol’ which is used to transfer file from one server to another. FTP follows a client-server architecture which utilizes separate control and data connections between the ftp client and server.
Considering the case of Linux servers, there are lot of command line options are available with FTP. We can simply upload and download files to and from remote servers using FTP commands. There are mainly two types of FTP connection to server, Active and Passive. By-default, two ports are associated with FTP transferring method, port 20 and 21. Port 21 is using to establish connection and the port 20 is the default data transfer port.
In this post I am explaining some commonly using FTP command-line options with example. We can connect to remote server by using different ways, please see the below pasted details:
1. How to connect to a server via ftp ?
You can connect to your account by following methods.
# ftp domain.com # ftp IP-Address-of-server # ftp Host-name-of-server
root@server [~]# ftp domain.com Connected to domain.com (111.222.333.111). 220---------- Welcome to Pure-FTPd [privsep] [TLS] ---------- 220-You are user number 2 of 50 allowed. 220-Local time is now 08:41. Server port: 21. 220-This is a private system - No anonymous login 220-IPv6 connections are also welcome on this server. 220 You will be disconnected after 15 minutes of inactivity. Name (domain.com:root): USERNAME Password : PASSWORD 230 OK. Current restricted directory is / Remote system type is UNIX. Using binary mode to transfer files. ftp> ftp>
2. How to list files under current folder?
“ls” command to list all content in the folder.
ftp > ls
ftp> ls 227 Entering Passive Mode (198,15,127,170,49,187) 150 Accepted data connection drwx--x--x 16 crybit crybit 4096 Jan 8 02:03 . drwx--x--x 16 crybit crybit 4096 Jan 8 02:03 .. -rw-r--r-- 1 crybit crybit 18 Jul 18 06:19 .bash_logout -rw-r--r-- 1 crybit crybit 176 Jul 18 06:19 .bash_profile -rw-r--r-- 1 crybit crybit 124 Jul 18 06:19 .bashrc -rw------- 1 crybit crybit 23 Sep 13 21:12 .contactemail drwx------ 5 crybit crybit 4096 Jan 7 04:04 .cpanel -rw------- 1 crybit crybit 14 Dec 28 01:42 .ftpquota drwxr-x--- 2 crybit 99 4096 Aug 29 02:25 .htpasswds -rw------- 1 crybit crybit 15 Aug 29 02:51 .lastlogin .......................................................................
3. Change Directory
ftp> cd dirName
Where dirName is the directory name.
4. How to change the Local directory ?
Local directory means, the present working directory of the server.
ftp> lcd dirName
The ‘lcd’ command alone will display the current local directory of your server.
ftp> lcd Local directory now /root
ftp> lcd /home/ Local directory now /home ftp> lcd Local directory now /home
5. Download/Copy file to local directory.
ftp> get filename
ftp> get .ftpquota local: .ftpquota remote: .ftpquota 227 Entering Passive Mode (198,15,127,170,33,202) 150 Accepted data connection 226-File successfully transferred 226 0.014 seconds (measured here), 0.97 Kbytes per second 14 bytes received in 0.0122 secs (1.15 Kbytes/sec) ftp>
Download/Copy more than one file from server.
ftp> mget file1 file2
6. Turn On / Off Interactive Prompting
The ftp command prompt sets interactive prompting; “on” which enables prompting so that you can verify of each step of the multiple commands, “off” allows the commands to act unimpeded
ftp> prompt on Interactive mode off. ftp> prompt off Interactive mode on.
7. How to delete a file from server?
ftp> delete fileName
8. Upload One File
Upload a file means, copy a file from local machine to server.
ftp> put fileName
Upload Multiple Files
ftp> mput file1 file2
9. How to Create a Directory ?
ftp> mkdir dirName
Where dirName is the directory name.
10. Delete a Directory
ftp> rmdir dirName
11. How to Set The Mode Of File Transfer ?
To set mode as ascii
To set mode as binary
12. How to get more commands details and help?
ftp> ? ftp> help
How to get a short description about each command?
ftp> help commandName
ftp> help mkdir mkdir make directory on the remote machine ftp>
13. How can I disconnected from ftp prompt ?
ftp> quit Or ftp> bye
That’s it. Have fun with ftp .