SlideServe
Menu
Préférences
© SlideServe · v2026

Introduction to UNIX

inge avatar
11 diapositives · 334 Views · Sep 05, 2014

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.

Introduction to UNIX - slide 1
01 / 11Introduction to UNIX
1 / 17

Télécharger la présentation

Introduction to UNIX
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  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