Copyright 1999 T. O' Donnell. T. O' Donnell Inc. http://www.tigertom.com THIS PAGE is in text format, as html would cause important parts of the code to 'wrap', and that would be bad (!). FTP and Telnet Explained. --------------------------- This tutorial is for Unix servers. I have no experience of NT or IIS. What you need: A web server server running the Unix operating system, An FTP client program, An internet connection, A 'virtual' server. {The latter is a web-space that emulates a stand-alone server. You appear to have a server of your own. This is what most webmasters can afford!} Your login IP address: login.ispname.com or something like that, Your username Your password For an FTP client program I use FTP Explorer, because it looks like Windows. Others swear by Cute FTP or WS_FTP. What is FTP? FTP stands for File Transfer Protocol. You can upload and download and delete files on a remote server, and in some clients (software programs on your PC), you can change their permissions, as you can in a Telnet session. What are permissions? Permissions are what these files are allowed to do and have done to them on your server. There are three categories of permissions: Read, Write and Execute or rwx for short. More on this later. If you've never uploaded files on a web server before I recommend you get FTP Explorer. It looks like Windows, and is less confusing to a beginner. You can upload, download, delete, and rename files, and that's about it. It's an easier way to manipulate files that Telnet, but much more limited. MAR. 2001: It's not widely know that you can tranfer files from your PC or your web site via FTP without a specialized client program. *This method is very useful if you want to transfer large files between web servers*. FTP for professionals. ====================== 1. Start up DOS on your PC [ Go to Start>Programs>MSDOS Prompt ] OR telnet (see below) to your website. 2. Type 'ftp', without the apostrophes. You now see a prompt like this: ftp> Now start typing the following: ftp> open login.yoursite.com You will be asked for your username and password. When you've supplied them, you can type the following commands. cd Change directory on the remote server e.g. cd cgi-bin lcd Change directory on the 'home' computer or website e.g. lcd myfiles/pies get Download a file to the home computer e.g. get index.html mget Download a number of files of the same type e.g. mget *.cgi put Upload a file e.g. put biscuit.html mput Upload a number of files of the same type e.g. mput *tiger*.* ascii Transfer in ascii format binary Transfer in binary format close Stop the current connection quit Terminate the ftp session These are just the basic commands. Do a search on any search engine for 'FTP tutorials'. THE MOST USEFUL function of doing FTP this way is that you don't need a special program to do it (it can be dome from any computer with a connection to the internet) AND, you can use it to transfer large files between two web servers at ETHERNET SPEEDS (if your webhost doesn't mind!). -------------------------------------- How To Telnet. You can get a stand-alone Telnet client program, or in Win 95/98/2000 just do the following: First, connect to the Internet. Some ISP's may not allow you to engage in a Telnet session, but most will. Go to Start>Run on your menu bar Type in: telnet www.yourdomain.com (or whatever the URL to login to your site is), and press OK. You will see... login: type your username here password: type your password here You will get some system messages, and then see the Unix prompt. This is an example only: ispname> You are now ready to do some real computing! --------------------------------------------- Unix commands work like a DOS session on your local PC, except what you are doing affects the files on a remote computer. They take the form... ispname> command filename or ispname> command /subdirectory/filename or ispname> command /subdirectory/subdirectory/filename or ispname> command subdirectory Commands may also have an option included e.g ispname> command -option /subdirectory/filename Here is a list of Unix commands to start you off... passwd Change your current login password. cd cd cake Places you in the cake sub-directory. Type cd again to return to root directory. cd .. Go up one directory. cd ../.. Go up two directories cd ../chat Go up one directory, and back 'down' to the directory 'chat'. ls list the files and subdirectories in the current directory ls -al list ALL the files and subdirectories in the current directory, including the hidden ones (files or directories with a dot in front, example : .pgp) AND their dates and permissions. pwd Shows which directory you are currently in.. whereis whereis perl Shows where perl is on a Unix server, and what versions. which same as whereis mv mv cake/biscuit.html sugar/biscuit.html Moves biscuit.html from the cake directory to the sugar directory. NOTE: mv cake/biscuit.html cake/cookie.html Changes the name of file biscuit.html to cookie.html. A handy trick! cp cp cake/biscuit.html carrot/biscuit.html Copy the file biscuit.html into the sub-directory carrot. cp biscuit.html sausage.html Copy the file biscuit.html AND rename the new file sausage.html. Very handy! rm rm cake/biscuit.html deletes biscuit.html rm -r rm -r cake/cheese/ Deletes cheese directory AND ALL ITS' CONTENTS. Be very careful with this command! 'r' stands for 'recursively'. pico pico biscuit.html Allows you to edit biscuit.html. Use ctrl+x to escape and save what you've done. chmod chmod 705 biscuit.html (example only) Changes file permissions - what that file is allowed to do and have done to it on the server, and by whom. Replace 705 above with 604, 707 or 606 for different, common file permissions. These numbers are arrived at by assigning numerical values to the file permissions read, write and execute, or rwx as you see them in an FTP session. The first digit refers to the owner's (your) permissions, the second the group (anyone else sharing the same server space) and the third the world (everyone else). The individual values are arrived at by addition: r=4, w=2, x=1, so if a file has a permission 707 anything can be done to it by anyone, which is why you have to be careful setting it. 604 is what a normal html file has as a permission. The owner can read and write to it, group and the world can only read it. touch touch sauce.dat Creates an empty file with the name sauce.dat * Not a command. Use as a wildcard to find or act on a set of files e.g. rm *.htm* delete all files whose names contain the extension .htm from the current directory. This would include .html files as well. *.* Not a command. Same as in DOS. Affect all files with any extensions e.g. chmod 644 *.* Change the permissions on all files in the current directory to 644. Important note: There is no undelete in Unix. If it's gone, it's gone for good. There is no 'undo' - if you've changed it you'd better have back-up copy, or be ready to manually fix it. You can back up all your files like this.... zip -r zod * Use it in your root (main) directory. It zips all the files and subdirectories in the current directory into a zip file named zod (or whatever). Useful for doing backups. ------------------------------------------------------------------------------- tar -cvf zod.tar * Make a tar (Tape ARchive) of all the files and sub-directories in your current directory. This only works on Unix. tar -xvf zod.tar Opens / 'untars' the file zod.tar gzip zod.tar Compresses the file zod.tar into a gzip file gunzip zod.tar.gz De-compresses the gzip file zod.tar.gz zip -2ee zod.tar Clever trick! Put your tar file into a *password protected* zip file. The 2 is the amount of compression (very little), the 'ee' prompts for a password to the zip file, twice. ------------------------------------------------------------------------------ grep grep Mamma luvlypage.htm Find the text 'Mamma' in a file named luvlypage.htm. If you want to find a phrase you would use quotation marks e.g. grep "I like my Mamma" luvlypage.htm perl -cw perl -cw formail.cgi Check if the cgi script file formail is syntactially correct i.e. that there's no errors in its text. ./ ./formail.cgi Partially execute (until it needs input) formail.cgi in the current directory (usually the cgi-bin), to see if it works properly. And that's it !