Unix basics
     System Software




                                       Roman Prykhodchenko
                            rprikhodchenko@kture.kharkov.ua


Tuesday, February 8, 2011
Agenda


                    •       History

                    •       Terminology

                    •       Unix commons




Tuesday, February 8, 2011
History




Tuesday, February 8, 2011
UNIX


                    •       UNIX is a computer operating system originally
                            developed in 1969 by a group of AT&T employees
                            at Bell Labs.

                    •       Today UNIX is a family of the operating systems
                            that correspond to the Single Unix Specification.




Tuesday, February 8, 2011
Main events
                    •       1969 – MULTICS, the first implementation of the
                            UNIX operating system for General Electric
                            GE-645 computer.

                    •       1976 – UNIX Timesharing System 6

                    •       1977 – Berkley Software Distribution (BSD)

                    •       1979 – UNIX Timesharing System 7

                    •       1982 – BSD 4.1 implements TCP/IP




Tuesday, February 8, 2011
People
                       Denis Ritchie   Brian Kernighan   Ken Thompson




Tuesday, February 8, 2011
Main events

                    •       1988 – First edition of POSIX standard

                    •       1989 – The ANSI C standard is published

                    •       1983 – Richard Stallman initiated the GNU project

                    •       1992 – The GNU is using the Linux kernel

                    •       1994 – 386 BSD is released




Tuesday, February 8, 2011
People
                            Linus Torvalds   Richard Stallman




Tuesday, February 8, 2011
People
                            William Jolitz   Lynne Jolitz




Tuesday, February 8, 2011
Terminology




Tuesday, February 8, 2011
*nix


                    •       UNIX-like operating system (or just *nix) is an
                            operating system that behaves similar to UNIX but
                            does not correspond to the Single Unix
                            Specification.




Tuesday, February 8, 2011
SUS


                    •       Single UNIX specification is the collective name of
                            a family of standards for computer operating
                            systems to qualify for the name "Unix"




Tuesday, February 8, 2011
POSIX
                    •       POSIX (Portable Operating System Interface for
                            uniX)is the standard for the UNIX operating
                            system published by IEEE Computer Society.

                    •       Includes:

                            •   System API

                            •   Shell interface

                            •   API of the system utilities




Tuesday, February 8, 2011
Time-sharing


                    •       Time-sharing operating system shares a computing
                            resource among many users by means of
                            multiprogramming and multi-tasking.




Tuesday, February 8, 2011
Unix commons




Tuesday, February 8, 2011
Key properties
                    •       Portability

                    •       Preemptive multitasking

                    •       Virtual memory

                    •       Multilevel architecture

                    •       Support of asynchronous processes

                    •       Device-independent I/O




Tuesday, February 8, 2011
Software conception
                    •       Do only one thing and do it well.
                            For each task the system can perform there is a
                            separate program.

                    •       Examples:
                            cp – copies a file
                            cat – prints a file’s contents

                    •       Benefits:
                            - Simplicity
                            - Number of errors is relatively small.




Tuesday, February 8, 2011
Everything is a file
                    •       Every computer’s resource is represented by a file.

                    •       Examples:
                            /home/john/text.txt – John’s text file
                            /dev/sda – first hard drive
                            /proc/scsi – information about any devices
                            connected via a SCSI or RAID controller

                    •       Benefits:
                            Device-independent I/O operations.




Tuesday, February 8, 2011
Multilevel architecture


                    •       Each software type runs on an appropriate level

                    •       Memory is not shared between different levels

                    •       System calls for inter-level communications




Tuesday, February 8, 2011
Multilevel architecture

                            Application software, network services, utilities

                   System software (command interpreters, protocols...)

                                              System calls

                                                 Kernel




Tuesday, February 8, 2011
Kernel

                    •       Scheduling

                    •       Memory management

                    •       Interruptions processing

                    •       Inter-process communication

                    •       Low-level device support




Tuesday, February 8, 2011
Kernel

                    •       Monolithic kernel

                    •       Microkernel

                            •   Nanokernel

                            •   Exokernel

                    •       Hybrid kernel




Tuesday, February 8, 2011
Kernel




Tuesday, February 8, 2011
Kernel
                                 “Exokernel”
                            based Operating System




Tuesday, February 8, 2011
System calls


                    •       Process management

                    •       Implementation of I/O operations

                    •       Bind user actions to drivers




Tuesday, February 8, 2011
Signals

                    •       Signals are an approach of inter-process
                            communication (IPC)

                    •       Signal is an asynchronous message sent to signal

                    •       Operating system interrupts the process when it is
                            sent a signal




Tuesday, February 8, 2011
Signals


                    •       A process can implement a handler for different
                            kind of signals

                    •       Default handler kills the process

                    •       Some signals can not be handled




Tuesday, February 8, 2011
Signals
                 • Sources of signals:
                   • Keyboard shortcuts
                   • Kernel
                     • Hardware exception
                     • Wrong system call
                     • I/O operations
                   • A process

Tuesday, February 8, 2011
Shell
                Shell is a command-line interpreter that provides a
                traditional user interface for the Unix operating system
                and for Unix-like systems.

                Most popular are: bash, sh, csh, zsh




                We will mostly use bash.



Tuesday, February 8, 2011
Common syntax
                $ app_name [options] [parameters]


                Options begin with - or --
                -o1 [value] -o2 -o3 [value]
                or
                -o1o2o3


                Examples:
                $ tar -x -j -v -f archive.tar.gz
                $ tar -xjvf archive.tar.gz


                Parameters are usually required.
                $ rdesktop -f -u UserName 192.168.0.124



Tuesday, February 8, 2011
Manual pages
                Man application shows a manual page for specified
                application:
                $ man {app_name}


                Or you can use option -h to see a short help:
                $ tar -h




Tuesday, February 8, 2011
File system hierarchy standard
              /                Rood directory
              /bin/            Essential command binaries
              /boot/           Static bootloader
              /dev/            Devices represented by files
              /etc/            Host-specific configuration data
              /lib/            Basic shared libraries and kernel modules
              /mnt/            Temporary mount point
              /opt/            Optional software
              /sbin/           Basic system software
              /tmp/            Temporary data
              /usr/            Secondary hierarchy
              /var/            Variable data




Tuesday, February 8, 2011
PATH
                PATH is an environment variable used by shells for
                searching for applications.

                Applications located in directories that are included to
                PATH can be launched without specifying full path.
                $ echo $PATH
                /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11R6/
                bin


                You can modify PATH
                $ PATH=$PATH:~/bin




Tuesday, February 8, 2011
Navigation
              cd             Navigates to specified directory

              ls             Shows current directory’s contents

              pwd            Shows current directory

              mkdir          Creates a directory

              rmdir          Removes a directory

              touch          Modifies last change date

              rm             Deletes a file




Tuesday, February 8, 2011
Inodes
                Inode is an index descriptor of a filesystem resource.

                - Every resource has own inode number.
                - File name is a link to inode.

                Example:
                $ ls -dl /usr/local
                drwxr-xr-x    8 root   root          240 Dec 22

                /usr/local
                /usr/local/.
                /usr/local/bin/..
                /usr/local/games/..
                /usr/local/lib/..
                /usr/local/sbin/..
                /usr/local/share/..
                /usr/local/src/..


Tuesday, February 8, 2011
Questions?




Tuesday, February 8, 2011

1 Unix basics. Part 1

  • 1.
    Unix basics System Software Roman Prykhodchenko rprikhodchenko@kture.kharkov.ua Tuesday, February 8, 2011
  • 2.
    Agenda • History • Terminology • Unix commons Tuesday, February 8, 2011
  • 3.
  • 4.
    UNIX • UNIX is a computer operating system originally developed in 1969 by a group of AT&T employees at Bell Labs. • Today UNIX is a family of the operating systems that correspond to the Single Unix Specification. Tuesday, February 8, 2011
  • 5.
    Main events • 1969 – MULTICS, the first implementation of the UNIX operating system for General Electric GE-645 computer. • 1976 – UNIX Timesharing System 6 • 1977 – Berkley Software Distribution (BSD) • 1979 – UNIX Timesharing System 7 • 1982 – BSD 4.1 implements TCP/IP Tuesday, February 8, 2011
  • 6.
    People Denis Ritchie Brian Kernighan Ken Thompson Tuesday, February 8, 2011
  • 7.
    Main events • 1988 – First edition of POSIX standard • 1989 – The ANSI C standard is published • 1983 – Richard Stallman initiated the GNU project • 1992 – The GNU is using the Linux kernel • 1994 – 386 BSD is released Tuesday, February 8, 2011
  • 8.
    People Linus Torvalds Richard Stallman Tuesday, February 8, 2011
  • 9.
    People William Jolitz Lynne Jolitz Tuesday, February 8, 2011
  • 10.
  • 11.
    *nix • UNIX-like operating system (or just *nix) is an operating system that behaves similar to UNIX but does not correspond to the Single Unix Specification. Tuesday, February 8, 2011
  • 12.
    SUS • Single UNIX specification is the collective name of a family of standards for computer operating systems to qualify for the name "Unix" Tuesday, February 8, 2011
  • 13.
    POSIX • POSIX (Portable Operating System Interface for uniX)is the standard for the UNIX operating system published by IEEE Computer Society. • Includes: • System API • Shell interface • API of the system utilities Tuesday, February 8, 2011
  • 14.
    Time-sharing • Time-sharing operating system shares a computing resource among many users by means of multiprogramming and multi-tasking. Tuesday, February 8, 2011
  • 15.
  • 16.
    Key properties • Portability • Preemptive multitasking • Virtual memory • Multilevel architecture • Support of asynchronous processes • Device-independent I/O Tuesday, February 8, 2011
  • 17.
    Software conception • Do only one thing and do it well. For each task the system can perform there is a separate program. • Examples: cp – copies a file cat – prints a file’s contents • Benefits: - Simplicity - Number of errors is relatively small. Tuesday, February 8, 2011
  • 18.
    Everything is afile • Every computer’s resource is represented by a file. • Examples: /home/john/text.txt – John’s text file /dev/sda – first hard drive /proc/scsi – information about any devices connected via a SCSI or RAID controller • Benefits: Device-independent I/O operations. Tuesday, February 8, 2011
  • 19.
    Multilevel architecture • Each software type runs on an appropriate level • Memory is not shared between different levels • System calls for inter-level communications Tuesday, February 8, 2011
  • 20.
    Multilevel architecture Application software, network services, utilities System software (command interpreters, protocols...) System calls Kernel Tuesday, February 8, 2011
  • 21.
    Kernel • Scheduling • Memory management • Interruptions processing • Inter-process communication • Low-level device support Tuesday, February 8, 2011
  • 22.
    Kernel • Monolithic kernel • Microkernel • Nanokernel • Exokernel • Hybrid kernel Tuesday, February 8, 2011
  • 23.
  • 24.
    Kernel “Exokernel” based Operating System Tuesday, February 8, 2011
  • 25.
    System calls • Process management • Implementation of I/O operations • Bind user actions to drivers Tuesday, February 8, 2011
  • 26.
    Signals • Signals are an approach of inter-process communication (IPC) • Signal is an asynchronous message sent to signal • Operating system interrupts the process when it is sent a signal Tuesday, February 8, 2011
  • 27.
    Signals • A process can implement a handler for different kind of signals • Default handler kills the process • Some signals can not be handled Tuesday, February 8, 2011
  • 28.
    Signals • Sources of signals: • Keyboard shortcuts • Kernel • Hardware exception • Wrong system call • I/O operations • A process Tuesday, February 8, 2011
  • 29.
    Shell Shell is a command-line interpreter that provides a traditional user interface for the Unix operating system and for Unix-like systems. Most popular are: bash, sh, csh, zsh We will mostly use bash. Tuesday, February 8, 2011
  • 30.
    Common syntax $ app_name [options] [parameters] Options begin with - or -- -o1 [value] -o2 -o3 [value] or -o1o2o3 Examples: $ tar -x -j -v -f archive.tar.gz $ tar -xjvf archive.tar.gz Parameters are usually required. $ rdesktop -f -u UserName 192.168.0.124 Tuesday, February 8, 2011
  • 31.
    Manual pages Man application shows a manual page for specified application: $ man {app_name} Or you can use option -h to see a short help: $ tar -h Tuesday, February 8, 2011
  • 32.
    File system hierarchystandard / Rood directory /bin/ Essential command binaries /boot/ Static bootloader /dev/ Devices represented by files /etc/ Host-specific configuration data /lib/ Basic shared libraries and kernel modules /mnt/ Temporary mount point /opt/ Optional software /sbin/ Basic system software /tmp/ Temporary data /usr/ Secondary hierarchy /var/ Variable data Tuesday, February 8, 2011
  • 33.
    PATH PATH is an environment variable used by shells for searching for applications. Applications located in directories that are included to PATH can be launched without specifying full path. $ echo $PATH /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11R6/ bin You can modify PATH $ PATH=$PATH:~/bin Tuesday, February 8, 2011
  • 34.
    Navigation cd Navigates to specified directory ls Shows current directory’s contents pwd Shows current directory mkdir Creates a directory rmdir Removes a directory touch Modifies last change date rm Deletes a file Tuesday, February 8, 2011
  • 35.
    Inodes Inode is an index descriptor of a filesystem resource. - Every resource has own inode number. - File name is a link to inode. Example: $ ls -dl /usr/local drwxr-xr-x 8 root root 240 Dec 22 /usr/local /usr/local/. /usr/local/bin/.. /usr/local/games/.. /usr/local/lib/.. /usr/local/sbin/.. /usr/local/share/.. /usr/local/src/.. Tuesday, February 8, 2011
  • 36.