Upload
sammy17
View
129
Download
6
Tags:
Embed Size (px)
DESCRIPTION
Citation preview
Title Slide
CSS 404/504
Internet Concepts
The UNIX Operating System (1)
By
Ralph B. Bisland, Jr.
2Internet Concepts Copyright Ralph Bisland 2004
The UNIX Operating System• Developed from the Multics Operating
System project• Developed at Bell Labs in 1969
(Originally called Unics)• UNIX commands are text based
(command interpreter)• Windows version of UNIX: X-Windows
3Internet Concepts Copyright Ralph Bisland 2004
Versions Of UNIX• Called shells
– C-Shell (csh) – TC Shell (tcsh) – Korn Shell (ksh) – Z shell (zsh) (what I use)– Borne Shell (bsh)– Borne Again Shell (bash) (USM CS
Default)
4Internet Concepts Copyright Ralph Bisland 2004
Why Learn UNIX
• Most Internet Service Providers (ISPs) utilize the UNIX Operating System
• Some ISPs use GUI interfaces - limit what you can do
• UNIX Operating systems have communications software built into their software.
5Internet Concepts Copyright Ralph Bisland 2004
UNIX Basics• UNIX commands are very cryptic (Often
2 letters)• The case of UNIX commands is very
important!!!!!!!!– ls LS Ls
• UNIX commands are usually entered in lowercase
6Internet Concepts Copyright Ralph Bisland 2004
Command Parameters• UNIX commands may have parameters
• Parameters are uused to specify options to commands
• Case is important here too• Parameters are preceded by a dash• Multiple parameters may be grouped together
or specified separately• Multiple parameters may be placed in any order
the user desires• Examples
– ls -a– ls -al– ls -la
7Internet Concepts Copyright Ralph Bisland 2004
UNIX Basics (ctd)• The UNIX prompt differs with each shell
• Z-Shell default prompt is: orca:~%– This may be altered
• UNIX is not MS-DOS, Windows, or Macintosh OS X
• Since MS-DOS "borrowed" some concepts from UNIX, some UNIX concepts are very similar to MS-DOS
8Internet Concepts Copyright Ralph Bisland 2004
Connecting to Orca• For security reasons this must be done
through secure shell (ssh) and not telnet.• To get a free ssh client program enter ssh
client (or ssh macintosh) into a search engine.• You also try Putty (win32 client)• Click on the Secure Shell icon to start it up.• Click on “Quick connect” to connect to orca.
9Internet Concepts Copyright Ralph Bisland 2004
Login Names & Passwords• To connect to a UNIX based computer
system two things are needed:– Login name (login ID)– Password
10Internet Concepts Copyright Ralph Bisland 2004
Login Names• General rules:
– 6-8 characters– digits– Can contain special characters such as -, _,
and .– Case sensitive
• This is assigned by the system administrator and can not be changed.
• This becomes your E-mail [email protected]
11Internet Concepts Copyright Ralph Bisland 2004
Passwords• General rules:
– At least 6 characters, at least 2 must be non-lowercase letters
• Passwords should be kept confidential.• Do not use simple names, dates, etc. as
passwords.• Use a sentence to create your password.• Example: I
am a Computer Science majorIaaCSm
12Internet Concepts Copyright Ralph Bisland 2004
Changing Passwords• To change your password, use the password
command (passwd)• Format: passwd NOTE: This will not work on the
ocean system• Example:orca% passwdEnter login (LDAP) password:New UNIX password:Retype new UNIX password:orca%
• Note that for security reasons the passwords are not echoed
13Internet Concepts Copyright Ralph Bisland 2004
Disconnecting from OrcaTo disconnect from orca, enter any of the
following commands: (well most probably)logout (This one works all the time)exitbyelo (works for me)
Remember that case is important when entering the commands!!!!
After doing this you also have to exit the ssh client.
14Internet Concepts Copyright Ralph Bisland 2004
UNIX Files• A file is a collection of data that is
stored on some secondary storage device.
• UNIX file names have no maximum storage limit.
• UNIX file are where the HTML commands for creating web pages are stored.
15Internet Concepts Copyright Ralph Bisland 2004
UNIX File Naming Conventions• Limited to 64 characters
• May contain special characters (except blank, / and possibly a leading -)
• Files that begin with a period (called a dot) have special meanings
• Case of letters is important. my-file MY-FILE My-File• Convention calls for a file extension to be appended
to each file name.• Place a period after the file name and add the
extensionmy-file.dat
16Internet Concepts Copyright Ralph Bisland 2004
UNIX Directories Directories/subdirectories are used to
segregate files On PC/Macs these are called folders The UNIX directory system forms a tree or
hierarchical structure The top directory of the tree is called the
root Each user has a home directory (which is a
subdirectory of root)• The user's home directory is the user's login
name
17Internet Concepts Copyright Ralph Bisland 2004
UNIX Directories
Root
Bisland Gregg Rimes
Not exact but close enough for now
18Internet Concepts Copyright Ralph Bisland 2004
Directory Notes• You may currently "reside" in only one
directory/subdirectory at a time.• Once you transfer from one directory to
another, you leave the first one and enter the second one.
• The directory/subdirectory that you currently reside in is called your "current working directory" (cwd) or "working directory“.
19Internet Concepts Copyright Ralph Bisland 2004
Orca’s Directory Structure• Orca’s directory system is configured its UNIX
directories as follows:/logical-computer-name/group-name/login-name
(slashes separate subdirectories)• Where
– logical-computer-name: Logical name of the computing systems
– group-name: Logical group name that the user falls into. Probably faculty, student, many others
– login-name: User's login name• Example:/orca/faculty/bisland
20Internet Concepts Copyright Ralph Bisland 2004
Orca’s Directory Structureorca
Faculty Students Staff others
Bisland Gregg
Internet Database SE-Eng
T-Hunts Tests
21Internet Concepts Copyright Ralph Bisland 2004
Creation Of Subdirectories• To create a subdirectory, use the make
directory (mkdir) command• Format: mkdir subdirectory-name• Example: orca% mkdir internet-course
• The command creates a subdirectory in your working current directory
22Internet Concepts Copyright Ralph Bisland 2004
Moving To Subdirectories• To make a subdirectory your current working
directory, use the change directory (cd) command.
• Format: cd subdirectory-name• Example:
orca% cd internet-course• Use the cd command by itself move back to
your home directory from any subdirectory.
23Internet Concepts Copyright Ralph Bisland 2004
Moving To Subdirectories (ctd)
• Every directory contains two files called . (dot) and .. (dot dot)– . => Name of the current working directory– .. => Name of the superdirectory of the current
working directory• To move back up one level, use the
command cd ..$ cd ..
24Internet Concepts Copyright Ralph Bisland 2004
Files In Other Directories• To access a file in another directory, you
must specify the path to the file• The path may be specified in either of two
ways:– Absolute Path: The exact path to the file
relative to the computer’s home directory– Relative Path: Relative to the current
working directory
25Internet Concepts Copyright Ralph Bisland 2004
Relative Path NamesLocation of a file relative to the current working directory.
bisland
internet
grades
database
projects
Assume that the cwd is internet, the relative path to the file test1.dat in thesubdirectory grades is
grades/test1.dat
Note that a slash does not precede the first subdirectory name
26Internet Concepts Copyright Ralph Bisland 2004
Absolute Path NamesLocation of the file regardless of the current working directory
bisland
internet
grades
database
projects
Assume the cwd is database and we wanted to get to the file test1.dat in the grades subdirectory, the absolute path name is:
/orca/faculty/bisland/internet/grades/test1.dat
Note that absolute directory names are preceded by a slash
Note that the absolute path name includes the logical computer name followedby the group name, followed by the logon name (the home directory), followedby the subdirectories
27Internet Concepts Copyright Ralph Bisland 2004
The Tilde Symbol• The tilde symbol (~) can be used to get to a user's home
directory• UNIX uses it's internal files to find the specified home
directory• To get to the test1.dat file in the previous example, we
could specify the path:
/orca/faculty/bisland/internet/grades/test1.dat
or using the tilde notation we could access it with the following path:
~bisland/internet/grades/test1.dat
28Internet Concepts Copyright Ralph Bisland 2004
Where Am I?• To display the absolute path to your current
working directory use the print working directory (pwd) command.
• Format: pwd
• Example:
orca% pwdorca/faculty/bisland/internet
29Internet Concepts Copyright Ralph Bisland 2004
Removing Directories• Subdirectories can only be removed when they
are empty! • The only files they contain are . and ..
(Removal of files is discussed later)• To remove a directory, the cwd must be the parent
directory• To remove a subdirectory, use the remove directory
command (rmdir)• Format: rmdir subdirectory-name• Example:
orca % rmdir internet
30Internet Concepts Copyright Ralph Bisland 2004
Displaying A Directory• To display the names of the files in a directory
use the list command (ls)• Format: ls [-parameters]• Example 1: (list the names of the files in the cwd)
orca% ls • Example 2: (lists the names of the files in the
subdirectory internet-course)
orca% ls internet-course
31Internet Concepts Copyright Ralph Bisland 2004
Displaying A Directory (ctd)• Parameters:
– a: All files with a directory (including ones that begin with a period)
– F: Directories are displayed with a slash suffix and programs are displayed with an asterisk suffix
– l: Produces a long listing of each directory entry• Example 3: (produces a long list of
everything in cwd)
orca % ls -l
32Internet Concepts Copyright Ralph Bisland 2004
Displaying The Contents Of A File• There are several utility programs to list
the contents of a file available in UNIX– Catenate (cat): – More (more)– Less (less)– Head (head)– Tail (tail)
33Internet Concepts Copyright Ralph Bisland 2004
Catenate• Lists the contents of a file from top to
bottom.• If the file is too long to fit on a page, the
excess is scrolled off the top of the page.
• Good for listing small files. • Format: cat filename
orca% cat my-file.dat
34Internet Concepts Copyright Ralph Bisland 2004
More• Displays the first "page" of the file and
waits for instructions– Return Key = One new line is displayed– Space Bar = One new page is displayed– q = Quit the display
• Format: more filename
orca% more my-file.dat
35Internet Concepts Copyright Ralph Bisland 2004
Head & Tail
• The head and tail commands are used to display parts of a text file.
• You may optionally specify the number of lines to list.
• Default is 10 lines• Formats: head [-l] <filename> tail [-|+l] <filename> orca% head my-file.dat
orca% tail my-file.dat
orca% head -20 my-file.dat
orca% tail -20 my-file.dat
orca% tail +10 my-file.dat {list from line 10 to EOF}
36Internet Concepts Copyright Ralph Bisland 2004
UNIX Text Editors
• Text Editor: A program that allows the creation and editing of text files.
• This is what we will use to create the HTML files.• Similar to a word processor but without all the
features• Text Editors create lines of text
– Each line is terminated by an EOLN mark– Each file is terminated by an EOF mark
• No fancy editing features like a word processor– Word wrap– Boldface, centering, underlining, etc.
37Internet Concepts Copyright Ralph Bisland 2004
PICO
• PICO = PIne COmposer• Very simple text editor - can only be used on
text files (ASCII files).• Limited in what it can do (find and replace,
delete multiple lines, etc.)• Default editor on the orca system.• Some of the PICO commands are shown
across the bottom of the screen.• All PICO commands begin with a control key
(shown as ^letter).
38Internet Concepts Copyright Ralph Bisland 2004
PICO (ctd)• To enter the PICO Editor, enter the word
"pico", followed by a blank space, followed by the name of the file you wish to create/edit.
• orca % pico my-file.dat• The screen will clear and the PICO edit
window is now open.• Use the arrow keys to move the cursor
around.• Whatever you enter will be entered in the
text file.
39Internet Concepts Copyright Ralph Bisland 2004
List Of The PICO Commands
^G: Help on PICO. (F1)
^F: Move the cursor forward one character.^B: Move the cursor backward one character.^N: Move the cursor down (next) one line.^P: Move the cursor up (previous) line.^A: Move the cursor to the beginning of the current line.^E: Move the cursor to the end of the current line.^V: Move cursor forward a page. (F8)^Y: Move the cursor backward a page. (F7)
^W: Search for (where is) text neglecting case. (F6)^L: Refresh the display.
^D: Delete the character at the cursor^K: Delete (kill) the entire line at the current cursor position. (F9) Note: Consecutive deletes append lines to the buffer which subsequently undeletes will write at the current cursor position.
^U: Undelete the last line(s) deleted at the cursor. (F10)
^I: Insert a tab at the current cursor position.
40Internet Concepts Copyright Ralph Bisland 2004
List Of PICO Commands (ctd)^J: Format (justify) the current paragraph. (F4)
Note: Paragraphs delimited by blank lines or indentation
^T: Invoke the spelling checker. (F12)
^C: Report the current cursor position. (F11)
^R: Insert an external file at the current cursor position. (F5)
^O: Output the current buffer to a file. (F3)
^X: Exit pico, saving the contents of the buffer to a file. (F2)
41Internet Concepts Copyright Ralph Bisland 2004
Sample PICO Edit Session PICO 1.7 File: my-file.dat
[ New file ]^G Get Help ^O WriteOut ^R Read File^Y Prev Pg ^K Del Line ^C Cur Pos^X Exit ^J Justify ^W Where is ^V Next Pg ^U UnDel Lin^T To Spell
42Internet Concepts Copyright Ralph Bisland 2004
Deleting Files• To delete a file from the system, use the remove
command (rm)
• Format: rm filename
orca% rm my-file.dat
• You will probably be asked for confirmation when you remove a file.
orca% rm my-file.datrm: remove ‘my-file.dat’?
43Internet Concepts Copyright Ralph Bisland 2004
Wildcards
• In some file commands wild cards can be used to substitute for characters or character strings
Wildcard Meaning-------- --------------------------------------------- * Match any sequence of zero or more characters ? Match any single character [ ] Match one of the enclosed characters
• Note: The only character that can not be matched by a wildcard is the slash (/)
44Internet Concepts Copyright Ralph Bisland 2004
Wildcard Examplesorca% rm *.dat
orca% rm file*orca% rm ?.datorca% rm set[123].datorca% ls -l *.datorca% ls *.*orca% rm *
45Internet Concepts Copyright Ralph Bisland 2004
Renaming A File• To rename a file, use the move command (mv)
• Format: mv oldfile-name newfile-name• Example: orca% mv my-file.dat your-file.dat• Since a directory is in essence a file, directories
can be renamed via the mv command.• Format: mv old-directory-name new-directory-name orca% mv internet-course internet-stuff
46Internet Concepts Copyright Ralph Bisland 2004
Making A Duplicate Copy Of A File• To make a duplicate copy of a file, use the
copy command (cp)
• Format: cp old-file new-file
• Example:
orca% cp my-file.dat your-file.dat
47Internet Concepts Copyright Ralph Bisland 2004
Files In Different Directories• To move a file from one directory to another directory,
use the mv command• Format: mv <filename> <directory-name>• Example:
orca% mv my-file.dat internet-course
• To copy a file from one directory to another, use the cp command
• Format: cp <filename> <directory-name>
orca% cp my-file.dat internet-course
48Internet Concepts Copyright Ralph Bisland 2004
History• History allows you to retrieve previously entered
commands.• This only works on commands entered during the
current terminal session.• Once a command has been retrieved, it can be
executed and/or editted.• To retrieve previously entered commands use the
up arrow or the down arrow key.• To edit a command, use the backward or forward
key to position the cursor at the editing point, then enter character or delete characters.
49Internet Concepts Copyright Ralph Bisland 2004
Filename Completion• UNIX allows the user to enter enough character
of a filename to determine a unique file name, then completes the file name for you.
• To do this, enter enough characters for UNIX to identify the file name, then press the TAB key – UNIX completes the file name for you.
• This feature only works on file names, not commands.
50Internet Concepts Copyright Ralph Bisland 2004
Printing• Any text file may be printed on the laser
printer in JST 205 or TEC207• Caution: Only print text files on the
printer!!!• The command to print a text file is lpr.• Format: lpr <filename>• Example:
orca% lpr my-file.dat• To check on the status of the USM printers
use the lpstat command orca% lpstat