Skip to content

Instantly share code, notes, and snippets.

@lionel-rowe
Last active October 17, 2018 10:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lionel-rowe/d69c00e0364046d9f69c738a75659206 to your computer and use it in GitHub Desktop.
Save lionel-rowe/d69c00e0364046d9f69c738a75659206 to your computer and use it in GitHub Desktop.
Useful terminal commands/shortcuts (Linux::Ubuntu)

Useful terminal commands and shortcuts (Linux::Ubuntu)

Commands

  • sudo apt-get install <pkg name> install package
  • sudo apt-get remove <pkg name> remove package
  • apt list | grep <txt to search> search currently installed packages
  • xkill kill an unresponsive window w. mouse
  • touch to create file, mkdir to create dir
  • rm to delete file, rmdir to delete dir
    • rm -rf <path> recursively deletes dir and suppresses warning (can be dangerious. rm -rf / would delete everything. use with caution)
  • ls (list), ll (list w. details)
  • man <cmd name> show manual page
  • subl <path> open in sublime
  • irb interactive ruby shell; type exit to exit (Ctrl + C does nothing)
  • <many commands> followed by -h or --help or -? show version of that command/program
  • git commit -a -m "<commit message>" add all to staging and then commit
  • sudo reboot restart computer
  • pwd print working directory, i.e. path of current dir in file system
  • cat <file path> | xclip copy contents of trg to clipboard
  • nautilus <path> open in graphical file explorer
  • wget -qO- <url> | less print HTTP response to terminal (paginated with less)
  • subl ~/.aliases edit list of aliases
    • alias pag="less -RS#3NM~g +Gg"
    • alias ip-public="curl ipinfo.io/ip"
  • alias | less print all aliases
  • export VARNAME=value set environment variable
  • unset VARNAME delete environment variable
  • printenv | less print all environment variables
  • curl <url> > <new file path> create new file from response to HTTP request to given URL
  • git reset HEAD^ revert last commit and put changes back into staging
    • git reset --hard HEAD^ revert last commit and discard changes
  • systemctl suspend suspend/sleep computer
  • history show history of other commands entered into terminal
    • history -<num> only show last num commands

Keyboard shortcuts

  • Ctrl + Shift + + increase font size
  • Ctrl + - decrease font size
  • Ctrl + C stop execution
  • Ctrl + Shift + C or Ctrl + Ins copy
  • Ctrl + Shift + V or Shift + Ins paste
  • Ctrl + Shift + T new tab
  • Ctrl + Shift + W close tab
  • Ctrl + PgUp and Ctrl + PgDn move between tabs
  • Ctrl + Shift + Up and Ctrl + Shift + Down move up/down
  • Shift + PgUp and Shift + PgDn page up/down

One-time setup

  • sudo apt-get install fonts-arphic-ukai fonts-arphic-uming fonts-ipafont-mincho fonts-ipafont-gothic fonts-unfonts-core install CJK fonts
  • Create a swap file
  • gsettings set org.gnome.desktop.peripherals.touchpad click-method areas Enable right click (disabled by default in ubuntu 18.04)
  • xmodmap -pke > ~/keymaptable, then sudo subl /usr/share/X11/xkb/symbols/pc Change key bindings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment