Cliff notes for unix

Introduction

This document is a brief overview of UNIX and the CAT supported UNIX systems at portland state. You will find it useful, but it's not meant as a "tutorial" for learning unix for the first time.

What is UNIX?

UNIX is a set of computer programs and utilities which run the workstations in the department. Like all operating systems, UNIX does exactly what you tell it to do. The difference with UNIX is that you can tell it to do just about anything, if you know how to word the instruction. Learning UNIX means learning how to use the zillions of commands, utilities, and options that are now at your fingertips. The more you learn, the more you can let the computer do the work.

What is the CAT?

The CAT is the computer action team. We run the UNIX workstations (mostly suns, some silicon graphics stations, and a couple others) in several PSU departments (EE, CS, ME, CE, Sysc, and ACL). If you have a question or problem with the systems, send email to cat (more about how to do that later).

Note that the CAT does NOT run odin. Odin is operated by the computer center.

Logging in

When you get an account, you have a loginname, and a password. You need to find a machine in your department. If you're in CS, the main computer cluster is in MSB 120. If you're in EE, the main cluster is in PCAT 138D. Goto the cluster and find a machine with the words "login" and "password" in a small box in the center. Type your login-name, hit return, type your password, and hit return. The windowning system should appear after a few seconds.

The window enviornment

You can give the computer instructions in two ways: with your mouse, or by typing commands at an xterminal.

Move the mouse pointer to an "empty" spot, and try holding down each of the three buttons in turn. As you can see, you can run some common applications, or create a new xterminal on your current workstation. In addition, there is a list of other workstations. By selecting one of them, you can start an xterminal on that machine (although you may be required to type in a password). You can also use the mouse to logout. The xterminal is the most important part of your enviornment. This is where you can type commands to the computer. Anything you can do with the mouse, you can also do by typing a command into an xterminal.

The prompt

In each xterminal, you will have a prompt. It looks like this:

122 sirius.cs.pdx.edu> The number on the left is the "history number." We'll explain that later. sirius.cs.pdx.edu is the name of the machine you are currently logged in on. The ">" at the end is the prompt, telling you that the computer is ready for your next command. In the examples below, when we show a user typing in input we'll show it like this:

134 sirius.cs.pdx.edu> ls -l total 24 -r--r--r-- 1 rootd 14260 Aug 10 1993 ethercrack -rw-r--r-- 1 rootd 1931 Aug 11 1993 mcwlog -rw-r--r-- 1 rootd 7652 Aug 12 1993 paper 135 sirius.cs.pdx.edu>

Changing your password

You probably want to change your password. Type the following:

140 sirius.cs.pdx.edu> passwd at the prompt. The computer will ask you for your old password (so someone can't change your password while you're away from your terminal for a second) and then the computer will ask you for your new password twice (to prevent a spelling mistake).

About good passwords

Most security penetrations on UNIX machines are the result of a "broken" password. Don't give anybody your password. Don't write down your password in a place where someone can easily find it (like next to your computer:-). Don't pick a password that someone (or some computer program) can guess. NEVER write your password in email or any computer file.

What are some bad passords?
What makes a good password?
One good trick is to pick a sentence with 7 words, use the first letter of each word in your password, alternate cases as you type them, and add a punctuation mark at some random point in the word. For example, the following sentence:

My history professor is a real pain

could become

Mh(PiArP

Which would be hard to guess, but easy to remember.

Viewing files

There are many ways to view files in UNIX 169 sirius.cs.pdx.edu> cat /etc/passwd cat prints out the contents of a file. For short files this is great, but for long files everything will scroll off the screen before you can read it.

171 sirius.cs.pdx.edu> more /etc/printcap more prints out the contents of a file, one screen at a time. Hit the spacebar to see the next screen. If you want to stop reading the file, and not page through the rest (what if the file is a thousand pages long?!) then hit q instead of the spacebar.

172 sirius.cs.pdx.edu> less /etc/printcap less is similar to more, in that it prints out a file one screen at a time. The advantage of less is that you can scroll backwards (hit b). Remember that you use q to quit.

Editing files

There are several different programs for editing files. The simplest is pico. To start pico, just type pico.

174 sirius.cs.pdx.edu> pico You use the arrow keys to move around. At the bottom of the screen is a list of special commands. Remember that ^R means hold down the control key and hit r (no shift key necessary).

vi is a much more powerful editor. If you're going to edit files regularly, you should learn vi. The secret to learning vi is that it has two modes: insert mode, and command mode. You start in command mode. Here are a few command-mode commands:

Insert mode will let you type text. Hit the escape key to leave insert mode.

To get out of the vi editor, you have to be in command mode. Hit the escape key to make sure you're in command mode, then type a colon (:). The colon will appear at the bottom of the screen. To save and quit, type in wq and hit the return key. To quit without saving type q! and hit the return key.

Textedit is a "graphic-oriented" editor. It allows you to use the mouse. If you type

176 sirius.cs.pdx.edu> textedit myfile & textedit will appear in a new window and will let you edit myfile.

Email

There are several programs for sending and receiving email. Some of them are:

All the email systems mentioned here use the concept of folders. A folder is a directory with email in it. You can organize old email by putting it into different folders. If you get a significant amount of email, this quickly becomes essential.

Quick guide to mh

mh actually consists of several commands. Each one is designed to do one task. By knowing only eight commands, you can use mh effectvely.

The eight commands to survival:

inc inc (incorporate) checks for new email scan scan lists all your email show show shows the current email next next shows the next email prev prev shows the previous email rmm rmm removes the current email comp comp composes an email for you In addition, some commands (like show, and rmm) can be used with numbers. If you want to remove messages 3,7, and 14, you can type:

> rmm 3 7 14

And it's done!

X windows basics

The X window system allows you to run a program on one machine, and have it display on another. This is how xterminals work, you login on the xterminal, but the programs run on the sparcstation the terminal is bound to.

There are two problems: first, your computer needs to know where to display its graphics, and second, your window needs to know what computers to allow to connect.

First you need to figure out your display's address. It is the same as the name of the terminal or computer where you are sitting, with :0.0 appended. For example, right now, I'm sitting at potemkin.cs.pdx.edu, so my display is potemkin.cs.pdx.edu:0.0

If I rlogin (or telnet) to another machine, or if I start a new xterm, I need to set my display enviornment variable before running a program. Here's how: > setenv DISPLAY potemkin.cs.pdx.edu:0.0 That's it! There is still the second problem: how do you tell your console to allow a particular machine to connect. You only need to worry about this if you are sitting at a workstation (x-terminals normally let anyone connect). If you are on flotsam, and (in one of your windows) you rlogin to ka, then type the following on flotsam to allow ka to connect:

37 flotsam.ee.pdx.edu> xhost +ka.ee.pdx.edu

Documentation