CIS 14A - Operating Systems (UNIX) - PowerPoint PPT Presentation

1 / 150
About This Presentation
Title:

CIS 14A - Operating Systems (UNIX)

Description:

Title: No Slide Title Author: Markus Geissler Last modified by: LDC Created Date: 6/10/1998 2:55:40 AM Document presentation format: On-screen Show – PowerPoint PPT presentation

Number of Views:269
Avg rating:3.0/5.0
Slides: 151
Provided by: MarkusG3
Category:

less

Transcript and Presenter's Notes

Title: CIS 14A - Operating Systems (UNIX)


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

2
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

3
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

4
Experience
  • - Electronic Engineer, 95 -96
  • Tinker Air Force Base
  • B-2 Stealth Bomber
  • - Software Engineer, 96 - 98
  • McClellan Air Force Base
  • A-10 aircraft

5
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

6
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

7
Office Hours
  • None
  • E-mail nghiep_nguyen_at_yahoo.com
  • Work nghiep.nguyen_at_lc.ca.gov
  • Web site http//www.geocities.com/nghiep_nguyen

8
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

9
Reverse Flows of Knowledge
  • Examinations
  • Hands-on in Classroom
  • One make-up exam per person at the instructors
    convenience
  • No more than 90 possible on makeup exams
  • Homework projects

10
Other Resources
  • UNIX Utility Program Reference
  • Back of textbook (starting on p. 521)

11
Things You Should Know Before Starting This Course
  • A basic understanding of the components of a
    computer system
  • CIS 1

12
UNIX
  • What exactly is UNIX?
  • Computer Operating System
  • large set of utility programs
  • general user
  • programmer
  • communication
  • administrative commands

13
Operating System
  • DefinitionAn operating system (OS) is a set of
    instructions that manages all computer operations
    and provides an interface between user(s) and
    system resources.

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

15
What Can UNIX Do For You?
  • General user applications
  • Programming environment
  • Typesetting tasks
  • Communication applications
  • Administration commands

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

17
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

18
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

19
Storage
  • Hard disk
  • Installed inside computers 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

20
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

21
UNIX Facts
  • Created in 1969
  • by Kent Thompson
  • Based on C language
  • ATT (Bell Labs) shared UNIX with colleges and
    universities
  • Colleges made enhancements
  • Berkeley Software Distribution (BSD)
  • See Introduction to UNIX
  • by Fiamingo, DeBula and Condron

22
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

23
Major UNIX Components
  • Kernel
  • Shell
  • File System

24
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

25
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

26
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

27
Shell History
  • Bourn -- Steve Bourne at ATT 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 ATT Bell Labs
  • faster than C shell, will run Bourne Script

28
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

29
File System Structure
  • Root (/)
  • /etc system administration files
  • /usr executable commands, s.a. utilities
  • /opt third-party software
  • /export/home or /home users home directory

30
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

31
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

32
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

33
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

34
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

35
Network
  • Connects computers to enable communication
    between users on multiple systems

36
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

37
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

38
Logging into CRCs LAN
  • Login name
  • First four letters of your last name
  • Last four digits of student ID number
  • Initial password new2lan
  • Change password right away

39
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

40
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

41
Accessing CRCs UNIX Box
  • From Windows 95 or Windows NT
  • Connect to Internet via your ISP
  • Start, Run
  • TELNET 165.196.137.125orTELNET
    cosumn.crc.losrios.cc.ca.us

42
User Account
  • Required for user login
  • Identifies user to the system
  • Contains essential user account info
  • Special environment settings for user
  • Mail file

43
Logging into CRCs UNIX Box
  • Log into system
  • Initial username is same as for CRCs 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

44
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

45
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

46
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

47
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

48
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

49
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

50
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

51
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

52
Commands
  • passwd
  • ls
  • cd
  • pwd
  • cp
  • rm
  • mv

53
Commands
  • cat
  • more
  • man
  • mkdir
  • rmdir
  • date
  • echo

54
Commands
  • cal
  • head
  • tail
  • wc
  • grep
  • find

55
Commands
  • cd directory_name
  • pwd
  • ls -aFlRt pathname
  • man command

56
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-direc
    tories and their corresponding files

57
Commands
  • ls -F will display the following symbols next the
    listing of files
  • / for directory
  • executable file, shell script
  • _at_ symbolic link
  • none text file (ASCII)

58
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.

59
Commands
  • grep -- search for a pattern in a file or files

60
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!

61
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

62
Directory Structure
/
/dev
/usr
/bin
/home
/cis14a
/user A
/user B
/home
63
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, typecd home

64
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

65
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

66
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

67
The ls Command
  • List the contents of current directory
  • Type ls at prompt
  • Directory entry types
  • - (hyphen) for file
  • d for directory

68
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

69
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

70
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 systems item number for each
    directory entry

71
More ls Command Options
  • ls directory name lists contents of other
    directory

72
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

73
UNIX Filenames
  • At least one character long
  • Maximum length 255 characters
  • Case-sensitive!
  • Uppercase and lowercase characters are distinct
  • Unlike DOS or Windows 9x

74
Special Characters in UNIX
  • Filenames cannot contain certain special
    characters
  • Special meaning to the shell
  • Examples
  • ? ( ) lt gt / \
  • see p. 38 in Sobell textbook for list

75
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 ?he
  • Returns ah123e, bhe, 1h23e, etc.
  • Example ls taeiou1-3p
  • Returns tap, tep, tip, top, tup, t1p, t2p, t3p

76
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

77
Clearing the Screen
  • Use clear or cls command to clear screen
  • Clears screen buffer
  • prompt only will appear at top of screen

78
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

79
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

80
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

81
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

82
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

83
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

84
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 (shiftcolon keys)

85
Accessing vis 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

86
Accessing vis Last-Line Mode
  • From command mode, press (colon)
  • Necessary to save file and exit vi

87
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

88
More vi Cursor Movements
  • Command mode
  • w moves to next word
  • moves to end of line
  • G moves to last line
  • Many more...

89
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

90
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

91
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)

92
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

93
Searching File Contents
  • Access vis command mode
  • /string finds next occurrence of string
  • /string searches for string at the beginning
    of a line
  • /\gtstring searches for string at end of word
  • More examples on p. 197 of textbook

94
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

95
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

96
File Management Summary
  • Copying
  • Renaming
  • Moving

97
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

98
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!

99
Copying Multiple Files
  • Example cp test test.out w3
  • Copies files test and test.out to w3 directory
  • w3 directory must exist

100
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

101
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

102
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

103
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

104
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

105
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

106
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

107
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

108
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

109
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

110
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

111
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

112
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

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

114
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

115
File Structure
  • Absolute and Relative Paths
  • Commands that work with directory
  • Change or go
  • create, delete
  • rename
  • copy
  • empty, or non-empty

116
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

117
File Structure
  • File or Directory Permission
  • r read from the file
  • w write to the file
  • x execute the file
  • ls -l

118
File Structure
  • chmod mode filename
  • mode
  • who
  • op
  • permission
  • File owner or root can change permission of a file

119
File Structure
  • Symbolic
  • chmod ux,gw,or
  • Numberic
  • r 4
  • w 2
  • x 1
  • rwx7
  • rw-6

120
File Structure
  • Links
  • ln -- link command
  • ln associate_file destination
  • hard link
  • soft link
  • ls -i

121
File Structure
  • Question
  • ????
  • BREAK

122
Redirection
  • Standard Input
  • Standard Output
  • Redirect Output
  • cat gt test
  • cntl-d to end
  • Redirect Input
  • command arg lt filename

123
Redirection
  • Appending
  • Use command gtgt
  • Examples

124
Pipes
  • command_a arg command_b arg
  • command_a gt temp
  • command_b lt temp
  • rm temp
  • Examples

125
Filter
  • Processes an input stream of data to produce an
    output stream of data
  • who sort lp
  • who tee test grep user

126
Metacharacters
  • ?
  • ,,,
  • ...

127
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)

128
File Permissions vs. Directory Permissions
  • Permission File Directory
  • Read r display/ list content copy
  • Write w modify files add/delete
  • Execute x execute control directory access

129
Default Permissions
  • Default permissions after creation

130
The chmod Command
  • Change permissions
  • Syntax chmod opcode filename
  • Example chmod uw test
  • Gives you permission to write to file test
  • Does not influence existing permissions
  • Example chmod gr test
  • Gives your group permission to read file test
  • Does not influence existing permissions

131
chmod Permission Categories
  • u - user
  • g - group
  • o - others (world)
  • a - all

132
Taking Permissions Away
  • chmod g-x
  • Takes execute permission away from group
  • Does not change r and w permissions

133
Absolute Permissions
  • chmod ox
  • Assigns execute permission to others
  • Example chmod ax test
  • Sets permissions to execute ONLY
  • r and w permissions are eliminated

134
Setting Permissions Using Symbolic vs. Numeric
Mode
  • Symbolic mode
  • rwx rwx rwx
  • Example chmod ur test
  • Numeric mode
  • 421 421 421
  • Example chmod 700 text
  • Possible to set absolute permissions only

135
Redirecting Screen Output
  • Prevent output from echoing to screen
  • Is sent to file/printer instead
  • Example ls gt test.out
  • Sends ls listing to file test.out
  • Caution Existing file will be overwritten
    without warning!
  • Use gtgt option to append existing file
  • Example ls gtgt test.out

136
Capturing Keystrokes
  • Record keystrokes
  • Use cat command
  • Syntax cat gt filename
  • Type text to capture to file
  • Press Ctrl-D to stop capturing and write to
    specified file
  • Example cat gt test.out

137
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

138
Communicating in UNIX
  • Real-time communication
  • write
  • talk
  • E-mail communication
  • mailx

139
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

140
The talk Command
  • Similar to write command
  • Divides user screen into two windows
  • Statements displayed in opposite window on other
    end of communication

141
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 lt message.fil
  • Sends file message.fil to user geisslm

142
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

143
Mail Message Listing
  • Message type
  • N - new message
  • R - read message
  • O - old message
  • Sender
  • Date and time
  • Size
  • Subject

144
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 lt test.doc
  • Sends file test.doc to user geisslm with subject
    E-mail test

145
More About mailx
  • Replying
  • r replies to all recipients of original message
  • R replies to sender of message ONLY

146
Exiting mailx Input Mode
  • quit command processes messages
  • exit command leaves mailbox untouched

147
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

148
Alias Advantages
  • Issue multiple commands through one alias
  • Example alias homeclearcdpwdls
  • Clears the screen, changes to home directory,
    displays current directory and its contents
  • Rename UNIX commands to DOS commands
  • Example alias dirls -l
  • Possible to issue DOS-like dir command to view
    contents of current directory

149
Removing Aliases
  • Use unalias command to remove alias(es)
  • Example unalias test
  • Removes test alias in current session

150
Thats All, Folks!
  • Course Review
  • Final Exam
Write a Comment
User Comments (0)
About PowerShow.com