Tutorial for Looking around a UNIX Web Site
Exercises
Many of us have access to UNIX through our ISPs. This tutorial is aimed at those people especially. But most of the tutorial would work on any UNIX system. And if you don't have access to a UNIX system, reading the exercises should still give you the basic idea.
The exercises don't create, delete or change any user data. So you are not likely to do any damage by doing these exercises.
If you want to do these exercises (not just read them), you'll need the following (or some rough equivalent).
The following conventions are used in the exercises below.
Since I don't know what's on your system, you'll need to tailor the exercises to your own site.
Having connected to your ISP, bring up Telnet and supply the host name of the computer your web site is on, e.g. users.lanminds.com (in my case)
In the example, I've used the host name of the computer my personal site is on. You would use the host name supplied by your ISP instead.
When prompted, key in your login name and then your password.
SunOS 5.7 login: metaart Password: Last login: Mon Apr 5 18:12:39 from coat4.ppp.lmi.ne Sun Microsystems Inc. SunOS 5.7 Generic October 1998 >
Your login name will be the one you arranged with your ISP rather than metaart. The example does not show the password because it is not echoed back. But you will need to key in the expected password.
Key in the pwd command to see the path to the current directory.
> pwd /data1/home/metaartThis tells us
This directory which you start in each time you login, is called your home directory.
Now do an ls command to see what files and directories are within the current directory.
> ls www
OK. This shows that www is within the current directory. But is it a file or a directory? Key in an ls command with a -l (long) option.
> ls -l total 2 drwxr-xr-x 8 metaart users 1024 Mar 15 01:40 www
This tells us, among other things, that www
Of course, what you see will be somewhat different. The path for your directory will be different, etc.
You can find out more about most commands (and many other subjects) with the man command. Here, we look for information about how to list the names of files which have names beginning with a dot (which are otherwise not shown).
> man ls
Reformatting page. Wait... done
User Commands ls(1)
NAME
ls - list contents of directory
SYNOPSIS
/usr/bin/ls [ -aAbcCdfFgilLmnopqrRstux1 ] [ file ... ]
/usr/xpg4/bin/ls [ -aAbcCdfFgilLmnopqrRstux1 ] [ file ... ]
DESCRIPTION
For each file that is a directory, ls lists the contents
of the directory; for each file that is an ordinary file,
ls repeats its name and any other information requested.
The output is sorted alphabetically by default. When no
argument is given, the current directory is listed. When
several arguments are given, the arguments are first sorted
appropriately, but file arguments appear before directories
and their contents.
--More--(4%)
Since you haven't yet found what you want, hit the space bar to see the next page. Continue doing that until you see something like:
.....
OPTIONS
The following options are supported:
-a List all entries, including those that begin with
a dot (.), which are normally not listed.
.....
Press q to stop looking at the output from man.
Now enter an ls command using the -a option described to see the hidden files, which have names starting with dot.
> ls -a . .. .cshrc .history .login www
As we mentioned at the start, you'll have to modify these examples to do these exercises on your account and your site.
Key in an ls -R command to see the structure of your directories and subdirectories (and the files in them) starting with the current directory (i.e. your home directory). This will give you an idea of what directories to use in the following exercises instead of the one's I used.
> ls -R .: www ./www: GW_articleson.html index.html GW_favorites.html isabelle GW_poems.html resume ..... ./www/isabelle: index.html isabelle_19981106.html isabelle_pic2.jpeg isabelle.css isabelle_19981231.html isabelle_19981020.html isabelle_pic1.jpeg ..... ./www/resume: GW.css GW_resume_faqs.html index.html GW_resume_chron.html GW_resume_skills.htmlThe structure that we see includes:
Change directories to the www directory within the current directory.
> cd www > pwd /data1/home/metaart/www
Now change directories to the parent directory. In UNIX .. refers to the parent directory.
> cd .. > pwd /data1/home/metaart/www
Now change directories to the resume directory within the www directory within the current directory.
> cd www/resume > pwd /data1/home/metaart/www/resume
Now go back to your home directory by using cd with no arguments.
> cd > pwd /data1/home/metaart
Use the find command to search for jpeg files (or some other kind of file you have) in all of your directories, starting with the current one (which is your home directory).
> find . -name " *.jpeg" -print ./www/family/GW_pic_RWES.jpeg ./www/family/GW_pic_RWJW.jpeg ./www/family/GW_pic_Sand3.jpeg ./www/friends/GW_pic_EHJW.jpeg ./www/friends/GW_pic_GWJW.jpeg ./www/friends/GW_pic_GWLC.jpeg ./www/isabelle/isabelle_pic1.jpeg ./www/isabelle/isabelle_pic2.jpeg
The * is a wild card, so *.jpeg searches for all files ending in .jpeg. Don't forget the -print. If you do, all the work will be done, but nothing will print.
Most ISPs have limitations on how much space you are allowed to use. Check to see how much you are using using the du command.
> du 36 ./www/george 206 ./www/octagon 192 ./www/family 240 ./www/friends 144 ./www/isabelle 36 ./www/resume 924 ./www 932 .
You are using 932 blocks. But what size are the blocks? In UNIX it's typically 512 bytes or 1024 bytes. Notice that the www/resume is using 932 blocks. Let's do an ls -l of that directory and see if we can tell the block size.
> ls -l www/resume total 34 -rw-r--r-- 1 metaart users 508 Mar 15 01:38 GW.css -rw-r--r-- 1 metaart users 2892 Mar 15 01:38 GW_resume_chron.html -rw-r--r-- 1 metaart users 3281 Mar 15 01:38 GW_resume_faqs.html -rw-r--r-- 1 metaart users 7201 Mar 15 01:38 GW_resume_skills.html -rw-r--r-- 1 metaart users 556 Mar 15 01:46 index.html
The way of measuring space is obviously different in du and ls. But it's clear a block size of 1024 bytes is much too high. So we'll assume that the block size is 512 bytes. That being so:
932 blocks * 512 bytes =
932 blocks * 1k/2 = 466K = about 1/2 meg.
Since I'm allowed 25 meg, I'm OK.
Note: Or it might have been simpler to use du -k instead of du earlier. That would have caused du to report in kilobyte units.
Change to a directory containing a file to look at, and checkout what's in the directory.
> cd www/isabelle > pwd /data1/home/metaart/www/isabelle > ls index.html ..... .....
Using cat display the contents of a file you are interested in.
> cat index.html <HTML><HEAD> <TITLE><Isabelle/TITLE> ..... <HR> </BODY>></HTML>
Change directories to a directory containing some HTML files and do a search on some tag. Here we search on the IMG tag.
> cd www/isabelle > grep "<IMG " *.html index.html:<IMG SRC="isabelle_pic1.jpeg" BORDER=3> <IMG SRC="isabelle_pic2.jpeg" BORDER=3>
Here we searched for IMG tags within www/isabelle, restricting ourselves to files with names ending in .html.
Finally, logout.
> logout
Your connection is broken.
Copyright 1999 by George Woolley
last substanive change April 6, 1999
note added April, 24, 2002