Skip to content

Instantly share code, notes, and snippets.

@aperkaz
Last active February 6, 2018 11:31
Show Gist options
  • Save aperkaz/8d933ee898ba352d537e4914a7cb68a2 to your computer and use it in GitHub Desktop.
Save aperkaz/8d933ee898ba352d537e4914a7cb68a2 to your computer and use it in GitHub Desktop.
Ubuntu command cheat-sheet

Ubuntu Command Cheatsheet

General usage ubuntu comments. Separated in general and development related.

General

General scope useful commands

  • Sync VM machine time
sudo ntpdate ntp.ubuntu.com
  • Kill process in specific port
fuser -k {port}/tcp
  • Grant sudo permissions to a folder
sudo chmod -R 777 {dir}
  • Chech the available system space
df -h

Development

Development related useful commands

Git

  • Remove local branch
git branch -d <branch_name>
  • Undo last commit
git reset HEAD~  
  • Remove remote branch
git push origin --delete <branch_name>
  • Reset ahead local commits to remote
git reset --hard <remote>/<branch_name>
  • Create new branch from commit branch
git branch <branch_name> <sha1-of-commit>
  • Stash changes
git stash
  • Show stashed changes
git stash list
  • Apply stashed changes
git stash apply
  • Remove folder from git cache (after adding to .gitignore)
git rm -r --cached path_to_your_folder/

NPM & Node.js

  • Clean NPM registry and cache, avoiding ENOSPC and other errors
rm -rf ~/.npm
npm cache rm
npm cache clear
  • Increade node.js process memmory (in MB)
node --max_old_space_size=8196 myServer.js

Host file

  • Modify host file
sudo nano /etc/hosts

NVM

Node version manager. X.X.X referes to Node version number.

  • Install specific version of node
nvm install vX.X.X
  • Set default node version
nvm alias default X.X.X
  • Use version of node
nvm use X.X.X
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment