Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to UNIX Road Map: 1. UNIX Structure 2. Components of UNIX 3. Process Structure 4. Shell & Utility Programs 5. Using Files & Directories 6.

Similar presentations


Presentation on theme: "Introduction to UNIX Road Map: 1. UNIX Structure 2. Components of UNIX 3. Process Structure 4. Shell & Utility Programs 5. Using Files & Directories 6."— Presentation transcript:

1 Introduction to UNIX Road Map: 1. UNIX Structure 2. Components of UNIX 3. Process Structure 4. Shell & Utility Programs 5. Using Files & Directories 6. Compiling and Running C Programs in UNIX

2 UNIX Structure  Multiuser : Several users can use a UNIX system at the same time.  Multitasking : Can run multiple processes at the same time. Hardware UNIX Kernel POSIX system call API P1P1 P2P2 PNPN …

3 Components of UNIX 1. Kernel + POSIX system call API ◦ Covered in OS 2. Shell (program to launch other programs) 3. Standard utility programs ◦ ( cp, mv, ls, cat, … ) 4. System configuration files ◦ ( /etc/vfstab,… )

4 Process Structure init login login (/bin/login)login shell (/bin/sh) lswccat Other user programs

5 Logging In/Out Login : user1 Password: 123 % command  get a shell prompt % command  get another shell prompt % exit  logout & terminate shell

6 Shell a.k.a command line interpreter  Getting help on UNIX % man ls % man man while(1) 1.prompt the user for the next command 2.Read the next command 3.Parse the command line 4.Launch the programs (fork, exec) 5.Wait until the programs terminate (waitpid) end

7 Running utility programs Most utility programs are located 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  cleans the screen Aborting a shell command: press ^C

8 UNIX has a tree-like hierarchical directory structure. When you login, login utility reads your home directory from /etc/passwd and changes your current directory to be your home directory. Using Files & Directories tmp bin lib usr etc home export dev include bin local bin

9 Directories 1. % pwd print working directory 2. % cd BIM322 change current directory % cd.. change to parent % cd / change to root % cd /usr/local absolute path specification % cd % cd ~ takes you to your home % cd ~cakinlar directory 3. % ls –al list directory content 4. % mkdir AA create a new directory 5. % rmdir AA remove a directory

10 Files 1. % touch file1 create an empty file 2. % cp file1 file2 copy files 3. % mv file1 /tmp move file to directory % mv file1 file3 move file to a new file % mv AA /tmp can also move directories 4. % rm file1 remove a file 3. % find. –name file1 find a file 4. % cat file1 view all at once 5. % more file1 page by page 6. % head file1 first … lines 7. % tail file1 last … lines

11 Compiling and Running C Programs in UNIX 1. Open an editor, type your ‘Hello world’ program. 2. % gcc first.c  outputs a.out 3. %./a.out or %./a 4. % gcc –o first first.c 5. %./first // first.c include int main(int argc, char *argv[]){ int i; for(i=0; i<argc; i++) printf("arg[%d]: %s\n", i, argv[i]); } //end-main // first.c include int main(int argc, char *argv[]){ int i; for(i=0; i<argc; i++) printf("arg[%d]: %s\n", i, argv[i]); } //end-main


Download ppt "Introduction to UNIX Road Map: 1. UNIX Structure 2. Components of UNIX 3. Process Structure 4. Shell & Utility Programs 5. Using Files & Directories 6."

Similar presentations


Ads by Google