CSC – 332 Data Structures Generics Analysis of Algorithms Dr. Curry Guinn.
CSC 332 Data Structures Unix and Vi Dr. Curry Guinn.
-
Upload
eustacia-barker -
Category
Documents
-
view
217 -
download
0
description
Transcript of CSC 332 Data Structures Unix and Vi Dr. Curry Guinn.
![Page 1: CSC 332 Data Structures Unix and Vi Dr. Curry Guinn.](https://reader035.fdocuments.us/reader035/viewer/2022062909/5a4d1bb27f8b9ab0599cd2a1/html5/thumbnails/1.jpg)
CSC – 332 Data StructuresUnix and Vi
Dr. Curry Guinn
![Page 2: CSC 332 Data Structures Unix and Vi Dr. Curry Guinn.](https://reader035.fdocuments.us/reader035/viewer/2022062909/5a4d1bb27f8b9ab0599cd2a1/html5/thumbnails/2.jpg)
Quick Info
• Dr. Curry Guinn– CIS 2045– [email protected]– www.uncw.edu/people/guinnc– 962-7937– Office Hours: MTWR: 11:00am-12:00pm
and by appointment
![Page 3: CSC 332 Data Structures Unix and Vi Dr. Curry Guinn.](https://reader035.fdocuments.us/reader035/viewer/2022062909/5a4d1bb27f8b9ab0599cd2a1/html5/thumbnails/3.jpg)
The CSC serverbabbage.cis.uncw.edu
• A cluster of 6 Dell PowerEdge 1850s with 2 Dual core Intel Xeon 2.8GHz processors and an 800MHz frontside bus.
• Each machine has 12GBs of memory • Each machine has two 72GB U320
hard drives in a Raid 1 configuration. • These machines will run Sun Grid
Engine N1 with the Sun scheduler, MPI
• The OS is Centos 4.1 (based on RedHat Enterprise server) which is rolled in with the Rocks Cluster
![Page 4: CSC 332 Data Structures Unix and Vi Dr. Curry Guinn.](https://reader035.fdocuments.us/reader035/viewer/2022062909/5a4d1bb27f8b9ab0599cd2a1/html5/thumbnails/4.jpg)
Why Unix• The OS of choice in universities for 25
years • The OS of choice for networking• Unix can run on virtually any computer
(IBM, Sun, HP, Macintosh,etc) • Unix is free or nearly free
• Linux/open source software movement • RedHat, FreeBSD, MKLinux, LinuxPPC, etc.
![Page 5: CSC 332 Data Structures Unix and Vi Dr. Curry Guinn.](https://reader035.fdocuments.us/reader035/viewer/2022062909/5a4d1bb27f8b9ab0599cd2a1/html5/thumbnails/5.jpg)
Stable and Efficient• Unix is very stable - computers running
Unix almost never crash • Unix is very efficient
• it gets maximum number crunching power out of your processor (and multiple processors)
• it can smoothly manage extremely huge amounts of data
• Once learned, the user interface allows for functionality that does not exist in GUI-based OS
![Page 6: CSC 332 Data Structures Unix and Vi Dr. Curry Guinn.](https://reader035.fdocuments.us/reader035/viewer/2022062909/5a4d1bb27f8b9ab0599cd2a1/html5/thumbnails/6.jpg)
Unix has some Drawbacks• Unix computers are controlled by a
command line interface • Not terribly user-friendly • Somewhat difficult to learn
• Hackers can exploit Unix/Linux• There are security holes
• There are many different versions of Unix with subtle (or not so subtle) differences
![Page 7: CSC 332 Data Structures Unix and Vi Dr. Curry Guinn.](https://reader035.fdocuments.us/reader035/viewer/2022062909/5a4d1bb27f8b9ab0599cd2a1/html5/thumbnails/7.jpg)
![Page 8: CSC 332 Data Structures Unix and Vi Dr. Curry Guinn.](https://reader035.fdocuments.us/reader035/viewer/2022062909/5a4d1bb27f8b9ab0599cd2a1/html5/thumbnails/8.jpg)
Program Management• Every program is independent
– The core operating system (known as the kernel) manages each program as a distinct process with its own little chunk of dedicated memory.
– If one program runs into trouble, it dies, but does not affect the affect the kernel or the other programs running on the computer.
![Page 9: CSC 332 Data Structures Unix and Vi Dr. Curry Guinn.](https://reader035.fdocuments.us/reader035/viewer/2022062909/5a4d1bb27f8b9ab0599cd2a1/html5/thumbnails/9.jpg)
The Unix Shell• You communicate with a Unix computer through
a command program known as a shell.
• The shell interprets the commands that you type on the keyboard.
• There are actually many different shells available for Unix computers, and on some systems you can choose the shell in which you wish to work.
• You can use shell commands to write simple programs (scripts) to automate many tasks
![Page 10: CSC 332 Data Structures Unix and Vi Dr. Curry Guinn.](https://reader035.fdocuments.us/reader035/viewer/2022062909/5a4d1bb27f8b9ab0599cd2a1/html5/thumbnails/10.jpg)
Unix Commands• Unix commands are short and cryptic like
vi or rm.• Very fast; you will get used to it.
• Every command has a host of modifiers which are generally single letters preceded by a hyphen:
ls -l or mv -R
![Page 11: CSC 332 Data Structures Unix and Vi Dr. Curry Guinn.](https://reader035.fdocuments.us/reader035/viewer/2022062909/5a4d1bb27f8b9ab0599cd2a1/html5/thumbnails/11.jpg)
Wildcards• You can substitute the * as a wildcard
symbol for any number of characters in any filename.
• If you type just * after a command, it stands for all files in the current directory:
cat * will write all files to the screen• You can mix the * with other characters to
form a search pattern: ls a*.txt will list all files that start with “a”
and end in “.txt”• The “?” wildcard stands for any single character
![Page 12: CSC 332 Data Structures Unix and Vi Dr. Curry Guinn.](https://reader035.fdocuments.us/reader035/viewer/2022062909/5a4d1bb27f8b9ab0599cd2a1/html5/thumbnails/12.jpg)
Control Characters
• Control commands that work (almost) any time
• ctrl-C will abort any program
• ctrl-S suspends (halts) output scrolling up on your terminal screen
• ctrl-Q resumes the display of output on your screen
![Page 13: CSC 332 Data Structures Unix and Vi Dr. Curry Guinn.](https://reader035.fdocuments.us/reader035/viewer/2022062909/5a4d1bb27f8b9ab0599cd2a1/html5/thumbnails/13.jpg)
Getting Help in Unix
• There is a rudimentary Help system which consists of a set of "manual” pages for every Unix command.
• The man pages tell you which options a particular command can take, and how each option modifies the behavior of the command.
• Type man and the name of a command to read the manual page for that command.
![Page 14: CSC 332 Data Structures Unix and Vi Dr. Curry Guinn.](https://reader035.fdocuments.us/reader035/viewer/2022062909/5a4d1bb27f8b9ab0599cd2a1/html5/thumbnails/14.jpg)
Unix Help on the WebHere is a list of a few online Unix
tutorials:• Unix for Beginners
http://www.ee.surrey.ac.uk/Teaching/Unix/• Unix Guru Universe
http://www.ugu.com/sui/ugu/show?help.beginners• Getting Started With The Unix
Operating System http://iss.leeds.ac.uk/info/313/unix/185/getting_started_with_the_unix_operating_system/1
![Page 15: CSC 332 Data Structures Unix and Vi Dr. Curry Guinn.](https://reader035.fdocuments.us/reader035/viewer/2022062909/5a4d1bb27f8b9ab0599cd2a1/html5/thumbnails/15.jpg)
Unix Filenames• Unix is case sensitive• UNIX filenames contain only letters,
numbers, and the _ (underscore), . (dot), and - (dash) characters.
![Page 16: CSC 332 Data Structures Unix and Vi Dr. Curry Guinn.](https://reader035.fdocuments.us/reader035/viewer/2022062909/5a4d1bb27f8b9ab0599cd2a1/html5/thumbnails/16.jpg)
Filename Extensions• Most UNIX filenames start with a lower
case letter and end with a dot followed by one, two, or three letters: myfile.txt
• However, this is just a common convention and is not required.
• It is also possible to have additional dots in the filename.
• The part of the name following the dot is called the “extension.”
• The extension is often used to designate the type of file.
![Page 17: CSC 332 Data Structures Unix and Vi Dr. Curry Guinn.](https://reader035.fdocuments.us/reader035/viewer/2022062909/5a4d1bb27f8b9ab0599cd2a1/html5/thumbnails/17.jpg)
Working with Directories• Directories are a means of organizing
your files on a Unix computer. – They are equivalent to folders in Windows
and Macintosh computers • Directories contain files, executable
programs, and sub-directories
![Page 18: CSC 332 Data Structures Unix and Vi Dr. Curry Guinn.](https://reader035.fdocuments.us/reader035/viewer/2022062909/5a4d1bb27f8b9ab0599cd2a1/html5/thumbnails/18.jpg)
Your Home Directory• When you login to the server, you always
start in your Home directory.• Create sub-directories to store specific
projects or groups of information, just as you would place folders in a filing cabinet.
![Page 19: CSC 332 Data Structures Unix and Vi Dr. Curry Guinn.](https://reader035.fdocuments.us/reader035/viewer/2022062909/5a4d1bb27f8b9ab0599cd2a1/html5/thumbnails/19.jpg)
File & Directory Commands• This is a minimal list of Unix commands
that you must know for file management:ls (list) mkdir (make directory) cd (change directory) rmdir (remove directory)cp (copy) pwd (present working directory) mv (move) more (view by page)rm (remove) cat (view entire file on screen)
• All of these commands can be modified with many options. Learn to use Unix ‘man’ pages for more information.
![Page 20: CSC 332 Data Structures Unix and Vi Dr. Curry Guinn.](https://reader035.fdocuments.us/reader035/viewer/2022062909/5a4d1bb27f8b9ab0599cd2a1/html5/thumbnails/20.jpg)
Navigation• pwd (present working directory) shows the name and
location of the directory where you are currently working:
$ pwd/home/faculty/guinnc
– This is a “pathname,” the slashes indicate sub-directories– The initial slash is the “root” of the whole filesytem
• ls (list) gives you a list of the files in the current directory: $ ls
CLASSES mbox Misc public_html subdir TORVALDS voicedata
– Use the ls -l (long) option to get more information about each file$ ls -l
total 32lrwxrwxrwx 1 guinnc guinnc 20 Jul 19 10:17 CLASSES -> /home/classes/guinnc-rw------- 1 guinnc guinnc 11258 Aug 18 10:54 mboxdrwxrwxr-x 2 guinnc guinnc 4096 Aug 20 11:13 Miscdrwxr-xr-x 2 guinnc guinnc 4096 Jul 18 10:15 public_htmldrwxrwxr-x 2 guinnc guinnc 4096 Aug 20 11:26 subdirdrwxr-xr-x 6 guinnc guinnc 4096 Jul 18 10:16 TORVALDSdrwxrwxr-x 3 guinnc guinnc 4096 Aug 7 14:01 voicedata
![Page 21: CSC 332 Data Structures Unix and Vi Dr. Curry Guinn.](https://reader035.fdocuments.us/reader035/viewer/2022062909/5a4d1bb27f8b9ab0599cd2a1/html5/thumbnails/21.jpg)
Sub-directories• cd (change directory) moves you to another
directory$ cd Misc$ pwd$ /home/faculty/guinnc/Misc
• mkdir (make directory) creates a new sub-directory inside of the current directory
$ lsCLASSES mbox Misc public_html TORVALDS voicedata$ mkdir subdir$ lsCLASSES mbox Misc public_html subdir TORVALDS voicedata
• rmdir (remove directory) deletes a sub-directory, but the sub-directory must be empty
$ rmdir subdir$ lsCLASSES mbox Misc public_html TORVALDS voicedata
![Page 22: CSC 332 Data Structures Unix and Vi Dr. Curry Guinn.](https://reader035.fdocuments.us/reader035/viewer/2022062909/5a4d1bb27f8b9ab0599cd2a1/html5/thumbnails/22.jpg)
File Commands
• Unix directory structure revisited– 'cd ~' change directory to your home– 'cd ~guinnc' change directory to guinnc's
home– 'cd ..' change directory to upper directory– 'cd / ' change directory to root– Use tabs to complete the file name (write
partial file name and then use tab)
![Page 23: CSC 332 Data Structures Unix and Vi Dr. Curry Guinn.](https://reader035.fdocuments.us/reader035/viewer/2022062909/5a4d1bb27f8b9ab0599cd2a1/html5/thumbnails/23.jpg)
Commands for Files• cat dumps the entire contents of a file onto
the screen.
![Page 24: CSC 332 Data Structures Unix and Vi Dr. Curry Guinn.](https://reader035.fdocuments.us/reader035/viewer/2022062909/5a4d1bb27f8b9ab0599cd2a1/html5/thumbnails/24.jpg)
more or less• Use the command more (or less) to view at
the contents of a file one screen at a time: Hit the spacebar to page down through
the file– b moves back up a page– At the bottom of the screen, more shows how much
of the file has been displayed
![Page 25: CSC 332 Data Structures Unix and Vi Dr. Curry Guinn.](https://reader035.fdocuments.us/reader035/viewer/2022062909/5a4d1bb27f8b9ab0599cd2a1/html5/thumbnails/25.jpg)
Copy & Move• cp lets you copy a file from any directory to
any other directory, or create a copy of a file with a new name in one directory
cp filename.ext newfilename.extcp filename.ext subdir/newname.extcp /u/jdoe01/filename.ext ./subdir/newfilename.ext
• mv allows you to move files to other directories, but it is also used to rename files. – Filename and directory syntax for mv is exactly the same
as for the cp command. • mv filename.ext subdir/newfilename.ext
– NOTE: When you use mv to move a file into another directory, the current file is deleted.
![Page 26: CSC 332 Data Structures Unix and Vi Dr. Curry Guinn.](https://reader035.fdocuments.us/reader035/viewer/2022062909/5a4d1bb27f8b9ab0599cd2a1/html5/thumbnails/26.jpg)
Delete• Use the command rm (remove) to
delete files• There is no way to undo this command!!!
• The rem program in my bin directory.• Puts files in your .wastebasket
• Go ahead and copy my .bash_profile and .vimrc into your home directory
![Page 27: CSC 332 Data Structures Unix and Vi Dr. Curry Guinn.](https://reader035.fdocuments.us/reader035/viewer/2022062909/5a4d1bb27f8b9ab0599cd2a1/html5/thumbnails/27.jpg)
Moving Files between Computers
• You will often need to move files between computers - desktop to server and back
• There are several options– E-mail– FTP
• SSH Secure Shell has a nice file transfer utility under the Menu “Windows”
![Page 28: CSC 332 Data Structures Unix and Vi Dr. Curry Guinn.](https://reader035.fdocuments.us/reader035/viewer/2022062909/5a4d1bb27f8b9ab0599cd2a1/html5/thumbnails/28.jpg)
Vi Tutorial
• http://people.uncw.edu/guinnc/courses/Fall12/332/notes/day2_unix/vi.ppt
![Page 29: CSC 332 Data Structures Unix and Vi Dr. Curry Guinn.](https://reader035.fdocuments.us/reader035/viewer/2022062909/5a4d1bb27f8b9ab0599cd2a1/html5/thumbnails/29.jpg)
For Next Class, Tuesday
• For Tuesday– Read Weiss, Chapter 1– Focus on 1.4 and 1.5– Quiz, due Tuesday night, 11:59pm
• Homework 1 due Thursday, 08/30