csc – 332 data structures day 2: unix and more! dr. curry guinn
TRANSCRIPT
![Page 1: CSC – 332 Data Structures Day 2: Unix and More! Dr. Curry Guinn](https://reader035.vdocument.in/reader035/viewer/2022062717/56649e255503460f94b141d7/html5/thumbnails/1.jpg)
CSC – 332 Data StructuresDay 2: Unix and More!
Dr. Curry Guinn
![Page 2: CSC – 332 Data Structures Day 2: Unix and More! Dr. Curry Guinn](https://reader035.vdocument.in/reader035/viewer/2022062717/56649e255503460f94b141d7/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 Day 2: Unix and More! Dr. Curry Guinn](https://reader035.vdocument.in/reader035/viewer/2022062717/56649e255503460f94b141d7/html5/thumbnails/3.jpg)
A recap of last meeting’s notes
• CSC 332 is important for future CSC courses – and your career in computing, in general
• What are data structures?
• Questions?
![Page 4: CSC – 332 Data Structures Day 2: Unix and More! Dr. Curry Guinn](https://reader035.vdocument.in/reader035/viewer/2022062717/56649e255503460f94b141d7/html5/thumbnails/4.jpg)
For Next Class, Tuesday
• For Tuesday– Homework 1 due Tuesday, 01/21, 11:59pm
– Quiz 1 - Today by 11:59pm.• Up to ∞ submissions
– Quiz 2 – Tuesday (1/21) before class time. Up to 3 submissions
– Quiz 3 – Thursday, 01/23, before class time.• Up to 2 submissions
– Read Chapter 1
![Page 5: CSC – 332 Data Structures Day 2: Unix and More! Dr. Curry Guinn](https://reader035.vdocument.in/reader035/viewer/2022062717/56649e255503460f94b141d7/html5/thumbnails/5.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 73GB 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 6: CSC – 332 Data Structures Day 2: Unix and More! Dr. Curry Guinn](https://reader035.vdocument.in/reader035/viewer/2022062717/56649e255503460f94b141d7/html5/thumbnails/6.jpg)
Why Unix• The OS of choice in computer science
research universities for 30 years
• The OS of choice for networking
• Unix can run on virtually any computer (IBM, Sun, Compaq, Macintosh,etc)
• Unix is free or nearly free • Linux/open source software movement • RedHat, FreeBSD, MKLinux, LinuxPPC, etc.
![Page 7: CSC – 332 Data Structures Day 2: Unix and More! Dr. Curry Guinn](https://reader035.vdocument.in/reader035/viewer/2022062717/56649e255503460f94b141d7/html5/thumbnails/7.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 8: CSC – 332 Data Structures Day 2: Unix and More! Dr. Curry Guinn](https://reader035.vdocument.in/reader035/viewer/2022062717/56649e255503460f94b141d7/html5/thumbnails/8.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 9: CSC – 332 Data Structures Day 2: Unix and More! Dr. Curry Guinn](https://reader035.vdocument.in/reader035/viewer/2022062717/56649e255503460f94b141d7/html5/thumbnails/9.jpg)
![Page 10: CSC – 332 Data Structures Day 2: Unix and More! Dr. Curry Guinn](https://reader035.vdocument.in/reader035/viewer/2022062717/56649e255503460f94b141d7/html5/thumbnails/10.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 11: CSC – 332 Data Structures Day 2: Unix and More! Dr. Curry Guinn](https://reader035.vdocument.in/reader035/viewer/2022062717/56649e255503460f94b141d7/html5/thumbnails/11.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 12: CSC – 332 Data Structures Day 2: Unix and More! Dr. Curry Guinn](https://reader035.vdocument.in/reader035/viewer/2022062717/56649e255503460f94b141d7/html5/thumbnails/12.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 13: CSC – 332 Data Structures Day 2: Unix and More! Dr. Curry Guinn](https://reader035.vdocument.in/reader035/viewer/2022062717/56649e255503460f94b141d7/html5/thumbnails/13.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 14: CSC – 332 Data Structures Day 2: Unix and More! Dr. Curry Guinn](https://reader035.vdocument.in/reader035/viewer/2022062717/56649e255503460f94b141d7/html5/thumbnails/14.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 15: CSC – 332 Data Structures Day 2: Unix and More! Dr. Curry Guinn](https://reader035.vdocument.in/reader035/viewer/2022062717/56649e255503460f94b141d7/html5/thumbnails/15.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 16: CSC – 332 Data Structures Day 2: Unix and More! Dr. Curry Guinn](https://reader035.vdocument.in/reader035/viewer/2022062717/56649e255503460f94b141d7/html5/thumbnails/16.jpg)
Unix Help on the Web
Here is a list of a few online Unix tutorials:
• Unix for Beginnershttp://www.ee.surrey.ac.uk/Teaching/Unix/
• Unix Guru Universehttp://www.ugu.com/sui/ugu/show?
help.beginners
![Page 17: CSC – 332 Data Structures Day 2: Unix and More! Dr. Curry Guinn](https://reader035.vdocument.in/reader035/viewer/2022062717/56649e255503460f94b141d7/html5/thumbnails/17.jpg)
Unix Filenames• Unix is case sensitive
• Unix filenames contain only letters, numbers, and the _ (underscore), . (dot), and - (dash) characters.
![Page 18: CSC – 332 Data Structures Day 2: Unix and More! Dr. Curry Guinn](https://reader035.vdocument.in/reader035/viewer/2022062717/56649e255503460f94b141d7/html5/thumbnails/18.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 19: CSC – 332 Data Structures Day 2: Unix and More! Dr. Curry Guinn](https://reader035.vdocument.in/reader035/viewer/2022062717/56649e255503460f94b141d7/html5/thumbnails/19.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 20: CSC – 332 Data Structures Day 2: Unix and More! Dr. Curry Guinn](https://reader035.vdocument.in/reader035/viewer/2022062717/56649e255503460f94b141d7/html5/thumbnails/20.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 21: CSC – 332 Data Structures Day 2: Unix and More! Dr. Curry Guinn](https://reader035.vdocument.in/reader035/viewer/2022062717/56649e255503460f94b141d7/html5/thumbnails/21.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 22: CSC – 332 Data Structures Day 2: Unix and More! Dr. Curry Guinn](https://reader035.vdocument.in/reader035/viewer/2022062717/56649e255503460f94b141d7/html5/thumbnails/22.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 23: CSC – 332 Data Structures Day 2: Unix and More! Dr. Curry Guinn](https://reader035.vdocument.in/reader035/viewer/2022062717/56649e255503460f94b141d7/html5/thumbnails/23.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 24: CSC – 332 Data Structures Day 2: Unix and More! Dr. Curry Guinn](https://reader035.vdocument.in/reader035/viewer/2022062717/56649e255503460f94b141d7/html5/thumbnails/24.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 25: CSC – 332 Data Structures Day 2: Unix and More! Dr. Curry Guinn](https://reader035.vdocument.in/reader035/viewer/2022062717/56649e255503460f94b141d7/html5/thumbnails/25.jpg)
Commands for Files• cat dumps the entire contents of a file onto
the screen.
![Page 26: CSC – 332 Data Structures Day 2: Unix and More! Dr. Curry Guinn](https://reader035.vdocument.in/reader035/viewer/2022062717/56649e255503460f94b141d7/html5/thumbnails/26.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 27: CSC – 332 Data Structures Day 2: Unix and More! Dr. Curry Guinn](https://reader035.vdocument.in/reader035/viewer/2022062717/56649e255503460f94b141d7/html5/thumbnails/27.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 28: CSC – 332 Data Structures Day 2: Unix and More! Dr. Curry Guinn](https://reader035.vdocument.in/reader035/viewer/2022062717/56649e255503460f94b141d7/html5/thumbnails/28.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 29: CSC – 332 Data Structures Day 2: Unix and More! Dr. Curry Guinn](https://reader035.vdocument.in/reader035/viewer/2022062717/56649e255503460f94b141d7/html5/thumbnails/29.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”– Fugu, Panic, and FileZilla are examples of a GUI
file transfer program for Mac OS
![Page 30: CSC – 332 Data Structures Day 2: Unix and More! Dr. Curry Guinn](https://reader035.vdocument.in/reader035/viewer/2022062717/56649e255503460f94b141d7/html5/thumbnails/30.jpg)
Vi Tutorial
• http://people.uncw.edu/guinnc/courses/Spring14/332/notes/day2_unix/vi.ppt
Generics
• http://people.uncw.edu/guinnc/courses/Spring14/332/notes/day2_unix/Generics.ppt
![Page 31: CSC – 332 Data Structures Day 2: Unix and More! Dr. Curry Guinn](https://reader035.vdocument.in/reader035/viewer/2022062717/56649e255503460f94b141d7/html5/thumbnails/31.jpg)
For Next Class, Thursday
• For Thursday– Homework 1 due Thursday, 08/29, 11:59pm
– Quiz 1 - Last night!!! by 11:59pm.• Up to ∞ submissions
– Quiz 2 – Tonight!!, 11:59pm• Up to 5 submissions
– Quiz 3 – Thursday, 08/29, 11:59pm• Up to 3 submissions
– Read Chapter 1