Skip to content

Latest commit

 

History

History
732 lines (509 loc) · 17.5 KB

File metadata and controls

732 lines (509 loc) · 17.5 KB
title author patat
░▒▓ modern linux command line tools ▓▒░
pandocExtensions incrementalLists wrap margins theme images
patat_extensions
autolink_bare_uris
emoji
hard_line_breaks
false
true
left right
6
4
header emph strong code codeBlock
bold
dullYellow
italic
bold
vividYellow
onRgb#101060
bold
dullWhite
backend path
w3m
/usr/lib/w3m/w3mimgdisplay

███╗   ███╗ ██████╗ ██████╗ ███████╗██████╗ ███╗   ██╗
████╗ ████║██╔═══██╗██╔══██╗██╔════╝██╔══██╗████╗  ██║
██╔████╔██║██║   ██║██║  ██║█████╗  ██████╔╝██╔██╗ ██║
██║╚██╔╝██║██║   ██║██║  ██║██╔══╝  ██╔══██╗██║╚██╗██║
██║ ╚═╝ ██║╚██████╔╝██████╔╝███████╗██║  ██║██║ ╚████║
╚═╝     ╚═╝ ╚═════╝ ╚═════╝ ╚══════╝╚═╝  ╚═╝╚═╝  ╚═══╝

██╗     ██╗███╗   ██╗██╗   ██╗██╗  ██╗
██║     ██║████╗  ██║██║   ██║╚██╗██╔╝
██║     ██║██╔██╗ ██║██║   ██║ ╚███╔╝
██║     ██║██║╚██╗██║██║   ██║ ██╔██╗
███████╗██║██║ ╚████║╚██████╔╝██╔╝ ██╗
╚══════╝╚═╝╚═╝  ╚═══╝ ╚═════╝ ╚═╝  ╚═╝

 ██████╗██╗     ██╗    ████████╗ ██████╗  ██████╗ ██╗     ███████╗
██╔════╝██║     ██║    ╚══██╔══╝██╔═══██╗██╔═══██╗██║     ██╔════╝
██║     ██║     ██║       ██║   ██║   ██║██║   ██║██║     ███████╗
██║     ██║     ██║       ██║   ██║   ██║██║   ██║██║     ╚════██║
╚██████╗███████╗██║       ██║   ╚██████╔╝╚██████╔╝███████╗███████║
 ╚═════╝╚══════╝╚═╝       ╚═╝    ╚═════╝  ╚═════╝ ╚══════╝╚══════╝

"modern" is relative...

Douglas Adams

I've come up with a set of rules that describe our reactions to technologies:

  1. Anything that is in the world when you're born is normal and ordinary and is just a natural part of the way the world works.

  2. Anything that's invented between when you're fifteen and thirty-five is new and exciting and revolutionary and you can probably get a career in it.

  3. Anything invented after you're thirty-five is against the natural order of things.


Target audience

  • linux desktop CLI users
  • linux admins
  __________________________________________
 / This is the year of linux on the desktop \
|                                            |
|          ...Windows10 has WSL ;-)          |
 \                                          /
  ------------------------------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

Linux tooling philosophy

  • do one thing (and only one thing!) well

  • chaining

  • sound familiar? (hint: functional programming...)


Why? Improvements to...

  • productivity

  • optics

    • "unix porn" (PS1, ls, ...)

Learn the basics

  • emacs and vim

    • learn navigation, copy & paste, (and how to exit 👍)
    • pick one and become fluent
  • cd, ls, cat, less, find, grep, sed, tail, awk, dd, rsync, ...


terminals and shells

What is the difference between terminal and shell?

+--------------------+
|     "terminal"     |
+--------------------+
|                    |
| +--------------+   |
| |              |   |
| |    "shell"   |   |
| |              |   |
| +--------------+   |
|                    |
+--------------------+

terminal

  • colors (16 or more), fonts (utf8, ligatures, ...)
  • interactions
    • keyboard shortcuts
    • mouse interaction (copy & paste, scrolling, selection, ...)

shell

  • everything else (f.ex. PS1, scripting language)

terminal

What is the best terminal?

  • use your default

Unicode, Emojis, Fonts, Image support (!)

  • but think about enriching your output!

  • Emojis: 👍 ☑️ 💥 ✌️ 💩 💬 ⚡ € ★ ⭐

 _______________________________________
/\                                      \
\_| You've got to know when to hold 'em |
  | Know when to fold 'em               |
  | Know when to walk away              |
  | And know when to run                |
  |   __________________________________|_
   \_/____________________________________/

(...this presentation is running in a terminal (kitty), not a browser...)


shell

  • bash
  • zsh
  • fish
  • dash (embedded)

shell / zsh


shell / fish: The new kid on the block


shell / bash


shell / PS1

  • PS1: alias for "prompt"

  • default: username:/some/location $

  • $PWD present working directory


shell / PS1: liquidprompt


shell / PS1: Powerline


byobu

   _________________________________
  /                                 \
  |    ...a personal favorite...    |
  \______________________________ '\
                             ()    \\
                               O    \\  .
                                 o  |\\/|
                                    / " '\
                                    . .   .
                                   /    ) |
                                  '  _.'  |
                                  '-'/    \

ranger

  • 6.9k stars https://ranger.github.io

  • file explorer

  • 2 layout options

    • miller columns ("mac" style)
    • multipane (similar to Midnight commander)
  • powerful preview mode and program launcher (word, music, ...)

    • with image support for certain terminals (iterms2, urxvt, kitty) not gnome-terminal (!)
  • key bindings: see ~/.config/ranger/rc.conf starting at line ~300...

  • category: navigation, file system

  • Demos:

    • kitty with image preview
    • copy yy & paste pp

tldr

  • 25k stars https://tldr.sh/

  • man pages can be difficult

  • tldr: implemented in many languages (js, ruby, python, perl, haskell, etc)

  • Demo: ln, tar, scp


bat

  • 17k stars https://github.com/sharkdp/bat

  • cat & less with syntax highlighting

    bat looks good on a dark background by default. However, if your terminal uses a light background, some themes like GitHub or OneHalfLight will work better for you.

  • hint: not the same preview used by ranger...

  • category: read / file display

   _________________________________
  /                                 \
  |    daily usage                  |
  \______________________________ '\
                             ()    \\
                               O    \\  .
                                 o  |\\/|
                                    / " '\
                                    . .   .
                                   /    ) |
                                  '  _.'  |
                                  '-'/    \

ripgrep

  • 17k stars https://github.com/BurntSushi/ripgrep

  • ripgrep recursively searches directories for a regex pattern

  • very fast grep replacement (benchmarks on website)

  • sensible defaults: respect .gitignore, ignores hidden files & folders

  • command: rg

  • category: search

       \\\///
      / _  _ \
    (| (.)(.) |)
.-.OOOo--()--oOOO.-.
|                  |
|   Power-Tool!    | -> Demo: search in exercism folder
|                  |
'-.oooO------------'
   (   )   Oooo.
    \ (    (   )
     \_)    ) /
           (_/

ripgrep-all

  • 1.4k stars https://github.com/phiresky/ripgrep-all

  • ripgrep, but also search in PDFs, E-Books, Office documents, zip, tar.gz, sqlite (!), etc

  • command: rga

  • faster than pdfgrep (see website for a benchmark)

  • category: search

  • Demo: search in Manning books folder


fzf

  • 26k stars https://github.com/junegunn/fzf

  • interactive fuzzy search

  • pipe any line based input to fzf: Example find * -type f | fzf

  • good integration with other tools

  • nice helper methods for

    • files & directories cd **<TAB>
    • kill kill -9 <TAB>
    • host names ssh **<TAB>
    • environment variables & aliases unset **<TAB>, export **<TAB>, unalias **<TAB>
  • category: search

  • Demos:

    • find files and select them
    • search a text file

fd

  • 11k stars https://github.com/sharkdp/fd

  • simple alternative to find

  • "The command name is 50% shorter than find"

  • Convenient syntax fd PATTERN (instead of find -iname '*PATTERN*')

  • Sensible defaults: .gitignore, ignore hidden files/folders

  • fast

  • category: search


hyperfine

# comparing `fd` with `find`

# ubuntu uses `fdfind` by default
hyperfine --warmup 3 'fdfind -HI '.*[0-9]\.jpg$'' 'find ~ -iregex '.*[0-9]\.jpg''

# arch
hyperfine --warmup 3 'fd -HI '.*[0-9]\.jpg$' Documents/talks' 'find Documents/talks -iregex '.*[0-9]\.jpg$''

# unfair comparison: `fd` ignores hidden files and `.git` be default
hyperfine --warmup 3 'fd '.*[0-9]\.jpg$' Documents/talks' 'find Documents/talks -iregex '.*[0-9]\.jpg$''
  • category: benchmarking

progress

  • 4k stars https://github.com/Xfennec/progress

  • attach to any kind of copy

  • category: monitoring

  • Demo:

    • ~/tmp/demo/origin/ contains very large file
    • tmux split screen ~/tmp/demo/
    • copy from ~/tmp/demo/origin/* to ~/tmp/demo/destination/ using cp.
    • watch progress
No command currently running: cp, mv, dd, tar, cat, rsync, grep, fgrep, egrep, cut, sort, md5sum,
sha1sum, sha224sum, sha256sum, sha384sum, sha512sum, adb, gzip, gunzip, bzip2, bunzip2, xz,
unxz, lzma, unlzma, 7z, 7za, zcat, bzcat, lzcat, split, gpg, or wrong permissions.

Ultimate Plumber (up)

  • 4k stars https://github.com/akavel/up

  • interactive piping

  • instant live preview

  • interactive REPL for bash piping

  • category: search, file manipulation, interactive

  • Demo: images/up-demo.gif


lolcat


ttyd

            _ ._  _ , _ ._
          (_ ' ( `  )_  .__)
        ( (  (    )   `)  ) _)
       (__ (_   (_ . _) _) ,__)
           `~~`\ ' . /`~~`
           ,::: ;   ; :::,
          ':::::::::::::::'
 ______________/_ __ \_____________
|                                  |
|               ttyd               |
| share your terminal over the web |
|__________________________________|
  • category: network, dangerous

no-more-secrets


sl


thefuck


patat

  • 1k stars https://github.com/jaspervdj/patat

  • nerdy slides in your shell

  • runs in a terminal (similar to revealJs for the browser)

  • Pandoc syntax (f. ex. markdown)

  • syntax highlighting

let foo = "bar";
  • emojis: 👍, ✅, ☑️, 💥

  • next slide: experimental image support in some terminals (same as for ranger)

    • iterm2, urxvt, kitty
  • category: presentation, slides, unix porn


softwerkskammer-logo


ls on steroids

ls problem: sort by name and time at the same time...

Use colors!

Required: font providing all symbols


colorls

   _________________________________
  /                                 \
  |    daily usage                  |
  \______________________________ '\
                             ()    \\
                               O    \\  .
                                 o  |\\/|
                                    / " '\
                                    . .   .
                                   /    ) |
                                  '  _.'  |
                                  '-'/    \

lsd


df alternatives

pydf

ncdu


boxes


monitoring

  • htop
  • apachetop
  • ngxtop
  • mtp
  • pg_top
  • powertop
  • iotop
  • iftop
  • nethogs

Resources

Slides & docker examples


END

              .-"""-.
             / .===. \
            / / a a \ \
           / ( \___/ ) \
  ______ooo\__\_____/__/________
 /                              \
| did I miss your favorite tool? |
 \_____________________ooo______/
          /           \
         /:.:.:.:.:.:.:\
             |  |  |
             \==|==/
             /-'Y'-\
            (__/ \__)

Bonus: CLI murder mystery