150
CIS 14A - Operating Systems (UNIX) Markus Geissler, MBA Nghiep Nguyen, MSEE

CIS 14A - Operating Systems (UNIX) Markus Geissler, MBA Nghiep Nguyen, MSEE

Embed Size (px)

Citation preview

CIS 14A - Operating Systems(UNIX)

Markus Geissler, MBA

Nghiep Nguyen, MSEE

About the Instructor...

Nghiep Nguyen, MSEE-Sacramento High School, 1983- AA in Math and Science

Sacramento City College, 1985-BS in Electrical Electronics Engineering

UC Davis, 1987

-MS in Electrical Electronics Engineering

CSUS, 1993

Experience

- Electronic Engineer, 87 - 90

Sacramento Army Depot

Write Test Program Sets for Unit Under Test for Tomahawk Computer.

- Software Engineer, 90 - 95

McClellan Air Force Base

Operational Flight Program for A-10

Experience

- Electronic Engineer, 95 -96

Tinker Air Force Base

B-2 Stealth Bomber

- Software Engineer, 96 - 98

McClellan Air Force Base

A-10 aircraft

Experience

- Associate Programmer 1/98 - 10/98

P.O.S.T: Work with PowerBuilder, SQL

- Associate Systems Software: 10 - 11/98

F.T.B: Sybase DBA

- Systems Software Specialist, 11/98 to Present

Legislative Data Center

Unix (Sun Solaris) System Administrator

Experience

Adjunct Faculty: 8/97 to Present

Cosumnes River College

Unix, Internet, HTML

Java, Visual Basic Visitor Lecturer: 8/02 – 6/03

California State University, Sacramento

Visual Basic, Java

Office Hours

None E-mail: [email protected] Work: [email protected] Web site: http://

www.geocities.com/nghiep_nguyen

Textbook(s)

Required– UNIX System V - A Practical Guide (Third

Edition)• by Mark G. Sobell• Addison-Wesley Publishing Company

Strongly recommended– CIS 14A Lecture Slides

• By Markus Geissler• Download from website

Reverse Flows of Knowledge

Examinations– Hands-on in Classroom – One make-up exam per person at the

instructor’s convenience • No more than 90% possible on makeup exams

Homework projects

Other Resources

UNIX Utility Program Reference– Back of textbook (starting on p. 521)

Things You Should Know Before Starting This Course A basic understanding of the

components of a computer system– CIS 1

UNIX

What exactly is UNIX?– Computer Operating System– large set of utility programs

• general user• programmer• communication• administrative commands

Operating System

Definition:An operating system (OS) is a set of instructions that manages all computer operations and provides an interface between user(s) and system resources.

UNIX

Computer operating system (OS)– Large set of utility programs– Based on C programming language– Used in enterprise networks

OperatingSystem

OperatingSystem

Disk DriveDisk Drive

MonitorMonitor

KeyboardKeyboard

MouseMouse

PrinterPrinter

ApplicationApplication

What Can UNIX Do For You?

General user applications Programming environment Typesetting tasks Communication applications Administration commands

The Inner Workings of a Computer - Summary Central Processing Unit Memory Storage I/O

Central Processing Unit (CPU)

“Brain” of the computer– Executes instructions from programs and

processes– Manufacturers include

• Intel• Advanced Micro Devices (AMD)• Cyrix• Motorola• Sun Microsystems

Memory

RAM (Random Access Memory)– Volatile

• Information disappears when electrical power to RAM is interrupted

• Capacity measured in Megabytes (MB)• Access speed measured in Nanoseconds (ns)

– Holds data before and after CPU processes them

• Program instructions• Application data

Storage

Hard disk– Installed inside computer’s case

Floppy/ZIP®/JAZ®/SyQuest® disks– Portable; require disk drive

Disks are typically non-volatile– Data called into memory when needed

• Capacity measured in Gigabytes (GB)

Magnetic Tape– Largely used for data backup

Input/Output (I/O)

Reads input from a device into memory– Keyboard– Mouse

Writes output from memory to devices– Monitor– Printer

Disk drives are input and output devices– long term storage devices

UNIX Facts

Created in 1969– by Kent Thompson

Based on C language AT&T (Bell Labs) shared UNIX with colleges

and universities– Colleges made enhancements– Berkeley Software Distribution (BSD)

See Introduction to UNIX– by Fiamingo, DeBula and Condron

Linux

Compact version of UNIX for PC– Created by Linus Thorvald

Not yet standardized– Supported by a large, active user

community Free versions available on the Internet

– approx. $50 for RedHat Linux

Major UNIX Components

Kernel Shell File System

KernelKernel

Shell & UtilitiesShell & Utilities

HardwareHardware

Kernel

Core of UNIX OS– Manages hardware, memory and file

system resources– Controls transmission of information

between user application and CPU– Stores information about the arrangement

of the computer system and the network

Shell

Interface between user and OS Korn shell

– Most robust features Bourne shell

– Subset of Korn shell C shell

– Not related to other two shells– Most widely used in SunOS

UNIX OS Components

Shell– Shell program are interpreted, not compiled

• commands are read and executed one by one• compiled program is read and converted to a

machine language then execute all at once• slower than compiled language such as C

Three types of Shells: Korn, Bourne, and C

Shell History

Bourn -- Steve Bourne at AT&T Bell Labs– Original UNIX shell -- compactness & speed– lack features for interactive use

C -- Bill Joy (SUNW)– friendly features for users– larger and slower than Bourne

Korn -- David Korn of AT&T Bell Labs– faster than C shell, will run Bourne Script

File System

Organizes data on disk in a hierarchical structure of directories

File– Program or data

Directory/folder– Similar to file drawer

• Each disk has root directory

Subdirectory– Directory/folder within other directory

File System Structure

Root (/)– /etc : system administration files– /usr : executable commands, s.a. utilities– /opt : third-party software– /export/home or /home : user’s home

directory

Multitasking OS

Used to approach 100% of computer resource utilization while increase user productivity– Reduced cost per user

• Time slicing

– Users can run multiple processes• Increases user productivity

UNIX refers to task as “process”– Usually maximum of 25 concurrent processes per

user session

Multi-User OS

Supports 1 - 2000 users– Users share system resources

To approach 100 percent in computer resource utilization while reducing the cost per user

Share system resources

Interactive Mode

Immediate response to keyboard or mouse input

“No news is good news”– Display returns shell prompt after

commands are issued• Different shells have different prompts

– Detailed feedback only when errors made

Networking Terms

Host - a computer system Host Name - a unique name for a system IP address - a number used by networking Network

– connects machines to enable comm. between users on other systems.

Server provides resources to one or more clients on the network

More Terms

Client is a machine that uses services from one or more servers on a network

NFS (Network File System) enables files to be shared across the network.

NIS (Network Information Services) enables system administration functions to be centralized on a server.

Client-Server

Network

Connects computers to enable communication between users on multiple systems

Clients vs. Servers

Server– Provides resources to one or more clients on

the network– Usually requires more powerful equipment than

clients Client

– Computer that uses services from one or more servers

Front end vs. back end

Set Up

User Account– must have it set up before a user can log in– contains essential user account info

• User name identifies a user to the system

– is created by System Administrator. Bring your class registration/schedule to

the computer lab. The lab assistant will set up the Unix account for you

Logging into CRC’s LAN

Login name– First four letters of your last name– Last four digits of student ID number

Initial password: new2lan– Change password right away

Password Security

Do not choose a password that can be related to you!

Use a password that does not resemble a word in the dictionary– Case sensitivity

Password Guidelines

No less than six characters Must contain at least two alphabetic

characters and at one numeric or special character– can have spaces, avoid special characters

Cannot be login name or reverse New password must differ from old

password by at least three characters

Accessing CRC’s UNIX Box

From Windows 95 or Windows NT– Connect to Internet via your ISP– Start, Run…– TELNET 165.196.137.125

orTELNET cosumn.crc.losrios.cc.ca.us

User Account

Required for user login Identifies user to the system Contains essential user account info

– Special environment settings for user– Mail file

Logging into CRC’s UNIX Box

Log into system– Initial username is same as for CRC’s LAN– Initial password: new2mini– Password will not display when typed– Connection times out if you take too long

Use exit command at the $ prompt to log out– Also possible to disconnect within TELNET

application

Entering UNIX Commands

Type commands with keyboard To correct a typing error, use Delete

key– NOT the Backspace key

Press Enter key to send command to kernel

Changing Your Password

Use passwd command at $ prompt to change your password– Type old password first– Type new password twice

• Password will not be displayed when typed• Password has to have at least one number in it• Suggestion: Use same password as LAN

account and add a number, if necessary

Getting Help in UNIX

Use man command Include command about which you want

help– man ls– Use man ls | more to display one page at a

time• “Pipe” character

– Use Ctrl-C to interrupt file display• If file is too long for one screen

Logging a TELNET Session

Record all activity within a session In TELNET utility

– Choose Terminal, Start Logging…• Specify filename to which to log

– Local drive– Network drive (U: drive in CRC lab)

» Up to 5 MB of space

– Choose Terminal, Stop Logging to stop writing to log file

The script Command

Logs commands entered and results displayed– If no filename specified, script logs to file

typescript Type exit to stop logging and close the

log file

Printing Log Files

Type lp filename to print to CRC lab FTP file to home computer and print to

local printer– Printing from DOS Editor may be easier

than from Notepad• Potential problems with line breaks• Turn off Word Wrap

UNIX Commands

Command line format– command [ - option(s) argument(s)]

Options modify the command Arguments tell the computer to what to

apply the command Example

– cd [directory_name]– ls [aFIR] [pathname]

Command Syntax

Command Line Format– command [option(s)] [argument(s)]– case sensitive– blank space does matter since it is the

delimiter for the shell– do not necessary require all three parts– 256 characters can be entered on a single

command line

Commands

passwd ls cd pwd cp rm mv

Commands

cat more man mkdir rmdir date echo

Commands

cal head tail wc grep find

Commands

cd [ directory_name] pwd ls [ -aFlRt] [pathname] man command

Commands

pwd -- present working directory cd -- change directory mkdir -- create a new directory ls -- diplays contents of your directory

– l -- stands for long information– F -- File type option– a -- display all files (including customization files)– R -- display recursively all directories/sub-

directories and their corresponding files

Commands

ls -F will display the following symbols next the listing of files:

/ for directory

* executable file, shell script

@ symbolic link

nonetext file (ASCII)

Commands

rmdir - remove directory head -n --- displays the first n lines tail -n -- displays the last n lines wc -- word count command to display

numbers of lines, words, characters diff -- to display the differences between

two files.

Commands

grep -- search for a pattern in a file or files

The cal Command

Displays a calendar on the screen Syntax: cal [ [month] year]

– Month from 1-12

– Year from 1 to 9999 (!) Example: cal 1999

– Displays the calendar for 1999

– Eastern and Western calendars were combined in 1752

• Check out September 1752!

The who Command

Lists current system users– Syntax: who– Example: who | sort -r

• Sorts users in reverse order

– Example: who | grep geisslm• Allows you to check whether or not user

geisslm is logged-in

– More details on examples later

Directory Structure

/

/dev /usr /bin/home

/cis14a

/user A /user B/home

Path

Absolute path– Type pwd at $ prompt

• Present working directory• /usr/cis14a/user B/home

– To change to directory, typecd /usr/cis14a/user B/home

Relative path– From /usr/cis14a/user B directory, type

cd home

File Path

absolute path -- Starts with / (stands for root directory) and go to where you want to go

relative path -- start from where you are and move to sub-directory or parent directory

The cd Command

Navigate directory structure Type cd .. at $ prompt to change to

parent directory– Directory above current directory

Type cd without attributes to change to home directory

Special Directory Names

. represents current directory .. represents parent directory

– “Above” current directory in directory tree Combine .. and “sibling” subdirectory

name to move to “sibling” subdirectory– To change from /usr/cis14a/user B

directory to /usr/cis14a/user A, typecd ../user A

The ls Command

List the contents of current directory Type ls at $ prompt Directory entry types

– - (hyphen) for file– d for directory

ls Command Options

Directory entry type User/group/other (world) permissions Number of links Owner name Owner group File size in bytes/blocks Date of file creation/last access Filename/directory name

ls Command Options

ls -l lists details about contents– Long version

ls -F shows slash (/) after directory name listing

ls -R lists contents of entire tree (including subdirectories)– Recursive

More ls Command Options

ls -r lists contents in reverse order ls -l (filenames) to list specific files ls -a displays all contents, including

hidden ls -s lists size of file/directory in blocks

– 1 block = 512 bytes ls -i displays system’s item number for

each directory entry

More ls Command Options

ls [directory name] lists contents of other directory

Combining ls Command Options

Possible to combine ls command options– ls -a -F is the same as– ls -aF

| more option– Say “pipe more”– Lists one screen at a time

• Example: ls -R |more

• More on “piping” later

UNIX Filenames

At least one character long– Maximum length: 255 characters

Case-sensitive!– Uppercase and lowercase characters are

distinct• Unlike DOS or Windows 9x

Special Characters in UNIX

Filenames cannot contain certain “special characters”– Special meaning to the shell

Examples– & ; | * ? ‘ “ ` [ ] ( ) $ < > { } ^ # / \– see p. 38 in Sobell textbook for list

UNIX Wildcards

Wildcards replace characters– * replaces zero, one or more characters– ? replaces one character– [ ] match one of the choices inside brackets– { } match each of the choices inside braces

Example: ls ?h*e– Returns ah123e, bhe, 1h23e, etc.

Example: ls t[aeiou1-3]p– Returns tap, tep, tip, top, tup, t1p, t2p, t3p

Creating a Directory

Type mkdir command at $ prompt– Example: mkdir reports

Possible to create multiple directories with one command– Use space as delimiter– Example: mkdir memos letters

Clearing the Screen

Use clear or cls command to clear screen– Clears screen buffer– $ prompt only will appear at top of screen

More mkdir Command Options

mkdir -p cis14a/hw1– Creates cis14a directory as well as hw1

subdirectory below cis14a directory Use -p option to create multiple

subdirectories at multiple levels at the same time– Example: mkdir -p cis14a/hw2 cis14b

The rmdir and rm Commands

Use rmdir to remove a directory– Current directory must be parent of directory

to be deleted unless absolute or other relative path is specified

If directory is not empty, use rm command– rm -r hw1 for recursive remove– rm -ir hw1 for interactive recursive remove

• System will prompt for confirmation

The cat and more Commands

cat [filename]– Displays contents of file

more [filename]– Displays contents of file in segments– Press Enter key to display one line at a time– Press Spacebar to display one screen at a

time Similar to pg [filename]

Ctrl Commands

Ctrl-c interrupts current activity Ctrl-u erases current command line Ctrl-w erases word in current command

line Ctrl-s stops scrolling screen output Ctrl-q restarts scrolling screen output Other commands can be customized for

user by administrator

The head and tail Commands

head [-n] filename– Displays top portion of file– head -5 hw1 displays first 5 lines of file

hw1 tail [-n] filename

– Displays bottom portion of file– tail -10 mbox displays last 10 lines of file

mbox

UNIX Editors

Use editor to create and edit files Several editors available

– vi - most commonly used– pico - not included in SVR4

• Not available at CRC

– emacs - not included in SVR4• Not available at CRC

Visual Editor (vi)

Type vi at $ prompt to start editor– vi [filename] to edit existing file (p. 212)

Three modes (p. 183)– Command mode

• Hit Esc key to access command mode

– Input (Text) mode– Last-line mode ([shift]&[colon] keys)

Accessing vi’s Insert Mode

From command prompt, press– i to insert text before cursor– I to insert text at beginning of line– a to append text after cursor– A to append text at end of line– o to open new line below cursor– O to open new line above cursor

• Page 214

Accessing vi’s Last-Line Mode

From command mode, press : (colon)– Necessary to save file and exit vi

vi Cursor Movements

Command mode– j or moves cursor down one line– k or moves cursor up one line– l or moves cursor to the right– h or moves cursor to the left– Ctrl-D moves down one half screen– Ctrl-U moves up one half screen– Ctrl-F moves forward one screen– Ctrl-B moves backward one screen

More vi Cursor Movements

Command mode– w moves to next word– $ moves to end of line– G moves to last line– Many more...

vi Commands

dd - delete one line to buffer ndd - delete n lines x - delete one character dw - delete one word to buffer d$ - delete to end of line to buffer d0 - delete to beginning of line to buffer

Command Mode

u -- undo a last command/change . -- do last change again Copy Text yy - yank a copy of a line to buffer nyy - yank a copy of n line to buffer yw - yank a copy of a word to buffer Past Text p -- put buffer after a cursor P -- put buffer before a cursor

Command Mode

cw -- change a word ncw -- change n words c$ -- change to end of a line r -- replace one character R -- replace the text (type over)

Last-Line Mode Commands

set showmode indicates Insert Mode or Command Mode– At bottom right of screen

set nu displays line numbers set nonu turns off line number display set list displays invisible characters set ic specifies that pattern search

should ignore case

Searching File Contents

Access vi’s command mode /[string] finds next occurrence of string

– /^[string] searches for string at the beginning of a line

– /\>[string] searches for string at end of word

• More examples on p. 197 of textbook

Last - line Mode

To turn off an option, put a “no” infront of the variable, i.e.,

set nu set nonu -- to turn it off Search for text /text -- go forward to the first occurence of text ?text -- go backward to previous occurence of

test

Moving and Deleting Lines

:3,8d deletes lines 3 to 8 :4,9m 12 moves lines 4-9 to line 12 :2,5t 13 copies lines 2-5 to line 13 :5,9w filename writes lines 5-9 to

filename

File Management Summary

Copying Renaming Moving

The cp Command

Create an exact copy of another file– With the same name in a different directory

• Possible to specify target directory only

– With a different name in the same directory Syntax: cp [source] … [target]

– Example: cp misc ./w1/misc• Copies file misc to subfolder w1 with the same

name

More About the cp Command

Example: cp w2/* w4– Copies all files from w2 directory to w4

directory– Does NOT copy subdirectories under w2

cp -r w2/* w4 also copies subdirectories– Recursive– Lowercase “R”!

Copying Multiple Files

Example: cp test test.out w3– Copies files test and test.out to w3

directory• w3 directory must exist

The mv Command

Moves and/or renames a file– Original file will disappear

• Different from cp command

Example: mv test exam– Renames file test to file exam

Example: mv exam w4– Moves file exam to directory w4

• w4 directory must exist

• mv command will not create it

Commands For Analyzing And Manipulating Files sort - sort file contents grep - search file for a pattern diff - point out differences between files comm - details file differences wc - counts words, lines and letters in file compress - reduce file size to conserve

disk space

The sort Command

Sort information within files and/or merge different files

Example: sort [filename]– Sorts [filename] alphabetically by first word

Example: sort -f +2 [filename]– Sorts [filename] alphabetically by third

word while ignoring case-sensitivity

The grep Command

Global regular expression pattern Find text patterns in files Syntax: grep [options] pattern [filelist] Example: grep echo test1

– Finds pattern echo in file test1 and displays lines matching pattern

More grep Command Examples

Example: grep -c echo test1– Displays line count of lines matching

pattern Example: grep -l echo

– Displays name of file that contains one or more matches

The diff Command

Shows lines that are different between two files

Syntax: diff [filename1] [filename2] Example: diff t1 t2

– Lists line and column number– Lists different text patterns

The comm Command

Displays line-by-line comparison of sorted files– Files must be sorted!

Syntax: comm [filename] [filename] … Example: comm file1 file2

– Results displayed in three columns• file1 unique text patterns

• file2 unique text patterns

• common text patterns

The wc Command

“Word Count” Display number of

– Lines– Words– Characters

Syntax: wc [options] [file-list] Example: wc -lw memo

– Displays the number of lines and words contained in the file memo

The compress Command

Compresses files to reduce amount of space required on disk– Similar to ZIP utility in DOS/Windows– Compressed file cannot be viewed/executed until

decompressed Syntax: compress [filename]

– Results in file filename.Z Example: compress -v text

– -v option displays compression ratio

Limiting Access to Resources

Use permissions– Not available in DOS

• Usually available only on network operating systems (NOS)

Who can change permissions?– Owner of file or directory– Administrator

Cis-14A: Misc

Printing – lp (after using script command)– File Transfer Protocol (FTP)

• Open Dos Command window• ftp 165.196.137.125 to log in

– Telnet Preference menu• Name your file, and location• start logging, do work, and stop logging• Use word processor to print your file

Cis-14A: Misc

Turn in assignments 1 and 2 File Structure

– Tree structure– Directory, and Files– File names

• Extension

– Absolute and Relative Path– cd, mkdir, rmdir, rm, cp, mv

Midterm 1

File Structure

Pyramid structure, inverted tree Each directory -- a subject

– a folder– can be divided into smaller directories for

more clarity or easy to use– sub-directory(ies) and/or file(s)– the end of a path

File Structure

File Name– 14 chars, some has up to 255 chars– A-Z, a-z– 0 - 9– underscore (_)– period (.)– comma(,)

File Structure

Filename Extension– usually after period (filename.ext)– can use more than one period– meaningful

• .ext, .c, .txt, .990206

– Invisible Filename• start with a period (.filename)• ls -a

File Structure

Absolute and Relative Paths Commands that work with directory

– Change or go– create, delete– rename– copy– empty, or non-empty

File Structure

Standard Unix Directories : / -- root– /home, /export/home– /usr -- system information

• /usr/bin• /usr/sbin

– /etc– /var -- files that vary as system runs– /tmp– /dev

File Structure

File or Directory Permission– r read from the file– w write to the file– x execute the file

ls -l

File Structure

chmod mode filename– mode

• who• op• permission

File owner or root can change permission of a file

File Structure

Symbolic– chmod u+x,g+w,o+r

Numberic– r = 4– w = 2– x = 1

• rwx=7• rw-=6

File Structure

Links– ln -- link command – ln associate_file destination– hard link– soft link– ls -i

File Structure

Question

????

BREAK

Redirection

Standard Input Standard Output Redirect Output

– cat > test– cntl-d to end

Redirect Input– command [arg] < filename

Redirection

Appending– Use command >>

Examples

Pipes

command_a [arg] | command_b [arg] command_a > temp command_b < temp rm temp Examples

Filter

Processes an input stream of data to produce an output stream of data– who | sort | lp– who | tee test | grep user

Metacharacters

* ? [,,,] {...}

UNIX/NFS Permissions

NFS file permissions– Read (r)– Write (w)– Execute (x)

Permissions listed in sequence of– User– Group– World (all other users on system)

File Permissions vs. Directory Permissions

Permission File Directory

Read r display/ list contentcopy

Write w modify files add/delete

Execute x execute control directory

access

Default Permissions

Default permissions after creation

rw-r--r--rw-r--r--File:

rwxr-xr-xrwxr-xr-xDirectory:

The chmod Command

Change permissions– Syntax: chmod opcode filename

Example: chmod u+w test– Gives you permission to write to file test– Does not influence existing permissions

Example: chmod g+r test– Gives your group permission to read file test– Does not influence existing permissions

chmod Permission Categories

u - user g - group o - others (world) a - all

Taking Permissions Away

chmod g-x– Takes execute permission away from

group– Does not change r and w permissions

Absolute Permissions

chmod o=x– Assigns execute permission to others

Example: chmod a=x test– Sets permissions to execute ONLY– r and w permissions are eliminated

Setting Permissions Using Symbolic vs. Numeric Mode Symbolic mode

– rwx rwx rwx– Example: chmod u+r test

Numeric mode– 421 421 421– Example: chmod 700 text

• Possible to set absolute permissions only

Redirecting Screen Output

Prevent output from echoing to screen– Is sent to file/printer instead– Example: ls > test.out

• Sends ls listing to file test.out

Caution: Existing file will be overwritten without warning!– Use >> option to append existing file– Example: ls >> test.out

Capturing Keystrokes

Record keystrokes– Use cat command– Syntax: cat > filename

• Type text to capture to file• Press Ctrl-D to stop capturing and write to

specified file

– Example: cat > test.out

Piping

Use the | (pipe) character– Modifies or redirects previous command in line– Example: man ls | more

• Displays help for the ls command one screenful at a time

– Example: who | sort | lp• Sends a sorted list of currently logged-in users to the

printer• Note: lp command must be last command

Communicating in UNIX

Real-time communication– write– talk

E-mail communication– mailx

The write Command

Send instant message to other user on UNIX system– Similar to “chatting”– Recipient must permit messaging

• Type mesg y at $ prompt

– Example: write geisslm• Opens write session with user geisslm

• End conversation with “oo” (over and out)

• Press Ctrl-C to end transmission

The talk Command

Similar to write command– Divides user screen into two windows– Statements displayed in opposite window

on other end of communication

My “talking” appears here

Your “talking” appears here

The mailx Command

Send electronic mail from UNIX system– Syntax: mailx [username]

• Type subject line• Type message• Press Ctrl-D to send message

– Example: mailx geisslm• Type subject line and message

– Example: mailx geisslm < message.fil• Sends file message.fil to user geisslm

Using mailx Interactively

Many options available– Type ? at ? prompt to view list of available

options– Example: t 2

• Types second message on screen

– Example: delete 3 (or d 3)• Deletes message number 3 from message list

– Example: h• Displays list of message headers

Mail Message Listing

Message type– N - new message– R - read message– O - old message

Sender Date and time Size Subject

Changing Message Options

Possible to change options while typing message text– Use ~ (tilde) character options

• Be sure to specify option after issuing command• Otherwise information may be missing

Specify in mailx command line– mailx -s “E-mail test” geisslm < test.doc

• Sends file test.doc to user geisslm with subject “E-mail test”

More About mailx

Replying– r replies to all recipients of original

message– R replies to sender of message ONLY

Exiting mailx Input Mode

quit command processes messages exit command leaves mailbox

“untouched”

Aliasing

Alias– For one username– For multiple usernames

• Distribution list

– Example: alias entry in .mailrc file• .mailrc is UNIX customization file• Entry: alias users user1 user2

– Mail sent to alias users is forwarded to user1 and user2

– Create current-session alias at $ prompt

Alias Advantages

Issue multiple commands through one alias– Example: alias home=‘clear;cd;pwd;ls’

• Clears the screen, changes to home directory, displays current directory and its contents

“Rename” UNIX commands to DOS commands– Example: alias dir=‘ls -l’

• Possible to issue DOS-like dir command to view contents of current directory

Removing Aliases

Use unalias command to remove alias(es)– Example: unalias test

• Removes test alias in current session

That’s All, Folks!

Course Review Final Exam