UNIX Introduction

last updated 1/17/08

UNIX

 A popular, open operating system developed in early 1970's at Bell Labs (AT&T).

Note that the Suns here all share the same file system, so it doesn't matter which you log into.

 


Sun Workstations

We will use the Unix workstations found in C102 that are Solaris based. These machines are local to Eaglenet.  You will need to connect to the campus network via VPN or RAS first to access these machine from off campus. The workstation names are:

  • cairo
  • dublin
  • paris
  • sydney
  • tokyo
  • venice
  • amsterdam
  • london
  • moscow
  • vienna

We will use the Common Desktop Environment GUI (CDE) on the Suns accessible via an X-window application called Cygwin.  Cygwin should be found as a preinstalled application in C102.  You will need to choose one of the above workstation names on the opening screen. 

To install Cygwin on your own computer, visit the link http://www.cygwin.com/ and be sure to install the Xwindows components.

On a windows machine, once you start Cygwin, at the command prompt you should type:
xwin -query hostname -clipboard -fp tcp/hostname:7100

The above command allows you to use the clipboard, to cut & paste data from windows to Unix, and uses the Sun's fonts.

You can remove the -clipboard and -fp tcp/hostname:7100 options, if you wish, and simply use:
xwin -query hostname

login on Sun workstations

When logging into Solaris, be sure you choose CDE as the environment (on the login screen choose Options, then Session, then Common Desktop Environment)

Unix usernames are set to be the same as on Eaglenet but the passwords are saved in different places.

 


Login, passwords and logout

Access to the Sun workstations can also be done from a terminal session on a PC (using any telnet application such as putty).  You want to typically use a VT100 style emulator.  This is not a graphical interface--it is purely text.

The general command from any PC command line is

C:\> telnet workstation

Your login name/account is set up to be the same as on the Eaglenet.

A password prompt should not appear the first time you log in. You will have to keep track of this separate password.

passwd is the command to set/change passwords.

logout is the command to terminate your Unix session.

Be careful: ^D (Ctrl-D) also can cause you to log out.

 

You may also use the PuTTY software for telnet or ftp access to the Unix machines from Windows. The URL for downloading is: http://www.chiark.greenend.org.uk/~sgtatham/putty/

 


Special keys for use in a terminal session

There are a number of ctrl-key combinations that you should be familiar with. The first three are the most important.

Key combination Purpose
Ctrl-D End of input (logout)
Ctrl-C Interrupt; stop, cancel current program
Ctrl-Z Suspend current program (you probably want Ctrl-C)
Ctrl-S Stop screen scrolling
Ctrl-Q Resume screen scrolling
Ctrl-H Backspace
Ctrl-J Linefeed
Ctrl-L Pagefeed
Ctrl-R Redisplay the current command line

 

 


Unix system shell

You normally will work in a terminal window for this course.  The terminal window runs a "shell".

The "shell" is the command interpreter part of Unix which repeatedly carries out the following actions:

  1. print prompt
  2. read command
  3. transform command
  4. execute command
  5. repeat steps 1-4 until logout.

The shell itself is a command: csh

Other shells exist. sh is the original Unix shell. ksh is the Korn shell. bash is a shell found on Linux.

 Unless you are familiar with other shells, it is recommended to use csh as your shell for this course.

 

 

 

 

 


Commands and command syntax



  command [-switch-option ... ] [argument-list ... ] 

Commands are simply file names (executable);
options are typically prefixed with a hyphen;
arguments are often filenames

The "[ ]" mean the contents are an optional part of the command and "..." mean that more than one of the items can occur.

The command, options and arguments are separated by spaces.

Examples:

ls 
list directory contents; filenames only
ls -l 
list directory "long"; give details
ls -a 
list directory "all"; list hidden files that start with .
ls -F 
list directory contents; flag different file types
ls -l filename_with_wildcards 
ls -l *.java
list files that match the pattern
who 
show who is logged on to the workstation (not across the network or other workstations)
cat filename 
type out the contents of filename
mailx username 
construct a mail message to the user or email address
man command 
"manual" reference for command; this is the Unix help command
ps [-el]
show processes -e=all -l=long details

 

 


Aliases and start up command files

Aliases can be used to define alternate names for commands.

.cshrc is the standard file to define aliases if you're running csh. 

A .login file exists and is executed upon login if csh is your default shell.  A .profile file can serve similar purposes for other shells (sh or ksh). 

The .cshrc file is executed every time you start a csh shell, which may occur more than once in a log in session. For example you may use the workstation console to have several csh windows up at once.

 

 

 

 

 


Lab Exercises

  1. Logon into a Sun workstation.
  2. Check the files already in your directory using ls -a and then using ls -la
  3. Set an alias for lf , as above.
  4. Check the files in your directory using your new alias lf .
  5. List the files in the directory /academic/cs2, using lf .
  6. copy the file TestPrint.txt from the /academic/cs2 directory to your current directory, using the cp command.
  7. Print the file which you just copied, TestPrint.txt , to the C102 laser printer, using the lp command.
  8. Send e-mail (remember, this will only go to a Unix account) to the instructor (kruse) with the following information (you finish your email with a line containing only a period):
  1. Log out of the Sun workstation.
  2. Open a command prompt (DOS window) on your Windows machine. Set the prompt to your U: drive if it doesn't put you there by default.
  3. Pick a Sun workstation to perform file transfers with, and initiate this with the command ftp 'Sun machine name'
  4. Type an ls at the ftp> prompt. What files do you see?
  5. Ftp the file TestPrint.txt from your top-level directory on Unix to your U: drive with the command get TestPrint.txt.
  6. Type quit at the ftp> prompt to exit
  7. Use File Manager or Windows Explorer to find and confirm that TestPrint.txt is on your U: drive.
  8. Use PuTTY to log into a Sun Workstation. You may choose either the telnet or ssh option while logging in.