Bash Scripts Basic

download Bash Scripts Basic

of 24

Transcript of Bash Scripts Basic

  • 7/28/2019 Bash Scripts Basic

    1/24

    1.1

    The Unix System

    Unix is a Multi-user and Multi-tasking operating

    system History

    MULTICS (MULTIplexed Information and ComputingService) (1965)

    Ken Thompson (Bell Laboratories -1969)Space Wars, PDP-7, written in ASSEMBLER

    UNICS (UNiplexed Information and Computing Service)

    Ken Thompson, Dennis Ritchie (1970-1974)

    UNIX, PDP-11

    Ritchie develops C language (starting from B language)

    The third version of UNIX is written in C

    A paper on UNIX is published in 1974 (ACM TuringAward 1984)

  • 7/28/2019 Bash Scripts Basic

    2/24

    1.2

    The Unix System

    History,Bell Labs and AT&T UNIX PDP-11 is the computer of many departments of computer

    science and so UNIX becomes the OS of the Universities

    Bell Labs and AT&T UNIX development groups develop severalversion of UNIX:

    first edition (1969), ,seventh edition (1978,on PDP-11/70)

    a version for Interdata 8/2 and VAX UNIX for a network of computers

    System III (1982 - first commercial version)

    System V based on System III(1983)

    System V release 2, 3, 4 (1984 - 1989)

    SVR4 (System V release 4; 1989 AT&T and Sun Microsystems)

    1993: AT&T becomes a phone company and sells UNIX toNovell

  • 7/28/2019 Bash Scripts Basic

    3/24

    1.3

    The Unix System History University of California at Berkeley

    The most influential of the non-Bell Labs and non-AT&T

    UNIX development groups:.Thompson and some students develop 1BSD (Berkeley

    Software Distributions) starting from sixth edition (the first oneout of Bell Labs) (1978).

    3BSD - 4BSD UNIX resulted from DARPA funding to develop

    a standard UNIX system for government use.This series contains 4.1BSD, 4.2BSD, 4.3BSD and 4.4BSD

    (1980-93) and has some important new tools: virtual memory,paging, multiuser, network connection by means of TCP/IP.

    4.2BSD contains the text editorvi, the shell csh, Pascal and

    Lisp compilers,

    Sun Microsystem, DEC and some other companiesdecides to develop their UNIX version starting from BSDversions instead of System V.

  • 7/28/2019 Bash Scripts Basic

    4/24

    1.4

    History of

    UNIX Versions

  • 7/28/2019 Bash Scripts Basic

    5/24

    1.5

    The Standardization Projects

    History

    Several standardization projects seek to consolidate thevariant flavors of UNIX leading to one programming

    interface to UNIX. The most important are:

    POSIX (Portable Operating System): merge of System V

    and BSD (1984)

    IBM, DEC, Hewlett-Packard create OSF (Open Software

    Foundation) and their UNIX system is OSF/1 (1988)

    X/OPEN defines the Single UNIX specification (1993) and

    the systems satisfying this specification have the trademark

    UNIX 95Open group (merge of Open Software Foundation and

    X/OPEN; http://www.opengroup.com 1996)

    Definition of the second version of the Single UNIX

    specification (1997) with the trademark UNIX 98

    http://www.opengroup.com/http://www.opengroup.com/http://www.opengroup.com/http://www.opengroup.com/http://www.opengroup.com/http://www.opengroup.com/http://www.opengroup.com/http://www.opengroup.com/
  • 7/28/2019 Bash Scripts Basic

    6/24

    1.6

    A variant of the UNIX System

    Although there are many version of UNIX, themost important companies provide versionbased on UNIX System V Release 4 (SVR4) andthe last the Single UNIX specification ex. Solaris 2.x is the most widely used and most

    successful commercial UNIX implementation.

    These systems are very big and verycomplicated (the contrary of the Thompsonsbasic idea) and in same case expensive.

    So, Tanenbaum develops MINIX (1987) a smallfree UNIX system (11800 rows of C code and800 rows of Assembler code) satisfying POSIX.MINIX is a free educational system based on micro-

    kernel model (www.cs.vu.nl/~ast/minix.html)

    http://www.cs.vu.nl/~ast/minix.htmlhttp://www.cs.vu.nl/~ast/minix.htmlhttp://www.cs.vu.nl/~ast/minix.htmlhttp://www.cs.vu.nl/~ast/minix.htmlhttp://www.cs.vu.nl/~ast/minix.htmlhttp://www.cs.vu.nl/~ast/minix.htmlhttp://www.cs.vu.nl/~ast/minix.htmlhttp://www.cs.vu.nl/~ast/minix.htmlhttp://www.cs.vu.nl/~ast/minix.htmlhttp://www.cs.vu.nl/~ast/minix.html
  • 7/28/2019 Bash Scripts Basic

    7/24

    1.7

    Common System Components of an OS

    Process Management

    Main Memory Management

    File Management

    Secondary Memory Management

    I/O System Management

    Networking

    Protection System

    Command-Interpreter System (Shell)

  • 7/28/2019 Bash Scripts Basic

    8/24

    1.8

    System Structure

    System structure: defines the connectionsand manages the System Components

    Some system structuresa. Monolithic

    b. Client-Server model (micro-kernel)

  • 7/28/2019 Bash Scripts Basic

    9/24

    1.9

    Monolithic Operating System Structure

    A monolithic system has not a well defined structure. Itincludes virtually all of the operating-system functionalityin one large block of code that runs as a single processwith a single address space. All the functionalcomponents of the kernel have access to all of its internaldata structures and routines.

  • 7/28/2019 Bash Scripts Basic

    10/24

    1.10

    The Client-Server Model

    Moves as much from the kernel into user

    space. In this way it remains only a micro-kernel.

    Communication takes place between user

    modules using message passing.

  • 7/28/2019 Bash Scripts Basic

    11/24

    1.11

    The Client-Server Model

    Advantages

    easier to extend a micro-kernel

    easier to port the operating system to new architectures

    more reliable (less code is running in kernel mode)

    more secure

    Disadvantages

    Deterioration of the performances

    MINIX has the I/O drivers into the kernel (this is for

    technical reasons connected to 8088 architecture), while

    the Main Memory Management, and the File

    Management are two different user processes.

  • 7/28/2019 Bash Scripts Basic

    12/24

    1.12

    The Linux System

    There is not a free BSD system at the end of the

    eighties, and so many members of MINIXnewsgroup ask to Tanenbaum to introduce many

    modifications for improving the performances of

    MINIX. Some of these modifications could

    change the original educational project ofTanenbaum, and so often he said NO to these

    requests.

    So, Linus Torvalds using a pc 386 with MINIXdevelops a small but self-contained kernel in

    1991 (Linux 0.01), with the major design goal of

    UNIX compatibility (i.e., satisfying POSIX).

  • 7/28/2019 Bash Scripts Basic

    13/24

    1.13

    Linux 0.01

    The first version of Linux (Linux 0.01) has some of

    features of MINIX (ex. File system), but the maindifferences between Linux and MINIX are: The Linux kernel uses a monolithic model, and it has

    many more functions than the micro-kernel of MINIX.

    From a theoretical point of view MINIX is better thanLinux, but from a practical point of view theperformances of Linux are better than that one ofMINIX.

    However, for a description of the point of view of

    Torvalds on the advantages-disadvantages of Linux-MINIX see the flame war between Torvalds andTanenbaum in:

    Rivoluzionario per caso: come ho creato Linux (solo perdivertirmi), Linus Torvalds, Garzanti

  • 7/28/2019 Bash Scripts Basic

    14/24

    1.14

    The Linux Kernel

    Linux 0.01 (May 1991) had no networking, ran only on80386-compatible Intel processors and on PC hardware,

    had extremely limited device-drive support, and supportedonly the Minix file system.

    Linux 1.0 (March 1994) included these new features: Support forUNIXs standard TCP/IP networking protocols

    BSD-compatible socket interface for networking programming

    Device-driver support for running IP over an Ethernet

    Enhanced file system

    Support for a range of SCSI controllers for high-performance diskaccess

    Extra hardware support

    This version is sufficient compatible with UNIX and manypeople are interested in developing Linux under Torvaldsupervision.

    Linux 1.2 (March 1995) was the final PC-only Linux kernel.

  • 7/28/2019 Bash Scripts Basic

    15/24

    1.15

    Linux 2.0 Released in June 1996, 2.0 added two major new

    capabilities:

    Support for multiple architectures Support for multiprocessor architectures

    Other new features included: Improved memory-management code

    Improved TCP/IP performance

    Support for internal kernel threads, for handling dependenciesbetween loadable modules, and for automatic loading of modules ondemand.

    Standardized configuration interface

    Available for Motorola 68000-series processors, Sun Sparc

    systems, and for PC and PowerMac systems. Linux 2.2 January 1999 improves some aspects of Linux 2.0

    The last release is Linux 2.4.20 (production) Linux 2.5.64(development)

    http://www.linuxhq.com/kernel/v2.4/20/index.htmlhttp://www.linuxhq.com/kernel/v2.5/64/index.htmlhttp://www.linuxhq.com/kernel/v2.5/64/index.htmlhttp://www.linuxhq.com/kernel/v2.5/64/index.htmlhttp://www.linuxhq.com/kernel/v2.5/64/index.htmlhttp://www.linuxhq.com/kernel/v2.5/64/index.htmlhttp://www.linuxhq.com/kernel/v2.5/64/index.htmlhttp://www.linuxhq.com/kernel/v2.5/64/index.htmlhttp://www.linuxhq.com/kernel/v2.5/64/index.htmlhttp://www.linuxhq.com/kernel/v2.4/20/index.htmlhttp://www.linuxhq.com/kernel/v2.4/20/index.htmlhttp://www.linuxhq.com/kernel/v2.4/20/index.htmlhttp://www.linuxhq.com/kernel/v2.4/20/index.htmlhttp://www.linuxhq.com/kernel/v2.4/20/index.htmlhttp://www.linuxhq.com/kernel/v2.4/20/index.htmlhttp://www.linuxhq.com/kernel/v2.4/20/index.html
  • 7/28/2019 Bash Scripts Basic

    16/24

    1.16

    The Moral of the Story

    Linux is a modern, free operating system based on UNIXstandards.

    First developed as a small but self-contained kernel in1991 by Linus Torvalds, with the major design goal ofUNIX compatibility.

    Its history has been one of collaboration by many users

    from all around the world, corresponding almostexclusively over the Internet (software open source).

    It has been designed to run efficiently and reliably oncommon PC hardware, but also runs on a variety of otherplatforms.

    The core Linux operating system kernel is entirelyoriginal, but it can run much existing free UNIX software,resulting in an entire UNIX-compatible operating systemfree from proprietary code.

  • 7/28/2019 Bash Scripts Basic

    17/24

    1.17

    The Linux System

    Linux uses many tools developed as part ofBerkeleys BSD

    operating system, System V, MITs X Window System, andthe Free Software Foundation's GNU project.

    The main system libraries were started by the GNU (GNUs

    Not Unix) project (ex. gcc (GNU C compiler)), with

    improvements provided by the Linux community. Linux networking-administration tools were derived from 4.3

    BSD code; recent BSD derivatives such as FreeBSD have

    borrowed code from Linux in return.

    The Linux system is maintained by a network of developerscollaborating on Internet (see /usr/src/linux/CREDITS), with

    a small number of public ftp sites acting as de facto

    standard repositories.

    http://localhost/var/www/apps/conversion/tmp/scratch_4/gnu/Panoramica%20del%20Progetto%20GNU%20-%20Free%20Software%20Foundation%20(FSF).htmhttp://localhost/var/www/apps/conversion/tmp/scratch_4/gnu/Panoramica%20del%20Progetto%20GNU%20-%20Free%20Software%20Foundation%20(FSF).htmhttp://localhost/var/www/apps/conversion/tmp/scratch_4/gnu/Panoramica%20del%20Progetto%20GNU%20-%20Free%20Software%20Foundation%20(FSF).htmhttp://localhost/var/www/apps/conversion/tmp/scratch_4/gnu/Panoramica%20del%20Progetto%20GNU%20-%20Free%20Software%20Foundation%20(FSF).htmhttp://localhost/var/www/apps/conversion/tmp/scratch_4/gnu/Panoramica%20del%20Progetto%20GNU%20-%20Free%20Software%20Foundation%20(FSF).htmhttp://localhost/var/www/apps/conversion/tmp/scratch_4/gnu/Panoramica%20del%20Progetto%20GNU%20-%20Free%20Software%20Foundation%20(FSF).htmhttp://localhost/var/www/apps/conversion/tmp/scratch_4/gnu/Panoramica%20del%20Progetto%20GNU%20-%20Free%20Software%20Foundation%20(FSF).htmhttp://localhost/var/www/apps/conversion/tmp/scratch_4/gnu/Panoramica%20del%20Progetto%20GNU%20-%20Free%20Software%20Foundation%20(FSF).htmhttp://localhost/var/www/apps/conversion/tmp/scratch_4/gnu/Panoramica%20del%20Progetto%20GNU%20-%20Free%20Software%20Foundation%20(FSF).htmhttp://localhost/var/www/apps/conversion/tmp/scratch_4/gnu/Panoramica%20del%20Progetto%20GNU%20-%20Free%20Software%20Foundation%20(FSF).htm
  • 7/28/2019 Bash Scripts Basic

    18/24

    1.18

    Linux Distributions

    Standard, precompiled sets of packages, or distributions,

    include the basic Linux system, system installation andmanagement utilities, and ready-to-install packages of

    common UNIX tools.

    The first distributions managed these packages by simply

    providing a means of unpacking all the files into theappropriate places; modern distributions include advanced

    package management.

    Red Hat, Debian, SuSE, Mandrake are popular

    distributions from commercial and noncommercial sources,

    respectively (see www.linux.org).

    The RPM Package file format permits compatibility among

    the various Linux distributions (see www.linuxbase.org).

    http://www.linux.org/http://www.linuxbase.org/http://www.linuxbase.org/http://www.linuxbase.org/http://www.linuxbase.org/http://www.linuxbase.org/http://www.linuxbase.org/http://www.linux.org/http://www.linux.org/http://www.linux.org/http://www.linux.org/http://www.linux.org/
  • 7/28/2019 Bash Scripts Basic

    19/24

    1.19

    Which distribution to use ?

    RedHat (www.redhat.com)

    Big, professional, very widely used

    Debian (www.debian.org/)

    Open development model, excellent packaging

    system

    Mandrake (www.mandrakesoft.com)

    Aims to be very easy to install and use

    SuSE (www.suse.com/)

    Compromise between Red Hat and Mandrake

    Slackware (www.slackware.com/)

    Most traditional; little extra help

    http://www.redhat.com/http://www.debian.org/http://www.mandrakesoft.com/http://www.suse.com/http://www.slackware.com/http://www.slackware.com/http://www.slackware.com/http://www.slackware.com/http://www.slackware.com/http://www.slackware.com/http://www.suse.com/http://www.suse.com/http://www.suse.com/http://www.suse.com/http://www.suse.com/http://www.mandrakesoft.com/http://www.mandrakesoft.com/http://www.mandrakesoft.com/http://www.mandrakesoft.com/http://www.mandrakesoft.com/http://www.debian.org/http://www.debian.org/http://www.debian.org/http://www.debian.org/http://www.debian.org/http://www.redhat.com/http://www.redhat.com/http://www.redhat.com/http://www.redhat.com/http://www.redhat.com/
  • 7/28/2019 Bash Scripts Basic

    20/24

    1.20

    Mandrake Distribution

    Mandrake provides a simple and friendly

    distribution. Maybe, it is the best distribution for thedesktop (www.mandrakesoft.com).

    The last release of Mandrake distribution isMandrake 9.0 Dolphin and it is contained in three

    CDs. It contains the Linux kernel 2.4.19. The minimum installation requires only the first

    CD and takes only 60MB. The other two CDcontain many packages.

    There are two different GUI (Graphical UserInterface): KDE (release 3.0.3) and GNOME (2.0.1)

    http://www.mandrakesoft.com/http://www.mandrakesoft.com/http://www.mandrakesoft.com/http://www.mandrakesoft.com/http://www.mandrakesoft.com/http://www.mandrakesoft.com/
  • 7/28/2019 Bash Scripts Basic

    21/24

    1.21

    Mandrake Installation

    The installation of Mandrake 9.0 Dolphin is very easy. You can select Italian language

    The first time you should choose the installation forprincipiante

    The more difficult step is the partition of the hard disk. Apartition correspond to a logic disk. If you want to installsome operating systems on your hard disk, you have to define

    a partition for each OS. A disk has at most 4 primarypartitions. You can make these partitions by means of thecommand fdisk.The Mandrake installation provides asimple graphical tool for making the Linux partitions.

    We wish to point out that from DOS/Windows you cannot see

    the other partitions. On the contrary, Linux see DOS/Windowspartition (/mnt/windows).

    However, all the steps of the installation will beillustrated during the lecture.

  • 7/28/2019 Bash Scripts Basic

    22/24

    1.22

    The Moral of the Installation

    Varies from distribution to distribution

    Most modern distributions make it easy: Buy CD / download and burn CD image

    Boot

    Follow instructions

    Need to think about partitioning.

    Install a boot loader (probably LILO (LInux

    LOader), maybe something else). This needs tobe configured to boot whatever other operatingsystems you have installed.

  • 7/28/2019 Bash Scripts Basic

    23/24

    1.23

    Users Linux is an intrinsically multi-user system

    Every user on the system has its own username

    and password The root user has ultimate power to run the

    system. You should not log in as rootunlessyou really need to.

    During installation, you should have beenprompted for a root password and also ausername and password for an ordinary useraccount.

    The commandpasswd allows to change thepassword.

    Careful: you have to perform the programshutdown h now before to switch off the PC

  • 7/28/2019 Bash Scripts Basic

    24/24

    1.24

    Linux Licensing

    The Linux kernel is distributed under the GNU

    General Public License (GPL), the terms of whichare set out by the Free Software Foundation. See /usr/src/linux/COPYING

    The main consequence of GPL is that anyoneusing Linux, or creating their own derivative ofLinux, may not make the derived productproprietary; software released under the GPL may

    not be redistributed as a binary-only product.

    For a deeper examination of this subject seewww.gnu.org/home.it.html

    http://www.gnu.org/home.it.htmlhttp://www.gnu.org/home.it.htmlhttp://www.gnu.org/home.it.htmlhttp://www.gnu.org/home.it.htmlhttp://www.gnu.org/home.it.htmlhttp://www.gnu.org/home.it.htmlhttp://www.gnu.org/home.it.htmlhttp://www.gnu.org/home.it.htmlhttp://www.gnu.org/home.it.htmlhttp://www.gnu.org/home.it.html