Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Bash Introduction

Bash Introduction

Introduction to the Unix command line

André Augusto Costa Santos

October 24, 2013
Tweet

Other Decks in Programming

Transcript

  1. INTRODUCTION
    BASH

    View full-size slide

  2. ANDRÉ SANTOS
    FRANCISCO NEVES
    62Gerente [email protected] andre-santos.pt
    francisconeves [email protected] francisconeves.com

    View full-size slide

  3. UNIX BASED SYSTEMS

    View full-size slide

  4. UNIX BASED SYSTEMS
    STABILITY
    PERFORMANCE
    SCALABILITY
    COMPATIBILITY
    PRICE
    VS WINDOWS

    View full-size slide

  5. BASH?
    ‣WHAT DOES IT MEAN?
    ‣ADVANTAGES?
    WHAT IS

    View full-size slide

  6. BASH?
    ‣AUTOCOMPLETE
    ‣MAN PAGES
    ‣CLEAR SCREEN
    HOW TO DEAL WITH

    View full-size slide

  7. COMMANDS
    SOME REQUIRED

    View full-size slide

  8. LIST ls -a
    -l
    ALL FILES
    LONG FORMAT
    MAKE
    DIRECTORY mkdir [OPT] DIR
    -p MAKE PARENTS

    View full-size slide

  9. CHANGE
    DIRECTORY cd PATH . CURRENT DIR
    ~
    .. PARENT DIR
    HOME DIR
    PRINT WORKING
    DIRECTORY
    pwd
    CREATE
    EMPTY FILE touch FILE

    View full-size slide

  10. COPY cp [OPT] FROM TO
    MOVE OR
    RENAME mv FROM TO
    -r COPY DIRECTORIES RECURSIVELY

    View full-size slide

  11. REMOVE rm [OPT] FILE
    REMOVE
    DIRECTORY rmdir [OPT] DIR
    -r RECURSIVELY REMOVE DIRECTORIES
    -f FORCE
    -p PARENTS

    View full-size slide

  12. CONCATENATE
    AND PRINT FILES
    cat [OPT] FILES
    less [OPT] FILE
    -N NUMBER THE OUTPUT LINES
    VIEW FILE
    -l NUMBER THE OUTPUT LINES

    View full-size slide

  13. FREQUENT COMMANDS
    LESS
    Key COMMAND
    Space NEXT PAGE
    b PREVIOUS PAGE
    j NEXT LINE
    k PREVIOUS LINE
    g FIRST LINE
    G LAST LINE
    G LINE
    Key COMMAND
    / FOWARD SEARCH FOR
    ? BACKWARD SEARCH FOR
    n NEXT SEARCH MATCH
    N PREVIOUS SEARCH MATCH
    = FILE INFORMATION
    h HELP
    q QUIT

    View full-size slide

  14. DISPLAY
    FIRST LINES
    head [OPT] FILE
    tail [OPT] FILE
    -n LAST N LINES
    -n FIRST N LINES
    DISPLAY
    LAST LINES

    View full-size slide

  15. PRINT LINES MATCHING A PATTERN
    grep [OPT] PATTERN [FILE...]
    -c DISPLAY THE NUMBER OF MATCHED LINES
    -i IGNORE CASE SENSITIVITY
    -l DISPLAY THE FILENAMES
    -n DISPLAY THE LINE NUMBERS
    -w MATCH WHOLE WORD

    View full-size slide

  16. WORD COUNT
    wc [OPT] FILE
    -l LINE COUNT
    -c BYTE COUNT
    -m CHARACTER COUNT
    -w WORD COUNT

    View full-size slide

  17. COMMANDS
    CTRL-KEY

    View full-size slide

  18. KILL PROCESS CTRL + C
    STOP PROCESS CTRL + Z
    END OF FILE CTRL + D

    View full-size slide

  19. REDIRECTION
    I/O

    View full-size slide

  20. COMMAND > FILE
    REDIRECT STDOUT TO A FILE
    OVERWRITE
    COMMAND >> FILE
    REDIRECT STDIN TO A FILE
    APPEND
    COMMAND < FILE

    View full-size slide

  21. COMMAND1 | COMMAND2 | COMMAND3
    REDIRECT THE OUTPUT FROM ONE COMMAND AS
    INPUT TO THE NEXT ONE

    View full-size slide

  22. WHAT ARE
    WILDCARDS?

    View full-size slide

  23. *
    ? ANY SINGLE CHARACTER
    ANY NUMBER OF CHARACTERS

    View full-size slide

  24. SECURITY
    SYSTEM AND

    View full-size slide

  25. PERMISSIONS
    UNIX
    sudo [OPT] [USER] COMMAND
    ALLOWS USERS TO RUN PROGRAMS WITH THE
    SECURITY PRIVILEGES OF ANOTHER USER
    NORMALLY THE ROOT

    View full-size slide

  26. PERMISSIONS
    UNIX
    u
    u
    u g
    g
    g o
    o
    o
    user
    user
    user group
    group
    group others
    others
    others
    r w x r w x r w x
    4 2 1 4 2 1 4 2 1
    a = all
    7

    View full-size slide

  27. CHANGE PERMISSIONS
    chmod [OPT] MODE FILE
    -R RECURSIVELY
    +rx
    g-w
    777
    READ AND EXECUTE FOR ALL
    DENY WRITE ACESS FOR GROUP
    READ, WRITE AND EXECUTE FOR ALL

    View full-size slide

  28. PROCESSES
    UNIX
    COMMAND & RUN PROCESS ON BACKGROUND
    jobs BACKGROUND OR SUSPENDED PROCESSES
    kill SIGNAL PROCESS SEND SIGNAL TO A PROCESS
    killall PROCESS KILL PROCESS BY NAME

    View full-size slide

  29. top
    DISPLAY TOP CPU PROCESSES
    ps
    REPORTS THE PROCESS STATUS
    -e
    FULL LISTING
    ALL PROCESSES
    -f

    View full-size slide

  30. LEAST
    LAST BUT NOT

    View full-size slide

  31. history -c CLEAR
    LAST COMMANDS USED
    time COMMAND
    TIME COMMAND EXECUTION
    diff
    COMPARE FILES LINE BY LINE
    !* LAST MATCHED COMMAND

    View full-size slide

  32. WALK A FILE HIERARCHY
    find PATH [OPT] [EXPRESSION]
    -name FIND BY NAME
    -size FIND BY SIZE
    -iname CASE INSENSITIVE MODE

    View full-size slide