*nix kungfu for web devs

/usr/akts

fsug-tvm  |  neoito

unix

men<em>of</em>unix

  • an OS built at AT&T's Bell Labs
  • OS = Shell + Kernel
  • linux is a unix clone - POSIX
  • Shell = user@devbox:~$

shells

this talk is on /bin/bash

$HISTORY & <Tab> completion

  • - very familiar.
  • ^r - search history *as many times needed
  • !! - last command in history
  • !20 & !-2 - exec 20th & 2nd last command in history
  • vi !$ (or) <Esc> . - fill the last arg of prev comm
  • <Tab> and <Tab><Tab>

$FILE ops

  • find /folder/path -type f -print - by file type
  • find /folder/path -name *.js -print - by file type
  • find /folder/path -size +50M -print - by file size
  • head & tail
  • cat
  • touch - create empty file or update timestamp
  • $PAGER - vim -R // less // more

$PIPE & $REDIRECTION

  • ls | grep *.log - piping
  • node print_something.js > output.txt - redirection
  • command 2> err.log 1> output.log
  • >> - appends to file

$NAVIGATION

  • cd // pushd // popd // dirs -v // cd ~x // cd -
  • ^a & ^e
  • ^l == clear
  • ^◀ & ^▶

$PROCESS

  • ps & kill <pid>
  • pidof nginx
  • top -p <p1>,<p2> ... then, E/e
  • netstat

$ARCHIVING

  • gzip foobar.txt
  • tar -czvf ar.tar.gz ar
  • zcat access.log.gz

executables & programs

  • $HOME/bin
  • ln -s $TARGET $FILE
  • .profile .bashrc - $PATH
  • scripting ./script.sh or sh script.sh

2 useful programs

crons

  • crontab -e
  • visit the guru

the prompt

  • PS1 and $HOME/bashrc
  • adding git prompt

functions & aliases

  • alias lanip="ip addr show wlp5s0 | grep inet | awk '{ print $2 }' | head -n 1 | cut -f1 -d'/'"
  • alias v=vim
  • alias sl=ls
  • cdls() { cd "$@" && ls;}

fin / questions ?