Telnet Basics
Telnet
is a simple client/server application. Telnet allows you to log onto a remote
machine and access almost like you are physically there. The remote machine MUST be running a telnet
server and you must have a logon and password.
This is how you will access some of core features of your
webserver. Setting file permissions,
compiling programs, setting passwords, and running programs are some of the
things you will be able to do. For this
tutorial I am assuming that the telnet server resides on a UNIX type machine.
Most
current computers come with a telnet client.
On Windows 95/98/NT you can simply click on the Start button and select
run, then you will type telnet www.yourserver.com. This will now attempt to connect to port 23 on your domain. **note**
if for some reason your webserver is using something other than port 23
you will have to specify is like this:
telnet www.yourserver.com 123
where we will try to connect to port 123 on yourserver.com. Now once you are connect to the server you will
have to adher to the conventions of that computer. What this means is if the remote computer is a 'UNIX' type
computer you will have to remember that things are case sensitive. Filea is different that FiLea. You will also have to use '/' instead of a
'\' when dealing with directories.
Once
you login into your account you will be presented with a prompt. Depending on the shell your provider is
using this prompt will vary a little.
One of the first commands your will probably want to use is the
"ls" command. This is the
list command. If you type
"ls" your will see a listing something like this:
filea.htm fileb.php3 directorya/
These
are the files in the directory you are in.
The
'ls' command has many switches. A
switch is usually prefixed with a '-' .
The most common one is -l . This
gives you a long listing of your current directory. So 'ls -l' will give you
something like this:
drwxrwxrwx somename root
/directorya
-rw-rw-rw- somename user filea.htm
-rw-rw-rw- somename user fileb.htm
This
listing gives us a lot of useful information about our files. First,
the leftmost column is the file permissions area. The next column is the owner, the next is
the owner's group, and the last is the name.
The permissions are 10 positions.
They are broken up like this:
Pos
1 can be: D for directory, L for link, - regular file
rwx
stand for read, write, and execute
Pos
2-4 these are the owner permissions
Pos
5-7 these are the group permissions
Pos
8-10 these are the world permissions
These
permissions determine what a particular user can do to a file.
Another
switch of note is the -a switch. This
switch displays all files in a directory.
So, 'ls -a' will dislay the same as the first example above plus all the
hidden files such as the "dot" files. The "dot" files are the current directory
("."), the parent directory (".."), and any file that
begins with a ".". One of the
"dot" files that is important to you will be probably be the
".htaccess" file. This file
can limit what can be viewed by the outside world. It also controls things such
as whether Server Side Includes will work on your site.
You
may also combine switches. This will
apply to most commands in the system.
So if you want to display the contents of the current directory in long
format showing all the files you would type 'ls -al'.
By
now you are probably ready to move around the filesystem. You probably need a little background on how
a UNIX filesytems is organized. Everything is based upon a root ('/')
directory. There aren't any drive
letters to speak of. Every harddrive,
cdrom, or floppy drive is given a subdirectory. So you may have a filesystem that looks like this:
/
/floppy0
/harddrive1
/cdrom
/bin
/etc
To
see what is located in one of these directories we use the 'cd' command. Type 'cd /floppy0' to change to the floppy
disk drive. This is akin to typing 'a:'
on a Dos/Windows system. If you type
'cd' then press enter this will take you to your home directory. In order to change to a subdirectory you
will type 'cd subdirname' or 'cd subdirname/alowerdir'. The first one will take you into a directory
called 'subdirname' and the second one will take you into a directory name
'aloweredir' which is located underneath 'subdirname'. Typing 'cd /' will take you to the root
directory. If you were to type 'cd
/mydir' this would look for a directory called 'mydir' off of the root
directory. Typing 'cd mydir' will look
for 'mydir' in the current directory.
So this means 'cd /home' will have different results than 'cd
home'. That is of course if you are not
located in the root directory. At
anytime you can type 'pwd' (present working directory) to see something like
this:
/home/gelfius/
To
create a subdirectory you use the 'mkdir' command. This will create a directory underneath the current
directory. To remove this directory you
use 'rmdir'. A subdirectory is very
useful in organizing files. It's a very
nice to keep your program source away from the program executables.
To
copy files from one place to another use the 'cp' command. Type 'cp file [location]/name'. This will create another copy of file and
place it [locaiton]/name. If you want
to delete a file use the 'rm' command.
If you want to move the file to another location use the 'mv'
command' The format for all three of
the commands is very simular. See the
man page on the command for further details.
Editing
files through telnet can be a little tricky.
Depending on the operating system you may or may not have a full page
editor. I personally use 'pico' to edit
files through telnet. Another useful
editor is 'vi' . Vi is more cumberson;
but is a very power editor once you master it.
Remembering
all the switches and operands of all these commands can be a little
tricky. So the 'man' command is
provided. Man will give you a manual
like page for the command you specify.
So, 'man cp' will give you all the optional parameters for the copy
command. Most commands in the system
will have a man page.
The
last very useful command is 'chmod'.
This a very powerful command with a lot of security implications
associated with. The 'chmod' (pronouced
change mode) command lets you set the permissions on the files. This is what you would use to change whether
a directory can be viewed everyone or only the creator.