California State University, Sacramento

Home
Syllabus
Assignments
Contact
Grades

Assignment 4

Points: 30
Due Date: 2/27
Reading: none




What is Unix?

Unix is the generic name of a family of computer operating systems (OS). You don't see them much on the typical PC, where the operating system is usually a version of Microsoft Windows. Unix is found primarily on server computers on large networks. These are machines that run various server programs, whose purpose it is to serve up web pages, provide shared file access, etc. Even your campus servers (gaia, saclink) are Unix machines. This lab will compare and contrast the Unix environment available to you on gaia, with the Windows or Mac environment with which you are more likely accustomed.

How is Unix different than Windows?

Unix is a multi-user operating system. Users are given accounts on the system which they can use to access the Unix operating system remotely from a terminal or a PC running a terminal emulation program. It is not likely that you will be using the actual console on a Unix machine, unless it is your own workstation. Unix is not (necessarily) a graphical environment. There are "window" environments for Unix systems, but they are independent of the main operating system. (The graphical environment is built into the Windows and the Mac OS operating system.) In this lab, you will log into your gaia account remotely. Gaia has a command line environment where, once logged in, you will be given a shell prompt to type commands. If you have any knowledge of DOS, this might be familiar to you.

So what is gaia?

Gaia is a computer. It's that simple. It is a Hewlett-Packard 9000/800 running HP-UX version 10.20. Basically, HP's version of Unix. There are also other versions of Unix such as Solaris (Sun Microsysytems) and AIX (IBM). One of the newest versions of a Unix-like operating systems that you may have heard about for the PC is Linux.

Ok, why are we learning about this again?

In the next several labs, we will be looking at a number of Internet applications on both the PC and Unix platforms. There are still enough resources out there that require you to have some knowledge of a command-line Unix environment even though more and more of these are moving to web-based interfaces.

By this point, you should have an account on gaia, the main file server in the school of Engineering and Computer Science (if you don't, contact me; you'll need one now).

Logging in to gaia

If you already have an account, and did lab assignment 1, you have probably already logged in and changed your password. If not, refer again to lab 1 for details on how to log in to gaia from a workstation at school, or from a PC at home.

Moving around in gaia

Follow this link for a description of a few UNIX commands. I will walk you through most of the ones you need to use, but you may find this reference useful.

As I mentioned above, you are faced with the shell prompt when you first log in. Try the following command: ls -al (all commands are executed by pressing the "Enter" key) This will provide you with a list of the files and directories in your current place in the file system. You can find out your location starting from the root of the file system by typing pwd. (If you are familiar with Windows, this would be finding which folder you are in on the C:\ drive.)

  1. Execute the pwd command. What is the output?

Unix commands are short; ls is the command to "list" the current directory and pwd is the command for "print working directory". The -al in the ls command mentioned above is referred to as a switch. This particular switch, when preceded by the ls command, displays the listing with (a)ll files, in (l)ong format.

  1. What are the differences between the ls and ls -al listing of files?

Directories in Unix are the same as folders in Windows. Issue the list command with the "a" and "l" switches again. The lines that begin with "d" are directories. The top level in the Unix filesystem is the root directory denoted by a single forward slash. The path to your current directory is denoted by forward slashes between directory names. (Do you see any similarities to paths in a URL? ) When you log in, you are placed in your account's home directory. You can navigate through the file system with the cd (change directory) command. The form of this command is cd [directory], where [directory] is an argument to the command specifying the relative or absolute path from your current directory to a target directory. For example, if I wanted to move to a directory named scott I would type cd scott. A single dot (.) is shorthand for the current directory, and two dots (..) means the parent of the current directory (one directory up). The cd command with no arguments will put you back in your account's home directory regardless of where you are.

  1. Based on what you now know, what is the command to change to your html directory?

    Use this command to change to the html directory.

  2. Once you have changed to the html directory, do another listing, and tell me the names of the files and folders listed.

These files are part of the default web page for your account. In a later assignment, you will come back here and add to or modify these files.

A bit about file permissions

After executing a long listing command, you will see a series of r's, w's and x's on the beginning of each line. These letters represent that file's (or directory's) access permissions, which are read, write, and execute. In a multi-user system, it is important to be able to control who has access to what files. It is also important that you be able to change the permissions on the files that you own, especially your web page files. Let's take a look at a permission string.

-rw-r--r--

The first "d" or "-" of a permission string represents either a directory or file respectively. After this designation, the permission string is divided into three sections of three characters each: The first section represents the users's permissions, the second the group's permissions, and lastly the others permissions. This grouping allows resources to be shared among more than one user, but not all users. For example,

file user group others
- rw- r-- r--

means the user has read and write permission, and the group and others have only read permission. (The - indicates a file. A d indicates a directory.)

  1. What does the permission string drwxrw-r-x represent?

  2. What would the permission string look like for read and execute permissions for the user, read and write for the group, and read for all others?

You will need to be able to change the permissions to your web page files if you want the rest of the world to see them. The way to do this is with the chmod (change mode) command. The arguments to chmod allow you to specify which class of users, and what permission you want to add or remove.

For example, the command chmod u+r index.html would add read permission for users to the file index.hmtl. chmod g-w index.html would remove write permission for the group for that same file. Generally, you will only be concerned with adding read permission for others to make your web page files visible to the world.

  1. Suppose you have a file named index.html. Assuming the letter "o" represents others in the chmod command, list the command or commands that would add read permissions so that all others could view this file? (You'll need to remember this for later labs.)

Other useful command information

Most UNIX operating systems have a built in help file. You can reach these help files by typing man <command>. Typing man ls would result in the help pages for the ls command. Here you will find information about the command, along with all of the switches that can be added to change the results of the command.

  1. Type man man. What is the description for this command?

Do another long listing, and you will notice several other bits of information about the files: the owner of the file, the group the file belongs to, and the file size.

There are many other commands available at the command line in Unix, not the least of which are commands to copy, move, and delete files, edit files, and run other programs. This assignment was only meant to introduce you to Unix. In later labs, you will learn the commands for several Internet programs in both the Unix and PC environment, and will be introduced to more Unix commands. For now, this should be enough to chew on.

Don't forget to type exit to log out of your account!