$30 off During Our Annual Pro Sale. View Details »

UNIX, Linux, and Command Line Basics

UNIX, Linux, and Command Line Basics

UNIX, Linux, and Command Line Basics

Henning Schwentner

May 08, 2023
Tweet

More Decks by Henning Schwentner

Other Decks in Programming

Transcript

  1. Starring
    Directed By
    Special
    Appearance
    Presented by
    With

    View Slide

  2. View Slide

  3. THE NAME OF THIS SPEAKER IS HENNING SCHWENTNER
    LIVE 45 MIN TALK

    View Slide

  4. View Slide

  5. !"#
    Kolleg:in gesucht
    (Deutschlandweit)

    View Slide

  6. 26.05.23 //// Seite 10
    WPS - Workplace Solutions GmbH
    WHY DO I CARE?
    § DevOps
    § Cloud
    § Docker/Containerization/Virtualization
    § It’s the 20ies—Even Microsoft <3 Linux
    § Op:
    § Servers are typically Linux + Java + (Tomcat) + DB
    § Start and stop Daemons
    § Dev:
    § Tools that help in your developer day

    View Slide

  7. @hschwentner
    History

    View Slide

  8. @hschwentner
    UNIX
    Foto: Dennis Hamilton/flickr/CC BY 2.0
    Ken
    Thompson
    Dennis
    Ritchie
    1969
    Bell Labs

    View Slide

  9. @hschwentner
    GNU
    Richard
    Stallman
    Free Software
    Foundation

    View Slide

  10. @hschwentner
    UNIX—Diversity
    Xenix

    View Slide

  11. @hschwentner
    Linux
    Linus Thorvalds
    1991

    View Slide

  12. @hschwentner
    Linux—Distributions

    View Slide

  13. @hschwentner
    Today: Unix Everywhere
    Windows Terminal
    WSL
    is Unix
    BSD-based

    View Slide

  14. 26.05.23 //// Seite 20
    WPS - Workplace Solutions GmbH
    § FHS
    § Static/ and Shared/Local Files
    § First Hierarchy
    § /
    § /bin, /sbin
    § /etc
    § /root, /home
    § /proc, /dev, /sys?, /mnt
    § Second Hierarchy
    § /usr, /var
    § /usr/bin, /usr/sbin, /usr/X11/bin
    § /var/tmp
    § /var/log
    § Local Hierarchy
    § /usr/local
    § Non-packaged tools vs. non-OS tools
    § Other tools
    § /opt
    THE FILESYSTEM TREE

    View Slide

  15. 26.05.23 //// Seite 21
    WPS - Workplace Solutions GmbH
    § root
    § groups
    § user
    § Rights:
    § user
    § group
    § world
    ROLES AND RIGHTS

    View Slide

  16. @hschwentner
    Terminal/
    Console/
    TTY/Shell

    View Slide

  17. @hschwentner
    In the old days
    mainframe
    (a.k.a. host)
    terminal
    terminal

    View Slide

  18. @hschwentner
    Terminal
    terminal (noun):
    a piece of hardware to
    interact with a computer

    View Slide

  19. @hschwentner
    Kinds of terminals
    console
    teleprinter,
    a.k.a teletype(writer),
    a.k.a. TTY
    video
    terminal
    (here: VT 100)
    for admins for users

    View Slide

  20. @hschwentner
    Terminal emulator
    terminal emulator (noun):
    a piece of software that
    emulates a terminal

    View Slide

  21. @hschwentner
    Terminal emulators
    Windows
    Terminal
    macOS
    Terminal
    Windows
    Console
    (conhost.exe)
    iTerm2
    XTerm
    Alacritty

    View Slide

  22. @hschwentner
    Terminal emulators II

    View Slide

  23. @hschwentner
    Shell
    shell (noun):
    A piece of software to
    interact with the kernel.
    Runs typically in a terminal.
    There are command-line
    shells and graphical shells.

    View Slide

  24. @hschwentner
    CLI shells
    C shell
    KornShell
    Bourne shell
    Command
    prompt
    PowerShell
    Fish

    View Slide

  25. @hschwentner
    Graphical shells

    View Slide

  26. @hschwentner
    UNIX on
    Windows

    View Slide

  27. @hschwentner
    On Windows

    View Slide

  28. @hschwentner
    Terminal/
    Console/
    TTY/Shell

    View Slide

  29. @hschwentner
    /home
    Command line
    $ -l
    ls
    prompt command

    View Slide

  30. @hschwentner
    /home
    Command = argument[]
    $ -l
    ls
    argument 0
    arg. 1
    arg. 2

    View Slide

  31. @hschwentner
    /home
    Anatomy of a command
    $ -l
    ls
    command
    option
    parameter

    View Slide

  32. @hschwentner
    Important commands
    • pwd
    • cd/pushd/popd
    • ls
    • mkdir/touch
    • rm
    • cat/tail/less
    • man
    • & bg/fg
    • . and ..
    • ls -la

    View Slide

  33. @hschwentner
    Typical options
    • - and --
    • -v --version
    • -h --help
    option (noun):
    An argument that starts
    with a dash. Several options
    can be put into one
    argument.

    View Slide

  34. @hschwentner
    Getting help
    • -h –help
    • man

    View Slide

  35. @hschwentner
    Path

    View Slide

  36. @hschwentner
    Tab completion

    View Slide

  37. @hschwentner
    PIPELINING
    • Unix commands are generally
    working on strings of characters
    • STDIN, STDOUT, STDERR
    • Pipes allow to connect the output of
    one command to connect to the
    input of another
    echo "Hello world" >
    hallo.txt
    2> <
    echo "Hallo world" | wc

    View Slide

  38. @hschwentner
    Installers
    • Debian family
    • Apt, apt-get, aptitude
    • deb/dpkg
    • snap
    • Redhat family
    • yum
    • rpm
    • Zypper
    • Alpine
    • apk
    • OS X
    • Homebrew, (MacPorts, Fink)
    • Windows
    • Cygwin
    • Chocolatey
    • Winget

    View Slide

  39. @hschwentner
    SED and GREP

    View Slide

  40. @hschwentner
    SCRIPTING
    • Shell scripts
    • Perl/Python & co.
    • Reg Ex
    • Scripting in Dockerfiles
    • Shebang:
    • #!/bin/sh
    • #!/usr/bin/env perl

    View Slide

  41. @hschwentner
    Command Line Java
    • java/javac
    • jshell
    • mvn/gradle

    View Slide

  42. We can
    do it,
    too!

    View Slide

  43. @hschwentner
    EXERCISE
    • On Windows 10: install Windows Terminal/Git Bash/Cygwin
    • Create directory learning-unix
    • Change into that directory
    • Create a file hello.txt
    • Change ownership and access of hello.txt
    • Make it executable

    View Slide

  44. View Slide

  45. View Slide

  46. Bibliography
    Nemeth, Evi, Garth Snyder, Trent R. Hein, Ben Whaley, and Dan Mackin. UNIX and Linux System Administrators
    Handbook. 5th ed. Boston: Addison-Wesley, 2017.
    Raymond, Eric S. The Art of UNIX Programming. Boston: Addison-Wesley, 2004.
    Hofer, Stefan and Henning Schwentner. Domain Storytelling: a Collaborative, Visual, and Agile Way to Develop Domain-
    Driven Software. Boston: Addison-Wesley, 2022.

    View Slide

  47. View Slide

  48. Henning Schwentner
    ⌂ https://hschwentner.io
    @hschwentner
    [email protected]

    View Slide