Practical Computing-II March 20, 2015 0. An Introduction
About The Course CMS M.2.2 Practical Computing-II
About The Course CMS M.2.2 Practical Computing-II 25 credits (33.33% weighting)
About The Course CMS M.2.2 Practical Computing-II 25 credits (33.33% weighting) About Linux/Unix environment
About The Course CMS M.2.2 Practical Computing-II 25 credits (33.33% weighting) About Linux/Unix environment Scripting Tools and Languages (like sed & awk)
About The Course CMS M.2.2 Practical Computing-II 25 credits (33.33% weighting) About Linux/Unix environment Scripting Tools and Languages (like sed & awk) 1. boot-up sequence
About The Course CMS M.2.2 Practical Computing-II 25 credits (33.33% weighting) About Linux/Unix environment Scripting Tools and Languages (like sed & awk) 1. boot-up sequence 2. kernel
About The Course CMS M.2.2 Practical Computing-II 25 credits (33.33% weighting) About Linux/Unix environment Scripting Tools and Languages (like sed & awk) 1. boot-up sequence 2. kernel 3. Signals
About The Course CMS M.2.2 Practical Computing-II 25 credits (33.33% weighting) About Linux/Unix environment Scripting Tools and Languages (like sed & awk) 1. boot-up sequence 2. kernel 3. Signals 4. programs vs. processes
About The Course CMS M.2.2 Practical Computing-II 25 credits (33.33% weighting) About Linux/Unix environment Scripting Tools and Languages (like sed & awk) 1. boot-up sequence 2. kernel 3. Signals 4. programs vs. processes 5. permissions and access control
About The Course CMS M.2.2 Practical Computing-II 25 credits (33.33% weighting) About Linux/Unix environment Scripting Tools and Languages (like sed & awk) 1. boot-up sequence 2. kernel 3. Signals 4. programs vs. processes 5. permissions and access control 6. fork and exec
About The Course CMS M.2.2 Practical Computing-II 25 credits (33.33% weighting) About Linux/Unix environment Scripting Tools and Languages (like sed & awk) 1. boot-up sequence 2. kernel 3. Signals 4. programs vs. processes 5. permissions and access control 6. fork and exec 7. foreground and background processes
Prerequisites Linux account
Prerequisites Linux account Familiarity with the basic Linux command line environment
Prerequisites Linux account Familiarity with the basic Linux command line environment Some experience in programming with the gcc and g++ compilers
Prerequisites Linux account Familiarity with the basic Linux command line environment Some experience in programming with the gcc and g++ compilers Insights into how the system behaves in various circumstances
UNIX The UNIX operating system was developed in the late 1960s at AT&T Bell Laboratories
UNIX The UNIX operating system was developed in the late 1960s at AT&T Bell Laboratories Ken Thompson in 1969 made it work on DEC PDP-7
UNIX The UNIX operating system was developed in the late 1960s at AT&T Bell Laboratories Ken Thompson in 1969 made it work on DEC PDP-7 Also involved, through ideas & contributions, were Rudd Canaday, Doug McIlroy, Joe Ossanna & Dennis Ritchie
UNIX The UNIX operating system was developed in the late 1960s at AT&T Bell Laboratories Ken Thompson in 1969 made it work on DEC PDP-7 Also involved, through ideas & contributions, were Rudd Canaday, Doug McIlroy, Joe Ossanna & Dennis Ritchie Ritchie ported UNIX to the more advanced PDP-11 in 1970
UNIX The UNIX operating system was developed in the late 1960s at AT&T Bell Laboratories Ken Thompson in 1969 made it work on DEC PDP-7 Also involved, through ideas & contributions, were Rudd Canaday, Doug McIlroy, Joe Ossanna & Dennis Ritchie Ritchie ported UNIX to the more advanced PDP-11 in 1970 He then developed C language & its compiler to work with UNIX
UNIX The UNIX operating system was developed in the late 1960s at AT&T Bell Laboratories Ken Thompson in 1969 made it work on DEC PDP-7 Also involved, through ideas & contributions, were Rudd Canaday, Doug McIlroy, Joe Ossanna & Dennis Ritchie Ritchie ported UNIX to the more advanced PDP-11 in 1970 He then developed C language & its compiler to work with UNIX In 1973, Thompson & Ritchie rewrote entire UNIX system code in C
UNIX The UNIX operating system was developed in the late 1960s at AT&T Bell Laboratories Ken Thompson in 1969 made it work on DEC PDP-7 Also involved, through ideas & contributions, were Rudd Canaday, Doug McIlroy, Joe Ossanna & Dennis Ritchie Ritchie ported UNIX to the more advanced PDP-11 in 1970 He then developed C language & its compiler to work with UNIX In 1973, Thompson & Ritchie rewrote entire UNIX system code in C It broke the tradition of writing OS in assembly language
UNIX The UNIX operating system was developed in the late 1960s at AT&T Bell Laboratories Ken Thompson in 1969 made it work on DEC PDP-7 Also involved, through ideas & contributions, were Rudd Canaday, Doug McIlroy, Joe Ossanna & Dennis Ritchie Ritchie ported UNIX to the more advanced PDP-11 in 1970 He then developed C language & its compiler to work with UNIX In 1973, Thompson & Ritchie rewrote entire UNIX system code in C It broke the tradition of writing OS in assembly language With rewrite in C, UNIX became portable to any hardware
Unix It all resulted in UNIX becoming an operating system that was 1. time sharing
Unix It all resulted in UNIX becoming an operating system that was 1. time sharing 2. multi-user
Unix It all resulted in UNIX becoming an operating system that was 1. time sharing 2. multi-user 3. having support for programming
Unix It all resulted in UNIX becoming an operating system that was 1. time sharing 2. multi-user 3. having support for programming 4. unusually rich in features & productive (compared to its predecessors)
Unix It all resulted in UNIX becoming an operating system that was 1. time sharing 2. multi-user 3. having support for programming 4. unusually rich in features & productive (compared to its predecessors) 5. Hence, popular!
Unix It all resulted in UNIX becoming an operating system that was 1. time sharing 2. multi-user 3. having support for programming 4. unusually rich in features & productive (compared to its predecessors) 5. Hence, popular! Many free and commercial variants of UNIX are available today e.g.
Unix It all resulted in UNIX becoming an operating system that was 1. time sharing 2. multi-user 3. having support for programming 4. unusually rich in features & productive (compared to its predecessors) 5. Hence, popular! Many free and commercial variants of UNIX are available today e.g. Solaris, HP-UX, AIX, Zenix, FreeBSD, Linux,
Linux Unix-like computer operating system
Linux Unix-like computer operating system In 1991, as a graduate student at the University of Helsinki, Linus Torvalds became curious about OS
Linux Unix-like computer operating system In 1991, as a graduate student at the University of Helsinki, Linus Torvalds became curious about OS & got frustrated with limitations of existing Unix/Minix licensing terms
Linux Unix-like computer operating system In 1991, as a graduate student at the University of Helsinki, Linus Torvalds became curious about OS & got frustrated with limitations of existing Unix/Minix licensing terms Developed his own variant called Linux
Linux Unix-like computer operating system In 1991, as a graduate student at the University of Helsinki, Linus Torvalds became curious about OS & got frustrated with limitations of existing Unix/Minix licensing terms Developed his own variant called Linux (as his degree project!!!)
Linux Unix-like computer operating system In 1991, as a graduate student at the University of Helsinki, Linus Torvalds became curious about OS & got frustrated with limitations of existing Unix/Minix licensing terms Developed his own variant called Linux (as his degree project!!!) The core of Linux is the kernel, first released 5 October 1991 by Torvalds
Linux Unix-like computer operating system In 1991, as a graduate student at the University of Helsinki, Linus Torvalds became curious about OS & got frustrated with limitations of existing Unix/Minix licensing terms Developed his own variant called Linux (as his degree project!!!) The core of Linux is the kernel, first released 5 October 1991 by Torvalds Uses model of free and open source software development and distribution, prospered with GNU set of utilities
Linux Unix-like computer operating system In 1991, as a graduate student at the University of Helsinki, Linus Torvalds became curious about OS & got frustrated with limitations of existing Unix/Minix licensing terms Developed his own variant called Linux (as his degree project!!!) The core of Linux is the kernel, first released 5 October 1991 by Torvalds Uses model of free and open source software development and distribution, prospered with GNU set of utilities Today, Linux systems are everywhere, from embedded systems to supercomputers, from education to industry; in research labs, government establishments, financial institutions,
Linux internals Linux is made up of: The Linux kernel
Linux internals Linux is made up of: The Linux kernel version ending in even number is stable e.g. 3.0.8
Linux internals Linux is made up of: The Linux kernel version ending in even number is stable e.g. 3.0.8 version ending in odd number is unstable/testing/beta version e.g. 3.1.5
Linux internals Linux is made up of: The Linux kernel version ending in even number is stable e.g. 3.0.8 version ending in odd number is unstable/testing/beta version e.g. 3.1.5 The GNU tools like gcc, gawk, gnuplot etc.
Linux internals Linux is made up of: The Linux kernel version ending in even number is stable e.g. 3.0.8 version ending in odd number is unstable/testing/beta version e.g. 3.1.5 The GNU tools like gcc, gawk, gnuplot etc. A graphical desktop environment (GNOME/KDE/xfce etc.)
Linux internals Linux is made up of: The Linux kernel version ending in even number is stable e.g. 3.0.8 version ending in odd number is unstable/testing/beta version e.g. 3.1.5 The GNU tools like gcc, gawk, gnuplot etc. A graphical desktop environment (GNOME/KDE/xfce etc.) Application software: browsers, SciLab, eclipse etc.
Linux internals Linux is made up of: The Linux kernel version ending in even number is stable e.g. 3.0.8 version ending in odd number is unstable/testing/beta version e.g. 3.1.5 The GNU tools like gcc, gawk, gnuplot etc. A graphical desktop environment (GNOME/KDE/xfce etc.) Application software: browsers, SciLab, eclipse etc. None of these is useful independently
Linux internals Linux is made up of: The Linux kernel version ending in even number is stable e.g. 3.0.8 version ending in odd number is unstable/testing/beta version e.g. 3.1.5 The GNU tools like gcc, gawk, gnuplot etc. A graphical desktop environment (GNOME/KDE/xfce etc.) Application software: browsers, SciLab, eclipse etc. None of these is useful independently strength comes from their collaboration
Diagrammatic Representation Apllication S/W A graphical desktop environment GNU system tools/utilities Linux Kernel Computer H/W
Diagrammatic Representation Apllication S/W A graphical desktop environment shell GNU system tools/utilities Linux Kernel Computer H/W
Linux kernel core of the Linux system
Linux kernel core of the Linux system kernel controls all of the hardware and software on the computing system
Linux kernel core of the Linux system kernel controls all of the hardware and software on the computing system allocates resources as and when necessary
Linux kernel core of the Linux system kernel controls all of the hardware and software on the computing system allocates resources as and when necessary executes commands/processes as and when necessary
Linux kernel core of the Linux system kernel controls all of the hardware and software on the computing system allocates resources as and when necessary executes commands/processes as and when necessary its controls are divided generally into:
Linux kernel core of the Linux system kernel controls all of the hardware and software on the computing system allocates resources as and when necessary executes commands/processes as and when necessary its controls are divided generally into: Hardware management
Linux kernel core of the Linux system kernel controls all of the hardware and software on the computing system allocates resources as and when necessary executes commands/processes as and when necessary its controls are divided generally into: Hardware management Memory management
Linux kernel core of the Linux system kernel controls all of the hardware and software on the computing system allocates resources as and when necessary executes commands/processes as and when necessary its controls are divided generally into: Hardware management Memory management File-system management
Linux kernel core of the Linux system kernel controls all of the hardware and software on the computing system allocates resources as and when necessary executes commands/processes as and when necessary its controls are divided generally into: Hardware management Memory management File-system management Software execution management
The shell a basic way of communication between kernel & user
The shell a basic way of communication between kernel & user it is a text-based command interpreter
The shell a basic way of communication between kernel & user it is a text-based command interpreter shell presents several user friendly facilities
The shell a basic way of communication between kernel & user it is a text-based command interpreter shell presents several user friendly facilities allows input/output redirection to files/console using pipes
The shell a basic way of communication between kernel & user it is a text-based command interpreter shell presents several user friendly facilities allows input/output redirection to files/console using pipes allows personalization of environment: user can create aliases for commands
The shell a basic way of communication between kernel & user it is a text-based command interpreter shell presents several user friendly facilities allows input/output redirection to files/console using pipes allows personalization of environment: user can create aliases for commands shell presents a powerful programming tool to work with commands: complete with
The shell a basic way of communication between kernel & user it is a text-based command interpreter shell presents several user friendly facilities allows input/output redirection to files/console using pipes allows personalization of environment: user can create aliases for commands shell presents a powerful programming tool to work with commands: complete with conditional statements
The shell a basic way of communication between kernel & user it is a text-based command interpreter shell presents several user friendly facilities allows input/output redirection to files/console using pipes allows personalization of environment: user can create aliases for commands shell presents a powerful programming tool to work with commands: complete with conditional statements, loops
The shell a basic way of communication between kernel & user it is a text-based command interpreter shell presents several user friendly facilities allows input/output redirection to files/console using pipes allows personalization of environment: user can create aliases for commands shell presents a powerful programming tool to work with commands: complete with conditional statements, loops and functions!!!
Command a basic entity that can run a process
Command a basic entity that can run a process shell does the job when command name is entered at command prompt (possibly with some arguments)
Command a basic entity that can run a process shell does the job when command name is entered at command prompt (possibly with some arguments) some examples:
Command a basic entity that can run a process shell does the job when command name is entered at command prompt (possibly with some arguments) some examples: ls
Command a basic entity that can run a process shell does the job when command name is entered at command prompt (possibly with some arguments) some examples: ls ls -al
Command a basic entity that can run a process shell does the job when command name is entered at command prompt (possibly with some arguments) some examples: ls ls -al whoami
Command a basic entity that can run a process shell does the job when command name is entered at command prompt (possibly with some arguments) some examples: ls ls -al whoami date
Command a basic entity that can run a process shell does the job when command name is entered at command prompt (possibly with some arguments) some examples: ls ls -al whoami date possible to enter multiple commands on single line: a ; works as command terminator
Command a basic entity that can run a process shell does the job when command name is entered at command prompt (possibly with some arguments) some examples: ls ls -al whoami date possible to enter multiple commands on single line: a ; works as command terminator whoami; date;
Script script is nothing but a sequence of commands and control statements stored in a file
Script script is nothing but a sequence of commands and control statements stored in a file saves the effort of retyping that particular sequence of commands each time
Script script is nothing but a sequence of commands and control statements stored in a file saves the effort of retyping that particular sequence of commands each time script is a program a tool which can easily be modified
Script script is nothing but a sequence of commands and control statements stored in a file saves the effort of retyping that particular sequence of commands each time script is a program a tool which can easily be modified must be made executable by chmod +x [script file name]
Script script is nothing but a sequence of commands and control statements stored in a file saves the effort of retyping that particular sequence of commands each time script is a program a tool which can easily be modified must be made executable by chmod +x [script file name] making sure script can work across different flavours of Linux and/or different shells
Types of shell Two major types:
Types of shell Two major types: 1. the Bourne shell: includes sh, ksh, bash
Types of shell Two major types: 1. the Bourne shell: includes sh, ksh, bash 2. the C shell: includes csh, tcsh
Types of shell Two major types: 1. the Bourne shell: includes sh, ksh, bash 2. the C shell: includes csh, tcsh the Bourne type shells usually have $ as the prompt character
Types of shell Two major types: 1. the Bourne shell: includes sh, ksh, bash 2. the C shell: includes csh, tcsh the Bourne type shells usually have $ as the prompt character the C type shells usually have # as the prompt character
Types of shell Two major types: 1. the Bourne shell: includes sh, ksh, bash 2. the C shell: includes csh, tcsh the Bourne type shells usually have $ as the prompt character the C type shells usually have # as the prompt character sh is s POSIX standard shell
Shell Initialization When login program start shell, the parameters required for operation of shell to start are missing
Shell Initialization When login program start shell, the parameters required for operation of shell to start are missing shell undergoes an initialization phase
Shell Initialization When login program start shell, the parameters required for operation of shell to start are missing shell undergoes an initialization phase usually a two step process, involves reading the files
Shell Initialization When login program start shell, the parameters required for operation of shell to start are missing shell undergoes an initialization phase usually a two step process, involves reading the files /etc/profile
Shell Initialization When login program start shell, the parameters required for operation of shell to start are missing shell undergoes an initialization phase usually a two step process, involves reading the files /etc/profile.profile
Shell Initialization When login program start shell, the parameters required for operation of shell to start are missing shell undergoes an initialization phase usually a two step process, involves reading the files /etc/profile.profile If any file doesn t exist, it is skipped and no error is shown
Shell Initialization When login program start shell, the parameters required for operation of shell to start are missing shell undergoes an initialization phase usually a two step process, involves reading the files /etc/profile.profile If any file doesn t exist, it is skipped and no error is shown after reading both the files, the prompt character is presented
How login starts the shell login automatically starts the program: /bin/sh
How login starts the shell login automatically starts the program: /bin/sh by this, shell is put in interactive mode i.e. ready to interact with user
How login starts the shell login automatically starts the program: /bin/sh by this, shell is put in interactive mode i.e. ready to interact with user there is non-interactive mode of shell execution, where shell terminates after executing some commands e.g. when you logout
How login starts the shell login automatically starts the program: /bin/sh by this, shell is put in interactive mode i.e. ready to interact with user there is non-interactive mode of shell execution, where shell terminates after executing some commands e.g. when you logout shell can be started non-interactively by issuing command /bin/sh [script filename]
Commands for file-system handling mkdir cd pwd cp, mv, rm cat ls Editors: vi, gedit, nedit, emacs, chown, chgrp, chmod symbolic links: ln pipes:, >, <>>, <<
Next lecture Processes starting a process
Next lecture Processes starting a process listing running processes
Next lecture Processes starting a process listing running processes killing a process
Next lecture Processes starting a process listing running processes killing a process parent-child processes background/foreground precesses and their switching
References Ritchie, D.; Thompson, K.; The UNIX Time-Sharing System, Communications of ACM 17(1974), p. 365. Kernighan, B.W.; Pike, R.; The unix Programming Environment, Prentice-Hall, 1984. Bach, M.J.; The Design of The UNIX Operating System, Prentice-Hall, 1986. http://tldp.org/ https://www.kernel.org/ http://www.linuxfoundation.org/ CMS library books: CMS-78, CMS-877, CMS-1287, CMS-1626 Robbins a.; Beebe, N.H.F.; Classic Shell Scripting - Hidden Commands that Unlock the Power of Unix, O Reilly Media, 2005.