1 / 11

Introduction to UNIX

Introduction to UNIX. Road Map: UNIX Structure Components of UNIX Process Structure Shell & Utility Programs Using Files & Directories Compiling and Running C Programs in UNIX. UNIX Structure. …. P 1. P 2. P N.

inge
Download Presentation

Introduction to UNIX

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introductionto UNIX Road Map: UNIX Structure Components of UNIX ProcessStructure Shell & Utility Programs Using Files & Directories CompilingandRunning C Programs in UNIX

  2. UNIX Structure … P1 P2 PN • Multiuser: Severalusers can use a UNIX system at thesame time. • Multitasking : Can runmultipleprocesses at thesame time. POSIX systemcall API UNIX Kernel Hardware

  3. Components of UNIX • Kernel + POSIX systemcall API • Covered in OS • Shell (program tolaunchotherprograms) • Standardutilityprograms • (cp, mv, ls, cat, …) • Systemconfigurationfiles • (/etc/vfstab,…)

  4. ProcessStructure init login(/bin/login) login login shell(/bin/sh) ls wc cat Otheruserprograms

  5. LoggingIn/Out Login : user1 Password: 123 %command get a shellprompt %command getanothershellprompt % exit  logout & terminateshell

  6. Shell a.k.acommandlineinterpreter • Gettinghelp on UNIX % manls % manman • while(1) • prompt the user for the next command • Read thenextcommand • Parsethecommandline • Launchtheprograms (fork, exec) • Waituntiltheprogramsterminate (waitpid) • end

  7. Runningutilityprograms • Mostutilityprogramsarelocated in /usr/bin • Basic form of a UNIX command is % command [-options] [arguments] Ex: % ls % ls –a % ls –al % ls BIM322 % ls –al BIM322 % clear cleansthescreen • Aborting a shellcommand: press^C

  8. Using Files & Directories • UNIX has a tree-likehierarchicaldirectorystructure. • Whenyoulogin, loginutilityreadsyourhomedirectoryfrom/etc/passwdandchangesyourcurrentdirectoryto be yourhomedirectory. tmp bin libusretchomeexport dev include bin local bin

  9. Directories • % pwdprintworkingdirectory • % cd BIM322 changecurrentdirectory % cd .. changetoparent % cd / changetoroot % cd /usr/localabsolutepathspecification % cd % cd ~ takesyoutoyourhome % cd ~cakinlardirectory • % ls –al listdirectorycontent • % mkdir AA create a newdirectory • % rmdir AA remove a directory

  10. Files • % touch file1 create an empty file • % cp file1 file2 copyfiles • % mv file1 /tmpmove file todirectory % mv file1 file3 move file to a new file % mv AA /tmpcan alsomovedirectories • % rm file1 remove a file • % find . –name file1 find a file • % cat file1 viewall at once • % more file1 pagebypage • % headfile1 first … lines • % tailfile1 last… lines

  11. CompilingandRunning C Programs in UNIX • Open an editor, typeyour ‘Helloworld’ program. • % gccfirst.c outputsa.out • % ./a.outor % ./a • % gcc –o firstfirst.c • % ./first // first.c include <stdio.h> int main(intargc, char *argv[]){ int i; for(i=0; i<argc; i++) printf("arg[%d]: %s\n", i, argv[i]); } //end-main

More Related