EE 260:  Introduction  Unix

1  Introduction

This is a brief tutorial on UNIX, which is an operating system like Windows.   We will be using software available on the College of Engineering (CoE) computer, which is named wiliki.  Get a wiliki account if you do not already have one.  You can get one immediately from POST 208, which is in the Pacific Ocean Sciences and Technology (POST) building which is north/mauka of Holmes Hall.   (Note that it takes a few days to process the forms to start an account.)

What can you do with your wiliki account?
This introduction is organized as follows.  

2  An Overview of UNIX

UNIX is an Operating System, which is the program (software) that makes a computer run. At this point, all you need to know about UNIX is that it's there working for you and that it's able to execute your commands.

To get a UNIX account means that

Let's first talk about the space (quota) that you get. Your space is used to store files. Files can be programs, email letters, scientific data, etc. To organize your files, there are entities called directories. Directories are "folders" that you can place your files into.  You can also put directories into directories.

All of your files and directories will be inside your home directory, which has the same name as your account. In fact, your files and directories are structured like a family tree.


Figure 1.

In this tree, the children of a directory are its contents -- files and other directories.  For example, the home directory (Directory A) has four children:   File A, and Directories B, C, and D.

Now let's talk about the kinds of commands that you can execute in UNIX. The following are some of the kinds of commands available:

3  Walk Through of UNIX

3.1. Logging In

There are a number of places you can access wiliki.

Methods for accessing wiliki may vary slightly depending on where you are and what type of computer/terminal you are using, but generally, it will be done using program called ssh, which is Secure Shell Client. To log into wiliki from another UNIX (or LINUX) computer, enter:

     ssh wiliki.eng.hawaii.edu

Wiliki will prompt you for your login id and password.

<>To login from a PC, find the Secure Shell Client ssh application and click it.  Then you can choose quick connect.  Then it will prompt you for the host name, which is wiliki.eng.hawaii.edu; and your user name, which is your login id. Then wiliki will prompt you for your password.

Once you've logged into wiliki, you will see the prompt:

-bash-3.2$

wiliki has the LINUX operating system that uses the command shell bash.  A command shell is a program that allows a user to type certain commands, that manage files and run executable programs.  Bash is a UNIX-like shell.  Users can type in commands (e.g., "cp" for copy a file, or "mv" for move a file), and these commands will be interpreted and acted upon by the shell.

3.2 Typical UNIX/LINUX Shell Commands

At this point you are interacting with a program referred to as a shell. These programs are responsible for interpreting and carrying out the commands you type. There are different types of shells, but the one you want to work with is the C shell. To check if you're interacting with C shell, type

     echo $SHELL

(NOTE: Unix is ``case sensitive'' meaning upper and lower case letters are different. You should type the above command to your shell exactly as shown above). You should see the response

     /bin/bash

that you are using the bash shell.

3.3 .bash_login and .bashrc

Now you can start typing shell commands. Since the commands may be difficult to remember. It's rea helpful to be able to customize your environment.  This can be accomplished by having two data files called

NOTE: type this command exactly as shown --- particularly the ``dot'' (.) in the names above. What you have just done is to copy (by using the command ``cp'') the file, called bashrc, to your working space. The copied file is called .bashrc. To check if the file has been copied over type ``ls -a,'' which will list all the files in your working space. Here, ls is the list command and -a is the ``all'' option. Now if you do an ls, you will see that there is still nothing there. That is because, without the -a option, ls does not list files with a dot as their first character.

To make sure that the set-path is properly installed in .bashrc, type

testenv

If some program runs then it's been installed properly. Otherwise, you'll get some error message. Quit the program if you got it running.

The environment defined by the .bashrc file will will not go into effect until you login again. But before we do that, there is one more change we can set up.

3.4  Changing Passwords

The password you were given on your account is probably a sequence of random letters and numbers --- this can be hard to remember. You might like to change the password to something you can remember better. (You don't have to do this now, if you would like to think about what you want to use for your password).

Unix allows you to choose your own password (with some restrictions) using the passwd command. You should choose something that you will remember, but that will not be easy for someone else to guess. You SHOULD NOT use things like your login id or your name or minor variations of these. In addition, the system requires that your password be at least 6 characters containing at least two letters and at least one number character. If you have something in mind, you can change the password now by typing passwd. The system will prompt you to first enter your current password (to make sure it is really you) and then it will prompt you twice to enter the new password (to make sure you can type it twice in a row). From that point on, whenever you login, you will have to use the new password.

Try not to forget your password. There is no way for anyone to find out what it is for you, not even the system administrators. If you forget your password, you will have to see the monitors in POST 208 to ask them to put a new password on your account. You will need a picture ID and it may take a day or two for you to get the new password. You will not be able to use your account until then.

3.5  Logging Out

Now that we have set up all these changes to your account, as I have said, to make them all take effect, you must logout and log back in. To logout, you can use the logout command or the exit command. Typing these to the shell will end your session on wiliki. NOTE: if you are on a PC or Mac telnet'ed to wiliki, simply turning the computer off WILL NOT automatically log you out. To protect your account, you should always use the logout or exit command.

Go ahead and logout now, and then log back in using the same procedure as before. We will then do a little more exploring of the system. Go ahead.... I'll wait...

3.6  Navigation

Welcome back...

You should now see that things look a little different. Your prompt now looks like:

     YOUR LOGIN ID:wiliki:1>

If you check, you will also see that you are using csh. There are other subtle changes which may become evident later.

We will discuss how data and programs are stored in Unix. First, all data and programs are called files, where programs are called executable files. Directories are storage areas for files that can also store other directories. If you are familiar with ``Windows'' or Macintosh software, then directories function as ``folders.'' Recall that directories and files are organized into a tree.

To find out what directory you are in type

     pwd

and you should get something printed out like this.

     /users10/ee/fac/sasaki

which means that I'm in directory ``sasaki'', which is contained in directory ``fac'', which is contained in directory ``ee'', which is contained in directory ``users10''. Directory tep is the one I get into when I login, and is my home directory. The string of directories /users10/ee/fac/sasaki is known as a path.

To navigate around, we can use the following UNIX commands:

You probably don't have too many things in your home directory. So let's go to another directory that has more stuff in it. Change the current directory by typing

    cd /inst/ee/ee260/ee260 or cd ~ee260

This will be referred to as the ee260 directory,

Type ls to list out the contents of the directory. You should see something like this:

Archive/  Lab0/     Lab3/     Lab6/     Lab9/     cshrc     info
Help/ Lab1/ Lab4/ Lab7/ RunMe* garage/ login
Hex/ Lab2/ Lab5/ Lab8/ bin/ house/

The ee260 directory contains both directories and files. Example directories are "Help", "Hex", "Lab6", "bin". Notice that directories have the forward slash (`/') appended to them. This just indicates that they are directories rather than files.

Also notice that some of the files have the suffix "*" appended to them. This indicates that they are executable files, which means that they are programs that you can run. In fact, if you type

RunMe

The program RunMe will run.

To get back to your home directory type:

cd

Type ls to check. To get back to the handout directory, type

cd ~ee260

rather than the long pathname. The ``tilde'' character before the login name tells the system to figure out where the home directory of ee260 is. Now let's get into a subdirectory such as house. Type:

cd house

Type ls, and then type pwd to find out where you are. To get back to the parent directory (in this case the home directory), type:

     cd ..

The ``..'' characters indicate you want to go up the directory tree.

Some of the directories in here are protected so that you cannot get into them. For example, try typing:

     cd Archive

You get the message ``Archive: Permission denied'' which means you do not have permission to get into that directory and see what is there.

Your home directory should have been set up with all permissions turned off so that only you can get into it. This is a good way to protect what is stored there. (There are ways to change permissions on files and directories, but we will not describe that here. Ask around if you are interested).

Go into the Lab0 directory. You will find a data file called add.work, which contains additional (optional) assignments for the rest of this laboratory. The assignments will give you additional practice in using Unix.

You can view the contents of add.work by typing:

     more add.work

The contents are displayed on the screen, one screenfull at a time.

3.7  Creating and Deleting Files and Directories

Here are some useful commands.

You will notice that directories are a nice way of organizing files. because you can put related directories and files in a common directory. Without directories, organization will be more difficult.

To keep organized you should have an EE260 directory to store all your class stuff.

Change to your home directory (type cd). Create a new directory by typing

     mkdir EE260

(Note: I generally use the convention of naming my directories beginning with upper case letters and files with lower case letters, but this is just a convention, and you may choose your own). Now if you do an ls you will see:

EE260/

i.e. a new directory called EE260 in your home directory. You can change to that directory by typing:

     cd EE260

Doing an ls there will show it to be an empty directory. We can copy over the add.work file by typing:

     cp ~ee260/Lab0/add.work lab0

This copies add.work into the current directory and names the file ``lab0''. You can also create files related to EE 260 stuff in this directory. A few of the tools available on the system for doing this is given in the next section.

Finally, if you forget how to use any of the commands, you can use the on-line manual command man. For example, to list the user instructions for the command cp, simply type:

     man cp
To scroll the instructions on the screen you can type space bar for new screenfull, return key for one line, or `q' to quit (just like the more command)

3.8  Editing

You can create or edit computer files using an editor.  One of the simplest to use is pico.  To create a file, type "pico".  To edit a file, type "pico file-name". Go through a PICO Tutorial from North Carolina State University.  Here's another tutorial from Indiana University.

Try it by creating a file called "test".

Another editor is "vi"  Click here for a quick tutorial. You can skip the tutorial if pico is sufficient for your needs.

3.9  Email

With your wiliki account you can send and receive email.  One of the simplest email programs (known as mailers) is pine.  To invoke it, just type "pine".  You can read, compose, and send email messages. Go through a PINE Tutorial from University of Washington.