1 / 27

(I) Introduction to Linux Operating System

제 01 강 : Introduction to Linux Operatiing System. (I) Introduction to Linux Operating System. Kern Koh Seoul National University. Course Description. [Linux programming]

dflora
Download Presentation

(I) Introduction to Linux Operating System

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. 제01강 : Introduction to Linux Operatiing System (I) Introduction to Linux Operating System Kern Koh Seoul National University

  2. Course Description • [Linux programming] • First part of this course introduces students to the Linux programming. Most Linux manuals are very cryptic and hence needs a gentle introduction. Students will be introduced to the basic knowledge about (not necessarily all the commands themselves) Linux commands, system calls, library and scripts - what feature is provided in each, and where to look for the information about them, etc. • [Modern program development environment] • The second subject of this lecture is modern "program development environment" and program development productivity. All the modern source codes are stored and distributed in tens and hundreds of directories and files. All these files are combined and linked to make one executable file. Modern computer architecture dictates such modular programming practice. But such programming practise creates a host of new problems during program development. Students are encouraged to understand the reason why such modular programming method is needed. Regular expression and tags file will be taught as a means of helping source code browsing. Make and SCCS commands are explained as a way of managing source codes and as a way of minimizing build time. Other important tools and utilities such as grep, find, ctags etc will be also taught. • [Linux Kernel Internal] • Third subject of this lecture is Linux kernel internal. This part begins from the kernel overall architecture, several important concepts exported by kernel such as file descriptor, superblock, inode, buffer cache, fsck etc. We will first read UNIX source code then introduce Linux source code. • In sum, much emphasis of this lecture is on the practice, not just the theory and concepts of Linux. The students are greatly encouraged to practise a lot of commands, make scripts, manage system, and study source code on Linux platform. All the lab work will be carried out on recent Linux operating system. Following books are recommended as text books and references:

  3. Outline • Interface to Operating System • Command, system call, script, daemon • shell variable, IPC, Web, CGI etc • Modern Program Development • make, tags, include, DLL, RPM etc • testing & debugging • UNIX/Linux kernel Internal Design • UNIX – Lion’s book & code • Linux – Love’s book & code • Always have Linux machine on-line besides you • We emphasize practice in this class

  4. References (1) If you are a Beginner: o Christian, The UNIX Operating System, 2nd Ed, Wiley. (2) To learn more about Commands: UNIX Power Tools, An O'Reilly & Associates/Random House Book. (3) If you want to be an advanced user o Anderson, The UNIX C Shell Field Guide, Prentice Hall o Newham & Rosenblatt, Learning the BASH shell,  O'Reilly (4) For function call interface (library, system calls) Stevens, Advanced Programming in UNIX, Addison Wesley. (5) If you want a textbook about Operating System o Silberschatz et. al., Applied Operating System Concepts, John Wiley & Sons. (6) For kernel source code o John Lions, Lions' Commentary on Unix : With Source Code, o Robert Love, Linux Kernel Development, Developer’s Library.

  5. Homework • Login to Linux machine • Use vi editor and type in C program • We assume you are familiar with C & vi editor. main() { printf(“Hello\n”); } • Name it “Hello.c” • Compile (use “gcc Hello.c”) • Check if a.out is created (use “ls”) • Run it (just say “./a.out”)

  6. History of UNIX • UNIX was designed for • Timesharing (Interactive) System • Use terminals (not card reader, printer) • Response time oriented * (not Throughput oriented) • Main use: • Program Development • Office Automation • Multiuser system • Portable OS • by Bell Laboratories (AT&T) * 747 -- throughput oriented (batch -- wait until many arrives) – HW important taxi -- response time oriented (as soon as a customer arrives) --- customer important

  7. Portability (移植可能) Other OS • Every programs needs OS (OS manages HW) • Before, hardware was expensive (no IC) • OS runs frequently  OS must be efficient • Code OS with assembler  CPU dependent -------------------------------------------------------- • UNIX was coded in C language • Unix can be ported to any CPU * (with C**) • Unix can talk with any HW(running UNIX) * No more learning, conversion needed when HW changes. ** Language porting is easier than OS porting UNIX

  8. Terminology • utility • command, disk resident part of OS (loaded on demand), • “program”(next page) • kernel • memory resident part of OS, just plain C program. • shell • A special utility. It’s mission is Job Control • reads keyboard input & execute command (interpreter) • UNIX interface to user, • file • “named collection of information” • “sequence of bytes”, no other restrictions (eg record, block) • I/O devices are treated as files (special files, try ls /dev) • standard file • standard output: screen • standard error: error message • standard input: keyboard

  9. Software Concept • Hardware supports only 3-level objects: [1] Instruction (機械語) [ADD SUB JUMP …..…] [2] Function (函數) [sin() open() print() ..] • function invocation  push a frame into stack return address, local variables, … [3] Process [binary, a.out, a.EXE,…] • eg shell, editor, word, kernel, … • Program Image: functions, variables • HW resource: keyboard, screen, memory, … • SW resource: files, lock, …

  10. Terminology (用語) Function (函數) main() printf() sin() STACK Process (a.out, program)

  11. Every SW object -- map to these three Editor game Shell Library System call Daemon (server) Window ftp Tcp/ip Web server macro • [1] Instruction • (機械語) • [2] Function • (函數) • [3] Process • (program, binary, a.out)

  12. Upper/Lower case • ‘Boy’ and ‘boy’ are different in UNIX! • Login • type username, password (multi-user system) • ask system administrator to get them • (shell) prompt • %, $, … • prompt appears  “shell is ready to accept next command” • file names • absolute pathname: /a/b/c starts from root • relative pathname: x/y starts from current directory

  13. Suffix .c c source .h header file .f fortran source .s asm source • special characters • kill ^c • EOF ^d • stop ^s • backspace ^h

  14. Manual rm [-fri] file … rm -fr f2 f3 (o) rm -f -r f1 (x) mail [-r][-q][-p][-f file] mail -r -p (o) mail -rp (x) • Manual volumes (1) commands (2) system call (3) library functions • try man cat, man ls • bold as it is • [ ] option • file name of the file • … repeat • Exercise try “man 1 intro”, … , “man 4 intro”, … What are sections 4 - 9 about?

  15. $ man cat CAT(1) User Commands CAT(1) NAME cat - concatenate files and print on the standard output SYNOPSIS cat [OPTION] [FILE]... DESCRIPTION Concatenate FILE(s), or standard input, to standard output. -A, --show-all equivalent to -vET -b, --number-nonblank number nonblank output lines -e equivalent to -vE

  16. command | sys call | library One Line Summary [ ] --- option FILE --- file … --- repeat else --- as it is CAT(1) User Commands CAT(1) NAME cat - concatenate files and print on the standard output SYNOPSIS cat [OPTION] [FILE]... DESCRIPTION Concatenate FILE(s), or standard input, to standard output. -A, --show-all equivalent to -vET -b, --number-nonblank number nonblank output lines -e equivalent to -vE Try “whatiscat”

  17. Manual rm [-fri] file … rm -fr f2 f3 (o) rm -f -r f1 (x) mail [-r][-q][-p][-f file] mail -r -p (o) mail -rp (x) • Manual volumes (1) commands (2) system call (3) library functions • try man cat, man ls • bold as it is • [ ] option • file name of the file • … repeat • Exercise try “man 1 intro”, … , “man 4 intro”, … What are sections 4 - 9?

  18. CAT(1) User Commands CAT(1) NAME cat - concatenate files and print on the standard output SYNOPSIS cat [OPTION] [FILE]... DESCRIPTION Concatenate FILE(s), or standard input, to standard output. -A, --show-all equivalent to -vET -b, --number-nonblank number nonblank output lines -e equivalent to -vE if you don’t provide file name

  19. man cat • SYNOPSIS • cat [OPTION] [FILE]... • need to provide FILE(s) • read until EOF (ctrl-D is EOF) • What if no FILE is provided? • (standard input  standard output) until EOF (ctrl-D is EOF) $ cat 1 (user types) 1 (cat command outputs to screen) 2 (user types) 2 (cat command outputs to screen) ---------- until when? --------------- ctrl-D $

  20. man bash(Command Line Interpreter) • SYNOPSIS bash [options] [file] • bash needs FILE • read until EOF (ctrl-D is EOF) • eg bash FILE (read each line & execute it) • “FILE” is script file (text, whose line is command) • “bash” is interpreter • What if FILE is NOT provided? • bash readsfrom standard input until EOF (ctrl-D) $ bash no FILE given. So bash reads from keyboard. $ command1 user types command1 at keyboard. …. $ command2 … bash continue reading keyboard until EOF (ctrl-d) bash reached EOF at keyboard.

  21. script $ bash hello Now we provide file called hello hello’s content is date date date • hello is an example of script file • Try another thing …. • At the shell prompt, try: $ ./hello  bash reads lines in hello, executes • It looks the same as a command • Command can be either (a.out) or (script) • [binary] [text file]

  22. When you know the name of command (function) • man rm • whatisrm (one line summary) • When you don’t know the name of command, but you know what it does • man -k delete • aproposdelete Ex apropos concatenate apropos shutdown

  23. $ whatis cat cat (1) - concatenate files and print on the standard output $ apropos concatenate cat (1) - concatenate files and print on the standard output ospent (1) - Concatenate entities strcat (3) - concatenate two strings strncat [strcat] (3) - concatenate two strings tac (1) - concatenate and print files in reverse wcscat (3) - concatenate two wide-character strings wcsncat (3) - concatenate two wide-character strings $

  24. Linux Protection - Yes Resource – 最大 節約 Text mode (CUI)* Total silent eg vi * CUI: Character User Interface * GUI: Graphical User Interface Windows Protection - Little Resource – 最大 使用 Window, GUI Shows everything History State Command Option eg word …. Multi-user vs Single-user

  25. User Interface (OS) GUI - Windows CUI - Linux $ _ man Command ps Command menu (Programs in disk) active processes (loaded into memory)

  26. $ ps -A | more PID TTY TIME CMD 1 ? 00:00:01 init 2 ? 00:00:01 migration/ 3 ? 00:00:00 ksoftirqd/0 4 ? 00:00:01 migration/1 5 ? 00:00:00 ksoftirqd/1 6 ? 00:00:00 events/0 7 ? 00:00:00 events/1 8 ? 00:00:00 khelper 9 ? 00:00:00 kacpid 24 ? 00:00:00 kblockd/0 $ ls /bin arch date gettext mkdir rm touch ash dd grep mknod rmdir tracepath ash. static df gtar mktemp tracepath6 awk dmesg gunzip more rvi traceroute basename gzip mount rview traceroute6 bash doexec hostname mt sed true bash2 igawk mv setfont umount bsh ipcalc netstat setserial uname

  27. User Interface (editor) GUI - word CUI – vi : _

More Related