Introduction to UNIX

Lab 1
CSCI 112


Goals:

Overview the basic organization of UNIX.

Introduce several basic UNIX commands.


Getting your computer account

In order to log on to the computers in the 112 lab, you must have an ecst (Engineering College) account

This is different than the university account (often called a Wildcat account, or University Portal account).

You can get a ecst account by going to the system administrator's (Elbert Chan) office hours:  OCNL 249 Monday - Friday 3:30 - 5:00.  You will need your student ID.


Lecture Notes:
Unix Overview

Kernel
Shell  (csh, tsh, ksh, bsh, bash)
X-windows

Unix Command structure

$ ls    shell looks for an executable in the special collection of directories for executable ls

$ ls  -F     options are specified with a “-“

$ ls > filename   output can be redirected to a file

$ cat < filename  input can be redirected from a file

$ cat < filename > filename

Pipes

output of one program can be sent to another program

$ ls | more

File wildcard characters

*  any string of zero or more characters
?  match any single character
[]  match any of the characters in the []

-->expansion of wildcard characters is done by the shell

Note: the *, and [] are borrowed from a general method of specifying a set of words called regular expressions.

Exaples:  


$ ls *.cpp           list all files that have the extension ".cpp"
$ ls [ab]*.cpp     list all files that start with an "a" or a "b" and have the extension ".cpp"

Common UNIX commands

cd
    change directory, ~ is used to mean your home directory, .. is used to mean the parent of current directory

$ cd                 change to your home directory
$ cd  ~user      change to specified user's home directory   (e.g.   $ cd ~tyson)
$ cd ..              change to the parent of the current directory (the directory above the current directory)
$ cd  112         if "112" is a sub-directory of the current directory, change to it
 
ls
    list the files in the current directory

pwd
    show the current directory (called the path)

mkdir
    make a new directory

$ mkdir 112        make a new directory in the current directory called "112"
$ mkdir ~/112    make a new directory in your home directory called "112"

chmod
    change the protection (access) of a file or directory

rm
    delete a file
    rm -r allows you to delete a directory and everything in it

cp
    copy a file

man       
    show the manual page for a command
          $ man cp

   the -k option searches for keywords in all man pages (useful if you forget the name of a command)
          $ man -k copy
    usually this produces too many matches and they scroll by too fast to read

           $ man -k copy | less

which
          tells you which executable is executed when you type a command
          $ which cp

^C
kill the current process

^D
End of input (end of file) character
When you want to tell a program you are done entering input, type ^D

Keep learning  Don’t get stuck in a rut!


Some useful links:

An overview of the UNIX operating system from Bell Labs

A Basic UNIX Tutorial

UNIX Tutorial for Beginners