SlideShare a Scribd company logo
Ultimate UNIX Setup
For Developers
Jacob Menke – Software Engineer && Business ComputerTechnologies LabTechnician (Ann Arbor MI)
Boring and not too usable
defaults…
Ultimate Unix Meetup Presentation
Config Files &&YouTubeTutorials
• https://github.com/MenkeTechnologies/TutorialFiles
• https://www.youtube.com/channel/UCLOQFBXPrcVvO2
Wb3wna8Ow
• RecentTopics : GNU Readline Shortcuts in mysql,
python3 and various REPLs
• http://jakobmenke.com/
Custom Shell functions
• cd
• aliases > functions > reserved words > builtins > external
commands in PATH > not found
• clearList == bash function
• essentially: clear && ls -AlhFi
Functions and aliases
UNIX Spirit – One letter commands. The more cryptic and less typing the better
Aliases Demo
Package Managers
• Mac => Homebrew, MacPorts, Fink (old)
• Homebrew HomePage => https://brew.sh/
• install => /usr/bin/ruby -e "$(curl -fsSL
https://raw.githubusercontent.com/Homebrew/install/ma
ster/install)"
Homebrew Jargon
• Package == Formula == ruby file
• installed into /usr/local/Cellar/<package> with symlinks into
/usr/local/bin, /usr/local/lib etc
• Taps == Github repositories
• Homebrew Core Repo Formulae
• downloaded to /usr/local/Homebrew/Library/taps/homebrew/homebrew-
core/formula
• Bottle == binary program already built for macOS (configure and make
already done for you)
• Cask == GUI program or font ie microsoft-office, intellij-idea
Homebrew Formula
brew install zzz
Homebrew Exploration
Homebrew
• brew install <package>
• brew ls
• brew rm <package>
• brew search <package>
• brew cleanup
• brew update
• brew upgrade
• brew cask install <gui-package>
• Brew cask rm <gui-package>
(removes .app from /Applications)
• brew cask zap <gui-package> (like
brew cask rm but also removes all
preferences files etc ie full
deinstallation)
• brew cask rm <gui>
Homebrew Demo
Package Managers
• Linux
• Debian based = Debian, Ubuntu, Mint, Raspbian, Kali
• Dpkg, apt, aptitude
• RPM based = Red Hat, Fedora, CentOS
• Rpm, yum
Apt
• sudo apt-get install <package>
• sudo apt-cache search <package>
• sudo apt-get purge <package>
• dpkg –l = list all installed packages
• dpkg –L <package> = show files for this package
• sudo apt-get update
• sudo apt-get upgrade
Tmux
• Terminal Multiplexer
• brew install tmux
• sudo apt-get install tmux
Ultimate Unix Meetup Presentation
Ultimate Unix Meetup Presentation
Ultimate Unix Meetup Presentation
Ultimate Unix Meetup Presentation
Tmux Commands
• tmux = start server
• tmux new-session –t <session-name>
• tmux new-window –t <window-name>
• tmux split-window = horizontal split pane
• tmux list-sessions (tmux ls) = list sessions
• tmux list-windows
• tmux list-panes
Tmux Commands
• tmux attach –t <session-name>
• tmux kill-session [–t <session-name>]
• tmux kill-window [–t <window-name>]
• tmux kill-pane [–t <pane>]
Tmux Demo
Inside ofTmux
• Prefix = defaults to ^B (Control B) but can be changed
• <prefix> + % => vertical split
• <prefix> + “ = horizontal split
• <prefix> + c = new window
• <prefix> + n = next window
• <prefix> + p = previous window
• <prefix> + : => command line inside tmux similar to vim
• <prefix> + : then kill-pane = kills current pane
• === tmux kill-pane
~/.tmux.conf
• Prefix = defaults to control b but can be changed
• These lines bind:
• prefix to ^a
• <prefix> - | to split vertically
• <prefix> - - to split horizontally
Tmux Demo
Tmux scripts
• usually located in ~/.tmux directory
• list of tmux commands to run
• could be run as tmux selectp –t 0 or <prefix>+: selectp –t 0
• ~/.tmux/four-panes
• ~/.tmux.conf
ControlWindow script
Tmux Demo
Htop
• brew install htop
• sudo apt-get install htop
• Similar to top but shows core usages
• / to search
• space to tag process
• k to kill process
Htop demo
ccze
• brew install ccze
• sudo apt-get install ccze
• tail –f /var/log/**/*.log | ccze
• sudo id = shows up in /var/log/system.log on Mac and
/var/log/auth.log on Linux
Logging with color bash script
ccze demo
iftop
• brew install iftop
• sudo apt-get install iftop
• sudo iftop –c ~/.iftop.conf
• while running:
• t = toggle bar display modes
• q = quit
• f = filter
• h = help
~/.iftop.conf
• port-display:on
• line-display:one-line-both
• interface: en0
iftop - colorized
• git clone
https://github.com/MenkeTechnologies/iftopcolor
• ./configure && make
• sudo make install or move executable ./iftop to
somewhere in PATH
iftop demo
grc – general colorizer
• https://github.com/garabik/grc
• brew install grc
• sudo apt-get install grc
grc config files
• Mac: /usr/local/share/grc/conf.ls
• Linux:/usr/share/grc/conf.ls
• each command that will be colorized has its
corresponding config file
• automatic aliases
• usage: grc netstat
• grc –c /usr/local/share/grc/conf.ls ping google.com
Automatic Aliasing (Over aliases)
• curl https://raw.githubusercontent.com/garabik/grc/master/grc.zsh -
O $HOME/grc.zsh
• ~/.zshrc : [[ -s ”$HOME/grc.zsh" ]] && source
“$HOME/grc.zsh”
• ping is now alias for grc ping
grc uses regex for colorization
grc demo
• ping
• ifconfig
• dd
• ps
Python programs
• Glances = pip package
• Powerline status = pip package
• brew install python = goes into
/usr/local/Cellar/python/<version-number>
• pip, package manager for python, should be included
• Mac: pip installs packages to /usr/local/lib/python2.7/site-
packages on
• Debian: pip installs packages to /usr/local/lib/python2.7/dist-
packages
Pip exploration
pip
• pip install <package>
• pip show <package>
• for package in $(pip list –outdated);do pip install
$package done
Powerline
• Status bars for vim, tmux
• requires special fonts for triangles such as Nerd Fonts
• https://github.com/ryanoasis/nerd-fonts
• pip install powerline-status
• ~/.tmux.conf
• ~/.vimrc
Powerline forVim
• recommend to install latest vim 8+
• brew install vim
• sudo apt-get install vim
• brew install macvim (fastest for mac IMO)
• mvim –v <file> = stay in terminal
• mvim <file> = launch gui
Powerline forVim
Macvim Demo
PowerlineTmux Status Bar
• http://powerline.readthedocs.io/en/master/usage/other.h
tml#tmux-statusline
• Define tmux status line in JSON file =>
• $HOME/.config/powerline/themes/tmux
PowerlineTmux StatusBar Demo
My Prompt == Powerlevel 9k
• https://github.com/bhilburn/power
level9k
• using Knack Nerd Font
• brew tap caskroom/fonts
• brew cask install font-hacknerd-
font
Powerlevel9k prompt config
Prompt Demo
glances
• pip install glances
• on Mac installs to /usr/local/lib/python2.7/site-
packages/glances
• Debian installs to /usr/local/lib/python2.7/dist-packages
• https://github.com/nicolargo/glances
glances
• sudo glances [--disable-alert] [--disable-network] […]
• To change text color from white to blue:
• Change line 203 in glances/outputs/glances_curses.py
• curses.init_pair(1, curses.COLOR_WHITE, -1)=>
• curses.init_pair(1, curses.COLOR_BLUE, -1)
glances demo
Oh-my-zsh
• Framework for zsh, geared toward developers
• Tons of prompts and plugins
• https://github.com/robbyrussell/oh-my-zsh
Oh my zsh install
• sh -c "$(curl -fsSL
https://raw.githubusercontent.com/robbyrussell/oh-my-
zsh/master/tools/install.sh)”
Oh my zsh Plugins
• git clone into ~/.oh-my-zsh/custom/plugins
• add to plugins array ~/.zshrc
Zsh-autosuggestions
• copy of FISH (friendly interactive shell)’s suggestions
• Searches history (~/.zsh-history) for most recent commands
starting with letters typed
• hit right arrow to complete the suggestion
• git clone https://github.com/zsh-users/zsh-autosuggestions
$ZSH_CUSTOM/plugins/zsh-autosuggestions
• add to plugins array in ~/.zshrc
Zsh-syntax highlighting
• Red if invalid command, green if found in PATH
• highlighting for quotes
• git clone https://github.com/zsh-users/zsh-syntax-
highlighting.git ${ZSH_CUSTOM:-~/.oh-my-
zsh/custom}/plugins/zsh-syntax-highlighting
• add to plugins array in ~/.zshrc
Zsh-completions
• adds zsh completions for more commands
• Adds zsh tab completions for many more commands such as caffeinate
• git clone https://github.com/zsh-users/zsh-completions ~/.oh-my-
zsh/custom/plugins/zsh-completions
• add to plugins array in ~/.zshrc
zsh plugins demo
z command
• creates database of visited directories
• usage: z <directory-name>
• directory-name can be just a few letters of the name
• if there is a match you will cd to that directory otherwise
no cd and returns 1
z install
• git clone
https://raw.githubusercontent.com/rupa/z/master/z.sh
$HOME
• source ~/z.sh
Zle line editor in ~/.zshrc
3) declare zsh function
as widget
4) Bind widget
function to Control-S
key combination
1) Define zsh function
2) Define zsh function to be
bound as widget. Calls above
function with the contents of
current command line as
argument
Type your commit
message at prompt no
quotes needed and
then pressControl-S
to add, commit and
push to remote
z and ZLE demo

More Related Content

Ultimate Unix Meetup Presentation

  • 1. Ultimate UNIX Setup For Developers Jacob Menke – Software Engineer && Business ComputerTechnologies LabTechnician (Ann Arbor MI)
  • 2. Boring and not too usable defaults…
  • 4. Config Files &&YouTubeTutorials • https://github.com/MenkeTechnologies/TutorialFiles • https://www.youtube.com/channel/UCLOQFBXPrcVvO2 Wb3wna8Ow • RecentTopics : GNU Readline Shortcuts in mysql, python3 and various REPLs • http://jakobmenke.com/
  • 5. Custom Shell functions • cd • aliases > functions > reserved words > builtins > external commands in PATH > not found
  • 6. • clearList == bash function • essentially: clear && ls -AlhFi
  • 7. Functions and aliases UNIX Spirit – One letter commands. The more cryptic and less typing the better
  • 9. Package Managers • Mac => Homebrew, MacPorts, Fink (old) • Homebrew HomePage => https://brew.sh/ • install => /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/ma ster/install)"
  • 10. Homebrew Jargon • Package == Formula == ruby file • installed into /usr/local/Cellar/<package> with symlinks into /usr/local/bin, /usr/local/lib etc • Taps == Github repositories • Homebrew Core Repo Formulae • downloaded to /usr/local/Homebrew/Library/taps/homebrew/homebrew- core/formula • Bottle == binary program already built for macOS (configure and make already done for you) • Cask == GUI program or font ie microsoft-office, intellij-idea
  • 13. Homebrew • brew install <package> • brew ls • brew rm <package> • brew search <package> • brew cleanup • brew update • brew upgrade • brew cask install <gui-package> • Brew cask rm <gui-package> (removes .app from /Applications) • brew cask zap <gui-package> (like brew cask rm but also removes all preferences files etc ie full deinstallation) • brew cask rm <gui>
  • 15. Package Managers • Linux • Debian based = Debian, Ubuntu, Mint, Raspbian, Kali • Dpkg, apt, aptitude • RPM based = Red Hat, Fedora, CentOS • Rpm, yum
  • 16. Apt • sudo apt-get install <package> • sudo apt-cache search <package> • sudo apt-get purge <package> • dpkg –l = list all installed packages • dpkg –L <package> = show files for this package • sudo apt-get update • sudo apt-get upgrade
  • 17. Tmux • Terminal Multiplexer • brew install tmux • sudo apt-get install tmux
  • 22. Tmux Commands • tmux = start server • tmux new-session –t <session-name> • tmux new-window –t <window-name> • tmux split-window = horizontal split pane • tmux list-sessions (tmux ls) = list sessions • tmux list-windows • tmux list-panes
  • 23. Tmux Commands • tmux attach –t <session-name> • tmux kill-session [–t <session-name>] • tmux kill-window [–t <window-name>] • tmux kill-pane [–t <pane>]
  • 25. Inside ofTmux • Prefix = defaults to ^B (Control B) but can be changed • <prefix> + % => vertical split • <prefix> + “ = horizontal split • <prefix> + c = new window • <prefix> + n = next window • <prefix> + p = previous window • <prefix> + : => command line inside tmux similar to vim • <prefix> + : then kill-pane = kills current pane • === tmux kill-pane
  • 26. ~/.tmux.conf • Prefix = defaults to control b but can be changed • These lines bind: • prefix to ^a • <prefix> - | to split vertically • <prefix> - - to split horizontally
  • 28. Tmux scripts • usually located in ~/.tmux directory • list of tmux commands to run • could be run as tmux selectp –t 0 or <prefix>+: selectp –t 0 • ~/.tmux/four-panes • ~/.tmux.conf
  • 31. Htop • brew install htop • sudo apt-get install htop • Similar to top but shows core usages • / to search • space to tag process • k to kill process
  • 33. ccze • brew install ccze • sudo apt-get install ccze • tail –f /var/log/**/*.log | ccze • sudo id = shows up in /var/log/system.log on Mac and /var/log/auth.log on Linux
  • 34. Logging with color bash script
  • 36. iftop • brew install iftop • sudo apt-get install iftop • sudo iftop –c ~/.iftop.conf • while running: • t = toggle bar display modes • q = quit • f = filter • h = help
  • 38. iftop - colorized • git clone https://github.com/MenkeTechnologies/iftopcolor • ./configure && make • sudo make install or move executable ./iftop to somewhere in PATH
  • 40. grc – general colorizer • https://github.com/garabik/grc • brew install grc • sudo apt-get install grc
  • 41. grc config files • Mac: /usr/local/share/grc/conf.ls • Linux:/usr/share/grc/conf.ls • each command that will be colorized has its corresponding config file • automatic aliases • usage: grc netstat • grc –c /usr/local/share/grc/conf.ls ping google.com
  • 42. Automatic Aliasing (Over aliases) • curl https://raw.githubusercontent.com/garabik/grc/master/grc.zsh - O $HOME/grc.zsh • ~/.zshrc : [[ -s ”$HOME/grc.zsh" ]] && source “$HOME/grc.zsh” • ping is now alias for grc ping
  • 43. grc uses regex for colorization
  • 44. grc demo • ping • ifconfig • dd • ps
  • 45. Python programs • Glances = pip package • Powerline status = pip package • brew install python = goes into /usr/local/Cellar/python/<version-number> • pip, package manager for python, should be included • Mac: pip installs packages to /usr/local/lib/python2.7/site- packages on • Debian: pip installs packages to /usr/local/lib/python2.7/dist- packages
  • 47. pip • pip install <package> • pip show <package> • for package in $(pip list –outdated);do pip install $package done
  • 48. Powerline • Status bars for vim, tmux • requires special fonts for triangles such as Nerd Fonts • https://github.com/ryanoasis/nerd-fonts • pip install powerline-status • ~/.tmux.conf • ~/.vimrc
  • 49. Powerline forVim • recommend to install latest vim 8+ • brew install vim • sudo apt-get install vim • brew install macvim (fastest for mac IMO) • mvim –v <file> = stay in terminal • mvim <file> = launch gui
  • 52. PowerlineTmux Status Bar • http://powerline.readthedocs.io/en/master/usage/other.h tml#tmux-statusline • Define tmux status line in JSON file => • $HOME/.config/powerline/themes/tmux
  • 54. My Prompt == Powerlevel 9k • https://github.com/bhilburn/power level9k • using Knack Nerd Font • brew tap caskroom/fonts • brew cask install font-hacknerd- font
  • 57. glances • pip install glances • on Mac installs to /usr/local/lib/python2.7/site- packages/glances • Debian installs to /usr/local/lib/python2.7/dist-packages • https://github.com/nicolargo/glances
  • 58. glances • sudo glances [--disable-alert] [--disable-network] […] • To change text color from white to blue: • Change line 203 in glances/outputs/glances_curses.py • curses.init_pair(1, curses.COLOR_WHITE, -1)=> • curses.init_pair(1, curses.COLOR_BLUE, -1)
  • 60. Oh-my-zsh • Framework for zsh, geared toward developers • Tons of prompts and plugins • https://github.com/robbyrussell/oh-my-zsh
  • 61. Oh my zsh install • sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my- zsh/master/tools/install.sh)”
  • 62. Oh my zsh Plugins • git clone into ~/.oh-my-zsh/custom/plugins • add to plugins array ~/.zshrc
  • 63. Zsh-autosuggestions • copy of FISH (friendly interactive shell)’s suggestions • Searches history (~/.zsh-history) for most recent commands starting with letters typed • hit right arrow to complete the suggestion • git clone https://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions • add to plugins array in ~/.zshrc
  • 64. Zsh-syntax highlighting • Red if invalid command, green if found in PATH • highlighting for quotes • git clone https://github.com/zsh-users/zsh-syntax- highlighting.git ${ZSH_CUSTOM:-~/.oh-my- zsh/custom}/plugins/zsh-syntax-highlighting • add to plugins array in ~/.zshrc
  • 65. Zsh-completions • adds zsh completions for more commands • Adds zsh tab completions for many more commands such as caffeinate • git clone https://github.com/zsh-users/zsh-completions ~/.oh-my- zsh/custom/plugins/zsh-completions • add to plugins array in ~/.zshrc
  • 67. z command • creates database of visited directories • usage: z <directory-name> • directory-name can be just a few letters of the name • if there is a match you will cd to that directory otherwise no cd and returns 1
  • 68. z install • git clone https://raw.githubusercontent.com/rupa/z/master/z.sh $HOME • source ~/z.sh
  • 69. Zle line editor in ~/.zshrc 3) declare zsh function as widget 4) Bind widget function to Control-S key combination 1) Define zsh function 2) Define zsh function to be bound as widget. Calls above function with the contents of current command line as argument Type your commit message at prompt no quotes needed and then pressControl-S to add, commit and push to remote
  • 70. z and ZLE demo