Telnet And Unix
Telnet
Telnet is the software you'll use to access your webhosting machine. It's called a terminal program because it makes your PC act like an old mainframe computer terminal. It gives you a character-based - i.e. not graphical - window into which you can type things, and see results.
I recommend you use PuTTY. Or
TeraTerm and it's SSH module: TTSSH. If you haven't already downloaded one of these, do it now.
SSH is a telnet protocol which encrypts your username/password while logging in. The SSH module for TeraTerm should be installed in the same directory as TeraTerm. You then run the 'ttssh.exe' file, and select 'SSH' as the connection method.
TIP: You can set your telnet program to automatically connect to your webhost, so you don't have to login every time. With TeraTerm, you supply the details on the command line... Create a shortcut to ttssh.exe on your desktop, then edit the file properties so the 'target' looks like this:
"C:\Program Files\Your-Path-To-TeraTerm\ttssh.exe" www.yourdomain.com
See the help file for details of all the options you can specify on the command line!
|
When you run your telnet client, it'll prompt you to enter your username and password. Once logged in, you get the Unix command line prompt which looks similar to this:
[you@self you]$
You can type any valid Unix command in here, and it'll be executed.
Unix Basics
Unix is a superbly flexible, stable, scalable operating system. It is well designed and based on fairly simple, robust concepts and algorithms. Unix is multi-user - lots of people can connect to one machine at the same time, and multi-tasking - it can run many programs all at the same time. Its power and longevity have come from the cleverness of its initial design, plus now its openness...
Unix now comes in a huge range of varieties, although they're mostly all based on Linux - an Open Source Unix that was originally written by an individual (Linus Torvalds). Linux has become a standard.
With the advent of Linux and the open source movement, a world of enthusiastic programmers have been able to give their input to it - and many other projects - and there is a wealth of high quality, free software out there.
Unix may sound scary, you may have seen frighteningly large books about it, but you actually need to know very little about Unix to be a webmaster, just a few basic commands. Besides, Unix is designed to be a tool - and it's actually very easy to use. You can pick up the niceties as you go along.
The Unix you'll use as a webmaster has an all character-based user-interface. This means, that there's no graphics, no windows! This is because sending graphics down the phone line into your computer is much more demanding (hence slower) than sending characters. It's not necessary either.
|
INFO: There is a graphical-user-interface (GUI) available for Unix called 'X-Windows'. It is superb, but you probably won't be using it - unless you run Linux on your home PC. |
If you don't already have your webhosting account, you should get it now. It's a good idea to try all the commands listed below on your webhosting computer to familiarise yourself with them.
When you login to your Unix account, you start out in your home directory. This will be something like: /users/yourname. The directory name can appear in the command line prompt (or just 'prompt) e.g.:
[you@self yourname]$
You change directories using the cd command (change directory), e.g. to go to the www directory:
cd www
The list of directories which specify where a file is to be found is called the path to the file. For example, the path to the Perl interpreter program is usually /usr/bin. More on this in the next module.
Common Unix Commands:
man | Access the manual pages |
cd | Change Directory. |
pwd | Print Working Directory. i.e. the current directory |
ls | List the files in a directory |
cp | Copy Files |
mv | Move Files |
rm | Remove (Delete) Files |
du | Show Disk Space Usage |
who | Who's currently logged in? |
which | Where's a program located? (Which directory) |
ps | What programs are currently running. |
You use these commands by typing them in, followed by any options or parameters (or switches) you might wish to pass to them. For example, to see all the details on all the files in a directory, you'd type:
ls -al
Unix has a built-in help system of manual pages. These are accessed by typing man command (where command is what you want to know about). i.e. you can type man man to find out how the man page system itself works. The man pages explain how everything works and list all the options each command can take.
Names are traditionally short in Unix as there were no windows interfaces when it was designed, and the designers decided that keeping typing to a minimum was a good idea.
All files in Unix have a set of permissions for security reasons. You can determine who can read(r) / write(w) / execute(x) any file. When you use the -l switch with the ls command (i.e. type 'ls -l') you'll see the file permissions...
To change file permissions, you use the chmod command. (Read the man page for chmod) e.g.
To make test.pl executable (so you can run it - a program):
chmod +x test.pl
Unix treats everything as files. It has 3 files that are always open:
- stdin - standard input - i.e. the keyboard
- stdout - standard output - i.e. the screen.
- stderr - standard error - i.e. also the screen...
TIP: By default the shell (see later) echos stdin to stdout - that's why you can see what you type!
stderr is usually redirected to stdout - so any errors appear on the screen. |
You can direct the output of programs to wherever you like, for example a disk file, using the redirection symbols: '<', '>' and '>>'. In this example:
ls -al >files.txt
...writes a directory listing to the file 'files.txt'.
The cat command prints or echos a file. By default it echos stdin to stdout, but you can use it to list the contents of a file, or create a file from scratch:
cat files.txt
...prints the contents of 'files.txt' to the screen, while:
cat >typing.txt
...will put everything you type into 'typing.txt' until you press the 'end-of-file' character (ctrl-d).
To append to a file - i.e. add to the end, use the >> symbol like so:
program >>log.txt
...This will send all the output from 'program' to it's log file - without overwriting what was already there.
To send the output from one program to another use the pipe symbol like so:
ps -ef | grep bob
...This will send all the output from 'ps' (list running processes) to 'grep' (echos lines containing the text 'bob'). You can use this to list all the running processes that are owned by you (i.e. replace 'bob' with your name).
This section covers the most common interactions you'll have with your webhosting machine. As a webmaster you don't really need to know much Unix. (If you were to set up your own webhosting company - that would be different - installing and setting up Unix can be a very technically demanding task.)
Unix is a very powerful operating system and contains a vast number of different tools, including programming tools, for all manner of applications. It encourages customisation. From writing your own shell aliases (see the alias man page) to writing entire applications, the programming experience is designed to be simple, powerful and efficient. This doesn't mean it's easy to learn everything about Unix, it can be terse to the point of obscurity and isn't actually designed to be novice friendly. But the majority of tasks you'll need to do will be quite straightforward and well documented.
Unix is a bit monolithic - it contains a huge tool set as standard, and some of those tools do a lot of different things. It can be daunting, or it can be great fun to explore. You can take it as far as you want - learn just the basics, or delve deeper, it's up to you...
Get a telnet session running. Once it's up and you've logged into your webhosting account, then try the commands listed on this page, and use the man pages to get a feel for the Unix environment.
|