Skip to content

Instantly share code, notes, and snippets.

@HendrixString
Last active September 8, 2017 11:09
Show Gist options
  • Save HendrixString/5826ce5ef22d7be64cc3eae5188e99aa to your computer and use it in GitHub Desktop.
Save HendrixString/5826ce5ef22d7be64cc3eae5188e99aa to your computer and use it in GitHub Desktop.
bash cheat sheet

man - show the doc of a command

man <commnad>

common

. = current directory
~ = home directory
$HOME = home directory
pwd = print current directory
cat <file> = print file content
cat > <file> << EOF = write output stream into a file
export VAR=VALUE = export environment variable
hitting TAB will auto-complete
id -u - get the current user id
cd - move to the home directory
cd - - move to latest directory

where and readlink

get the path of a symbolically linked file

>> where zsh
>> /usr/local/bin/zsh
>> readlink /usr/local/bin/zsh
>> ../Cellar/zsh/5.3.1/bin/zsh

important files

environment variables are usually stored here cat ~/.profile

Vim

vim <file> = open vim for theis file
Esc or Ctrl+[ = get into command palette
commands:

  • i = insert mode - editing
  • :w = write the changes into the file
  • :q = quit vim
  • :wq = write and quit vim

export environment

echo 'export GOPATH=$HOME/code/go' >> $HOME/.profile
echo 'export PATH=$PATH:/usr/local/go/bin' >> $HOME/.profile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment