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

$PATH, /bin and $PS1

$PATH, /bin and $PS1

In this talk, Kim demystifies the $PATH variable, which is often a part of installing new dev tools, she will describe how your computer stores executable files in your /bin directory, and the Filesystem Hierarchy Standard that governs the root directory, and she’ll show you how to customize your command line by altering the $PS1 variable.

This talk is for people who use a terminal to run commands and want to learn more about what’s going on and how to customize their command-line interface.

There is a companion blog post to this talk at https://kimschlesinger.com/2020/02/25/PATH-FHS-PS1/

Kim Schlesinger

February 25, 2020
Tweet

More Decks by Kim Schlesinger

Other Decks in Technology

Transcript

  1. @kimschles Environment Variables • Key value pairs that your system

    can access and use • ALL_UPPERCASE Commands: • env • echo $ENV_VAR
  2. @kimschles Shell “A shell reads your commands and tells the

    OS to do things.” -- Julia Evans Source: https://twitter.com/b0rk/status/1218647766097940481
  3. @kimschles /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin • Environment Variable • 1 long string •

    Colon-separated • Is a path to executable code invoked through text commands
  4. @kimschles Permanently Edit PATH • Update PATH in .bashrc, .bash_profile

    or .zshrc file • /usr/local/go/bin export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
  5. @kimschles Permanently Edit PATH • Update PATH in .bashrc or

    .bash_profile file • /usr/local/go/bin export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/go/bin
  6. @kimschles Temporarily Edit PATH • From the command line. Only

    lasts in current shell. PATH=$PATH:/usr/local/go/bin
  7. @kimschles /bin • bin stands for binary, which is a

    file you can execute • A collection of scripts • /bin has the basic commands we use like cat, mkdir, echo, pwd, rm
  8. @kimschles “The Filesystem Hierarchy Standard (FHS) defines the directory structure

    and directory contents in Linux distributions. It is maintained by the Linux Foundation. The latest version is 3.0, released on 3 June 2015.” Source: https://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard
  9. @kimschles PS1 • An environment variable • Creates the default

    command prompt you see at the beginning of your command line.
  10. @kimschles \u@\h:\w\$ \u = username \h = hostname \w =

    working directory Separated with @, : and $
  11. @kimschles Add colors (and emojis) Open you .bash_profile, .bashrc or

    .zshrc file and Add ANSI color escape sequences before each section of your PS1. Add emojis if you’d like.
  12. @kimschles $PATH Resources I’ve learned alot about the PATH variable

    from Breanne Boland, who wrote the first two articles on this list. • Access & Make Awesome Your PATH System Variable • When laziness is efficient: Make the most of your command line • PATH Definition • How to Modify the Shell Path in macOS Sierra and OSX using Terminal • What is the difference between .bash_profile and .bashrc?
  13. @kimschles /bin and FHS Resources • Filesystem Hierarchy Standard •

    Wikipedia: Filesystem Hierarchy Standard • The /bin Directory • Linux Directory Structure explained: /bin folder
  14. @kimschles $PS1 Resources • How to Customize Shell Variable PS1-PS4

    on Bash Prompt • UNIX StackExchange: Colorizing your terminal and shell environment • My Mac OSX Bash Profile • StackOverflow: List of ANSI color escape sequences • Simple Tricks to Improve the Terminal Appearance in Mac OS X • Customize the colors of your Terminal in Mac OS X