Difference between revisions of "FTP via cli/terminal"

From Imaginet FAQ
Jump to navigation Jump to search
(Windows command prompt)
 
(19 intermediate revisions by the same user not shown)
Line 1: Line 1:
If you're comfortable working in the Linux terminal, or on Windows, command prompt or PowerShell, you can upload files to our hosting servers via FTP without having to install a separate client application, and without having to use the control panel web interface.
+
If you're comfortable working in the terminal, or Windows command prompt, you can upload files to our hosting servers via FTP without having to install a separate client application, and without having to use the control panel web interface.
  
==Windows command prompt==
+
=Windows command prompt=
This section contains text as it appears in command prompt, and we will highlight that text
+
This section contains text as it appears in command prompt, and commands as they are to be typed.
  
<code> like this </code>
+
==How we will format commands and command prompt text in this section==
 +
Text to be typed, or as it appears in a command prompt window will be shown<code> like this</code>.
  
When we want to show you a command that you have to type and enter, we'll indicate that with the dollar sign "$" and it will be shown like this:
+
When we want to show you a command that you have to type and enter, we'll indicate that like this:
  
<code> > Hello </code>
+
<code>>Hello</code>
  
This means "type the word 'hello' and press '''enter'''".
+
This means ''''type the word 'hello' and press '''enter'''''''.
  
If we want to illustrate some text that you will have to replace, we will put that text [in square brackets like this].
+
If we want to illustrate some text that you will have to replace, we will put that text [in square brackets like this]. For example, to indicate that you should type your user name and press '''enter''':
  
For example, to indicate that you should type your user name and press '''enter''':
+
<code>>[your user name]</code>
  
<code> > [your user name] </code>
+
Open command prompt ('''Windows key + R''' to open the "Run" dialog. Enter '''cmd''' and press '''Enter''').
  
Open command prompt ('''Windows key + R''' to open the "Run" dialog. Enter '''cmd''' and press '''Enter''').
+
==Uploading your files==
  
 
In the command prompt, navigate to the folder where your website files are located. For example, if your files are in a folder called '''My website''' inside '''My Documents''':
 
In the command prompt, navigate to the folder where your website files are located. For example, if your files are in a folder called '''My website''' inside '''My Documents''':
  
<code> > cd "C:\Documents and Settings\[Your Windows User Name]\My Documents\My website" </code>
+
<code>>cd "C:\Documents and Settings\[Your Windows User Name]\My Documents\My website" </code>
  
 
Enter the command '''FTP''' and the command prompt will change to '''ftp>''':
 
Enter the command '''FTP''' and the command prompt will change to '''ftp>''':
 
+
>FTP
<code>
+
ftp>
> FTP
 
 
 
ftp>
 
</code>
 
 
 
 
Enter the command '''open''' followed by your domain name:
 
Enter the command '''open''' followed by your domain name:
  
<code>$ open [domain.co.za]</code>
+
<code>>open [domain.co.za]</code>
  
 
Enter your ftp user name and password when prompted.
 
Enter your ftp user name and password when prompted.
Line 40: Line 36:
 
When you are logged in, navigate to the '''httpdocs''' folder:
 
When you are logged in, navigate to the '''httpdocs''' folder:
  
<code> > cd httpdocs</code>
+
<code>>cd httpdocs</code>
  
 
Upload your files:
 
Upload your files:
  
<code> > mput * </code>
+
<code>>mput *</code>
  
 
Confirm the files that you want to upload from your current folder ('''My webiste''' in the example above) to the httpdocs folder on the server.
 
Confirm the files that you want to upload from your current folder ('''My webiste''' in the example above) to the httpdocs folder on the server.
  
 
Wait for the uploads to finish, and then type and enter the command '''exit''' to log out.  
 
Wait for the uploads to finish, and then type and enter the command '''exit''' to log out.  
 
+
226 Transfer complete
<code> 226 Transfer complete
+
ftp> exit
 
+
221 Goodbye.
ftp> exit
 
 
 
221 Goodbye.</code>
 
 
 
 
You can now close the command prompt window.
 
You can now close the command prompt window.
  
==Linux terminal==
+
=Linux terminal=
 +
This section uses the standard <code>$ shell input</code> notation. FTP commands issued on the remote server are indicated by <code>ftp> command</code>
  
 +
==Uploading your files==
 
Open terminal and navigate to the directory with your website files:
 
Open terminal and navigate to the directory with your website files:
  
<code>$cd [directory] </code>
+
<code>$ cd [directory] </code>
  
 
Log in to the server:
 
Log in to the server:
  
<code>$ftp [your ftp username]@[your domain name]</code>
+
<code>$ ftp [your ftp username]@[your domain name]</code>
  
 
In this mode you will be asked to confirm each file to upload. If you have a lot of files to upload, issue the ftp command with the -i option instead:
 
In this mode you will be asked to confirm each file to upload. If you have a lot of files to upload, issue the ftp command with the -i option instead:
  
<code>$ftp -i [username]@[domain.co.za]</code>
+
<code>$ ftp -i [your ftp username]@[domain.co.za]</code>
  
 
The server returns:
 
The server returns:
 
+
Connected to yourdomain.co.za.
<code>Connected to yourdomain.co.za.
+
220 ProFTPD Server (ProFTPD) [41.78.28.x]
 
+
331 Password required for username-ftp
220 ProFTPD Server (ProFTPD) [41.78.28.x]
+
Password:
 
 
331 Password required for username-ftp
 
 
 
Password: </code>
 
 
 
 
Enter your password to log in. The server returns:
 
Enter your password to log in. The server returns:
 
+
230 User username-ftp logged in
<code>230 User username-ftp logged in
+
Remote system type is UNIX.
 
+
Using binary mode to transfer files.</code>
Remote system type is UNIX.
 
 
 
Using binary mode to transfer files.</code>
 
 
 
 
Change to the httpdocs directory and upload files:
 
Change to the httpdocs directory and upload files:
 
+
ftp> cd httpdocs
<code>ftp>cd httpdocs
+
250 CWD command successful
 
+
ftp> mput *
250 CWD command successful
+
mput file1 [anpqy?]? y
 
+
229 Entering Extended Passive Mode (|||49772|)
ftp> mput *
+
150 Opening BINARY mode data connection for file1
 
+
226 Transfer complete</code>
mput file1 [anpqy?]? y
 
 
 
229 Entering Extended Passive Mode (|||49772|)
 
 
 
150 Opening BINARY mode data connection for file1
 
 
 
226 Transfer complete</code>
 
  
 
When the upload is complete, type '''exit''' and you'll be dropped back into your local directory:
 
When the upload is complete, type '''exit''' and you'll be dropped back into your local directory:
 
+
ftp> exit
<code>ftp> exit
+
221 Goodbye.
 
+
user@machine:~/MyWebsite$</code>
221 Goodbye.
 
 
 
user@machine:~/MyWebsite$</code>
 

Latest revision as of 17:16, 13 February 2023

If you're comfortable working in the terminal, or Windows command prompt, you can upload files to our hosting servers via FTP without having to install a separate client application, and without having to use the control panel web interface.

Windows command prompt

This section contains text as it appears in command prompt, and commands as they are to be typed.

How we will format commands and command prompt text in this section

Text to be typed, or as it appears in a command prompt window will be shown like this.

When we want to show you a command that you have to type and enter, we'll indicate that like this:

>Hello

This means ''type the word 'hello' and press enter''.

If we want to illustrate some text that you will have to replace, we will put that text [in square brackets like this]. For example, to indicate that you should type your user name and press enter:

>[your user name]

Open command prompt (Windows key + R to open the "Run" dialog. Enter cmd and press Enter).

Uploading your files

In the command prompt, navigate to the folder where your website files are located. For example, if your files are in a folder called My website inside My Documents:

>cd "C:\Documents and Settings\[Your Windows User Name]\My Documents\My website"

Enter the command FTP and the command prompt will change to ftp>:

>FTP
ftp>

Enter the command open followed by your domain name:

>open [domain.co.za]

Enter your ftp user name and password when prompted.

When you are logged in, navigate to the httpdocs folder:

>cd httpdocs

Upload your files:

>mput *

Confirm the files that you want to upload from your current folder (My webiste in the example above) to the httpdocs folder on the server.

Wait for the uploads to finish, and then type and enter the command exit to log out.

226 Transfer complete
ftp> exit
221 Goodbye.

You can now close the command prompt window.

Linux terminal

This section uses the standard $ shell input notation. FTP commands issued on the remote server are indicated by ftp> command

Uploading your files

Open terminal and navigate to the directory with your website files:

$ cd [directory]

Log in to the server:

$ ftp [your ftp username]@[your domain name]

In this mode you will be asked to confirm each file to upload. If you have a lot of files to upload, issue the ftp command with the -i option instead:

$ ftp -i [your ftp username]@[domain.co.za]

The server returns:

Connected to yourdomain.co.za.
220 ProFTPD Server (ProFTPD) [41.78.28.x]
331 Password required for username-ftp
Password:

Enter your password to log in. The server returns:

230 User username-ftp logged in
Remote system type is UNIX.
Using binary mode to transfer files.

Change to the httpdocs directory and upload files:

ftp> cd httpdocs
250 CWD command successful
ftp> mput *
mput file1 [anpqy?]? y
229 Entering Extended Passive Mode (|||49772|)
150 Opening BINARY mode data connection for file1
226 Transfer complete

When the upload is complete, type exit and you'll be dropped back into your local directory:

ftp> exit
221 Goodbye.
user@machine:~/MyWebsite$