Introduction to LinuxUNIX - PowerPoint PPT Presentation

1 / 14
About This Presentation
Title:

Introduction to LinuxUNIX

Description:

Ken Thompson and Dennis Richie. Working version (in 1970) on a DEC PDP 11/70 ... June 81: Berkeley UNIX 4.1 BSD (enhanced with vi, csh, and virtual memory management) ... – PowerPoint PPT presentation

Number of Views:77
Avg rating:3.0/5.0
Slides: 15
Provided by: GaryJ
Category:

less

Transcript and Presenter's Notes

Title: Introduction to LinuxUNIX


1
Introduction toLinux/UNIX
2
History
  • UNIX beginnings in 1969 (Linus Torvalds is born!)
  • AT T Bell Laboratories
  • Ken Thompson and Dennis Richie
  • Working version (in 1970) on a DEC PDP 11/70
  • UNIX and C Relationship
  • June 81 Berkeley UNIX 4.1 BSD (enhanced with vi,
    csh, and virtual memory management)
  • 1983 Berkeley UNIX 4.2 BSD (added TCP/IP
    networking, sockets and a new file system)
  • Later ? UNIX/32V, SYSTEM III, SYSTEM V
  • and ? ? Linux is introduced by Linus B. Torvalds
    in 1991
  • 1994 -- RedHat Linux is introduced

3
GNU Project
  • Launched in 1984 to develop a complete UNIX
    Operating system that is free software
  • www.gnu.org
  • Organized by free software foundation
  • Free GNU Software http//directory.fsf.org/GNU/
  • Usually C code, but some C
  • GNU has a 72-page document of coding standards
    well-written code
  • POSIX Portable Operating System Interface
  • An IEEE standard which describes the behaviour of
    UNIX and UNIX-like operating systems.
  • POSIX support assures code portability between
    systems and is increasingly mandated for
    commercial applications and government contracts

4
Basics
  • Talking to Linux/UNIX ? The Shell
  • displays the prompt for your next command and
    parses your command input and executes it
  • several different kinds Bourne Shell or sh, ksh,
    csh, and tcsh
  • Login shell
  • A sample .bashrc http//web.umr.edu/ercal/284/
    .bashrc
  • A sample .bash_login http//web.umr.edu/ercal/2
    84/.bash_login
  • A sample .login http//web.umr.edu/ercal/284/.
    login
  • A sample .userlogin http//web.umr.edu/ercal/28
    4/.userlogin
  • A sample .cshrc http//web.umr.edu/ercal/284/.
    cshrc
  • A sample .usercshrc http//web.umr.edu/ercal/2
    84/.usercshrc
  • A sample .alias http//web.umr.edu/ercal/284/.
    alias
  • Home directory
  • /afs/umr.edu/users/YourLoginName or
  • YourLoginName (e.g. ercal sea)
  • File/Directory structure ? A tree

5
here Useful UNIX/Linux Commands
  • http//web.umr.edu/ercal/284/UNIX-commands.txt
  • A subset of these commands are
  • alias/unalias, bg, cat, cc, cd, chmod, cp, csh,
    diff, du echo, emacs, fg, gcc, grep, history,
    jobs, kill, ln logout, lpq, lpr, lprm, ls, man,
    mkdir, more, mv, printenv, ps, pwd, rlogin, rm,
    rmdir, rsh, script, set, setenv, source tail,
    tar, telnet, touch, unset unsetenv uudecode,
    uuencode, vacation, vi, wc, which, xterm

6
More Basics
  • Access Control
  • cd ls l and chmod commands
  • rwx rwx rwx ? 7 7 7 rwx r_x r_x ? 7
    5 5
  • Consulting the on-line manual ? man command
  • Compiling with gcc and g
  • I/O Redirection
  • gt Redirect output
  • lt Redirect input
  • p Run p in the background (try also jobs,
    Z, bg, fg, ps, and kill)
  • p1 p2 Pipe output of p1 as input for p2
  • p gtgt f Append output of p into file f

7
Command-line arguments
  • dell2gt cat filename.c
  • int main( int argc, char argv)

argc 2
argv
cat \0
0
1
filename.c \0
NULL
2
8
Text Editing / e-mail / data compression
  • vi (/usr/bin/vim)
  • GNU emacs (/usr/bin/emacs)
  • Electronic Mail /usr/bin/mutt
  • /bin/gzip /bin/gunzip

9
Writing Simple Shell Scripts
  • Bourne Shell Programming (bash standard Linux
    shell)
  • http//steve-parker.org/sh/sh.shtml
  • http//www-106.ibm.com/developerworks/linux/librar
    y/l-bash.html
  • http//www-106.ibm.com/developerworks/linux/librar
    y/l-bash2.html
  • Example http//web.umr.edu/ercal/284/ShellScript
    s/args
  • !/usr/bin/env bash
  • echo name of script is 0
  • echo first argument is 1
  • echo second argument is 2
  • echo third argument is 3
  • echo eleventh argument is 11
  • echo number of arguments is

10
More examples
  • http//web.umr.edu/ercal/284/ShellScripts/SampleS
    cripts.html
  • Example 1 Remove "Cntl-M" from a given file
  • Example 2 Keep track of users every 20 seconds
    - ( problem with while )
  • Example 3 List all files in all subdirectories
    recursively
  • Example 4 List and count all files in all
    subdirectories
  • Example 5 Find the path(s) to a file recursively

11
Linux/UNIX Process Model
  • Process Attributes
  • A unique process identifier (PID) - getpid()
    call
  • parent process (PPID) getppid() call
  • permission identifiers (UID, GID etc.)
  • An address space
  • A current working directory (.)
  • A set of open files, directories
  • environment variables env or printenv (e.g.
    PATH . HOME)
  • scheduling priority

12
Linux/UNIX Processes
  • ps acefl more
  • ps acefl grep init
  • the first, primordial process ? init PID1
    PPID0 (kernel)
  • All other processes are descendants of init.
  • Each process has only one parent but could have
    many children
  • Child processes inherit the environment of the
    parent process
  • All programs start with three files open stdin,
    stdout, stderr

13
make facility
  • used for maintaining component modules in a
    software system.
  • The default file for make is called makefile or
    Makefile.
  • Otherwise, use
  • make f filename
  • A makefile consists of a series of sections each
    composed of target, dependencies and commands.
  • Example http//web.umr.edu/price/cs328/makeI
  • Every command line must begin with a tab.
  • make target returns without doing anything if no
    changes are made to any of the files involved in
    making the target.

14
makefile
  • A simple Makefile example
  • default all
  • all driver
  • driver program.o \
  • scanner.o
  • _at_echo "Building _at_"
  • g program.o scanner.o -o driver
  • program.o parser.h symbol.h \
  • program.cpp
  • g -c program.cpp
  • scanner.o scanner.h \
  • scanner.cpp
  • g -c scanner.cpp
Write a Comment
User Comments (0)
About PowerShow.com