Printer Friendly

Web page UNIX for beginners.

You've finished organizing and writing the content of your first Web page. You've labored over the HTML tags. And you've uploaded the document to your Web server. All set to go? Not quite. You might need to know a little UNIX to get the page up and running. If you have to put a page up by yourself, you'll want to learn just enough to help you complete your project.

UNIX? Some people cringe at the thought of learning another set of commands and instructions to get their Web page going. Others look down their noses at the operating system that many say is "user unfriendly." Still others may shrug their shoulders and ask, "What's UNIX?"

UNIX is the operating system of choice for many of the computers on the Internet that function as Web servers. It was developed in the early 1970s, when the Internet was in its infancy, in large part to serve as the underlying software technology for what has become known as client/server architecture. UNIX was developed along with TCP/IP protocols and has been a strong contributor to what the World Wide Web can do. Conventions such as remote and anonymous login, world-readable files, and multi-user access have very much been a part of UNIX from its earliest days. UNIX was originally developed as a kind of "shareware" but is now sold as a product by several companies. There are slight differences between these various products, but for the most part they act the same.

If you are loading your Web page on a UNIX server, it is likely that you'll have to learn a few of the basic commands to set up the page. You may have to ensure that it is in the right directory, that the files are named correctly, and that file permissions are set to allow proper access. Let's walk through a typical scenario to look closely at the points where you may need to know a little UNIX.

List Files

Let's say that you have your document or file uploaded to the machine on which you have access to an account for your Web page. One thing you will want to do is make sure that the file is in the right directory. For this you will probably need to list the files in a directory, possibly change directories, or at least make sure you are in the right directory.

The first command you are likely to use is the "list" command. This is basically the equivalent to the "dir" command in DOS and allows you to list all files in the current directory. When you type and enter "Is," UNIX shows you a short description "name only" of most files and directories:

unix% ls unix WWW seo.html

The "Is" command gives only minimal information about these two items. But if you type "Is" followed by "-la," you'll see a longer description of files. For instance:

unixt ls -la

unix% -rw---- 1 techman lib 2882 Aug 27 13:59 .login

drwxr-x-- 2 techman lib 512 May 22 12:21 WWW

-rw-r-r- 1 techman lib 2003 May 19 10:01 seo.html

The "Is" command with the "-la" option shows more information and includes an additional item. Usually, a file with a "dot" before the name is a system file that is hidden from normal view. The letter "a" in the "-la" option tells UNIX to show all files.

The "l" in the "-la" option tells UNIX to list files and directories in the long form, which includes (from left to right) the file permission settings, the number of links to the item, the owner, the group, the size of the file, the date it was created, and the name of the file or directory. One of the most important things to understand about UNIX files is the file permission settings.

Note in the example above that the file permissions for .login and seo.html start with a "dash," whereas WWW starts with the letter "d." This indicates that WWW is a directory and the other two items are files. (Why, you might ask, didn't they use the letter "f" instead of a dash? My answer: Beats me!) You have to look closely to distinguish between files and directories, although some people write directory names with a capital letter so they stand out (and when sorted, names with capitals are sorted before those starting with lower case).


After the leading character, you note there are nine places for a combination of the letters "r," "w," and "x." These represent permissions for reading, writing to, or executing a file (or directory). There are actually three groups, each of which can have an "rwx" combination. The first group sets permissions for the owner of the file, the second sets them for a group that can be set up by the system administrator, and the third is for anyone else in the world! It is this last group of permissions that is important for a Web page.

By default, when you, as owner of the account, create a file, the permissions are set like those for the file .login in the example above. Read and write permission are set only for the owner. The execute permission is not set, but it can be if you want to make the file a program that is run or executed. And no permissions are set for a group or the world. To change permissions you use the "chmod" command, which changes the mode, or status, or the permissions.

Permissions can be changed by two methods. The first is to add or subtract the appropriate letter for one of the three groups. The groups are referred to as "u" for user/owner, "g" for group, and "o" for other/world. So, to add read permission to a file for the world, you would type "chmod o+r" and then the filename:

unix% chmod o+r .login

(Note: UNIX is notorious for not notifying you whether your command was successful. After you type a command, you'll often get nothing more than another UNIX prompt.)

To remove read permission for the world from a file, you would type "chmod o-r" and the filename.

The other way to set permissions is to use a numeric representation as a kind of shorthand. Each of the permissions is given a numeric value, and the presence (or absence) of the permissions is determined by the sum of the values. If all three permissions are set, the sum of the values is 7 (4+2+1); if only the read permission is set, the sum of the values is 4 (4+0+0). (See Figure 1.)

Since there are three groups, the total permissions for a file are represented by a three-digit number. In the example above, the permissions for seo.html are 644 -- read and write set for user/owner, read set for group, and read set for other/world. To make the file readable only for the user/owner, you would type "chmod 400 seo.html." Some people prefer this shorthand because all they have to remember for Web pages is to type "chmod <filename>."

The Right Directory

Okay, so you've got the file uploaded and the permissions set. Now, as mentioned above, you must make sure the file is in the right directory. Your account on the UNIX server is often referred to as your "home" directory, whereas Web pages are often placed in a subdirectory called "WWW" or "pub lic_htmi." To create such a directory, you can use the "mkdir" command (very similar to the DOS command of similar name):

unix% mkdir www

And then you need to make the directory readable for the World Wide Web:

unix% chmod 755 WWW

You can verify the change by looking at the listing using the "Is" command:

unix% ls -l WWW

drwxr-xr-x 2 techman lib 512 May 22 12:21 WWW

(Note: In this case, 755 is used because a directory must be executable as well as readable.)

To move a file into that directory, you can use the "mv" command:

unix% mv seo.html /WWW/

(Note: The first slash indicates that WWW is a subdirectory of your home directory, the second slash indicates that you want to move the file into that subdirectory.)

The "mv" command will remove the file from the current directory when it places it into WWW, but it doesn't give you any notification of this. To verify this, you can use the "Is" command.

To change to the WWW directory to look at or edit files, use the "cd" command (similar to the DOS command of the same name):

unix% ca WWW

To move back, use the "cd" command followed by a space and two periods: "cd..". If you ever get confused or forget where you are, you can use the "pwd" command ("pwd" is an acronym for "print working directory") to print or display the current directory:

unix% pwd usr/yourname/www

(Your server may display something slightly different, but the end part will indicate whether you're in a subdirectory of your home directory.) You can then use the "Is" command to ensure your newly moved file is in that subdirectory.

A Web browser will automatically look for a file named index.html or Welcome.html as the home page in the Web directory. Thus you may need to rename the file that will be your home page. To do so, use the "mv" command:

unix% mv seo.html index.html

If you want to keep a backup copy or older version of the file, you can copy it using the "cp" command:

unix% cp index.html oldin dex.html

And you can use the "rm" command to remove a file at any time:

unix% rm oldindex.html

(Note: If your system does not automatically ask you if you really want to delete the file, you can use the command option as a precautionary measure.)

If you want to look at a file (assuming it is readable text), you can use the "more" command:

unix% more index.html

You can also use the "more" command coupled with another command. Suppose when you type "is" to list files, the list is so long it scrolls off the screen before you can read it. You can "pipe" the "Is" command into a "more" command using the "I" (bar or pipe) key.

unix% ls | more

This is similar to the "dir" command in DOS with the "/p" option -- the "pipe" allows you to take the outcome of one command (ls) and apply it to another (more).

Ready for the World

That's all it takes! Once your file is uploaded, placed in the appropriate directory, and given the proper file permissions, the world is ready to view your page via the World Wide Web. The URL for the page is a combination of the Internet name address for the server along with the name of the directory where your home page sits. For instance, my home page is in the directory "techman," on the server "," thus my URL is Because my home page is named "index.html," I don't need to specify that in the URL. However, people could point directly to it or any other page in that directory. For instance, the URL for my page on evaluation is Good Luck!


Keep in mind that there are three groups of permissions, and that each group has three basic permissions that can be set or unset:

               user/owner (u)   group (g)   other/world (o)
alphabetical        r w x        r w x         r w x
numerical           4 2 1        4 2 1         4 2 1

     Seven Basic UNIX Commands for Web Pages

Is     to list files (-la option lists all files in the long
cd     to change or move to a directory (cd .. moves you back)
pwd    to print/display working/current directory
my     to move or rename a file
chmod  to change permissions on a file or directory
rm     to remove a file (rm-i prompts you to double check)
cp     to make a copy of a file

Note: The UNIX Vault -- http://www.nda/com/-jblaine/vault/--is one of the most comprehensive lists of UNIX-related resources on the Internet. It includes the UNIX FAQ, UNIX Survival, UNIX Guru Universe, UNIX Resources, UNIX Reference Desk, and UNIXhelp for users, as well as links to resources on scripting in Perl, shell programming, and pertinent news-groups.

D. Scott Brandt is technology training librarian at Purdue University Libraries. He can be reached by e-mail at
COPYRIGHT 1996 Information Today, Inc.
No portion of this article can be reproduced without the express written permission from the copyright holder.
Copyright 1996 Gale, Cengage Learning. All rights reserved.

Article Details
Printer friendly Cite/link Email Feedback
Title Annotation:World Wide Web
Author:Brandt, D. Scott
Publication:Computers in Libraries
Date:Nov 1, 1996
Previous Article:Operating system wars.
Next Article:Library networking: preventing network problems.

Terms of use | Privacy policy | Copyright © 2021 Farlex, Inc. | Feedback | For webmasters |