{"id":13908521,"url":"https://github.com/JREAM/ubuntu-cheatsheet","last_synced_at":"2025-07-18T07:31:32.855Z","repository":{"id":78658778,"uuid":"68881925","full_name":"JREAM/ubuntu-cheatsheet","owner":"JREAM","description":"Ubuntu Terminal Cheatsheet","archived":false,"fork":false,"pushed_at":"2024-07-09T14:37:51.000Z","size":582,"stargazers_count":293,"open_issues_count":4,"forks_count":98,"subscribers_count":16,"default_branch":"main","last_synced_at":"2025-03-02T16:48:44.767Z","etag":null,"topics":["cheatsheet","ubuntu"],"latest_commit_sha":null,"homepage":null,"language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JREAM.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-09-22T03:41:31.000Z","updated_at":"2025-02-25T06:50:02.000Z","dependencies_parsed_at":"2024-11-25T17:33:36.797Z","dependency_job_id":"b27e9a68-3591-48dc-aec0-771863cb78f2","html_url":"https://github.com/JREAM/ubuntu-cheatsheet","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/JREAM/ubuntu-cheatsheet","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JREAM%2Fubuntu-cheatsheet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JREAM%2Fubuntu-cheatsheet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JREAM%2Fubuntu-cheatsheet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JREAM%2Fubuntu-cheatsheet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JREAM","download_url":"https://codeload.github.com/JREAM/ubuntu-cheatsheet/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JREAM%2Fubuntu-cheatsheet/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265720591,"owners_count":23817267,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cheatsheet","ubuntu"],"created_at":"2024-08-06T23:02:47.490Z","updated_at":"2025-07-18T07:31:32.497Z","avatar_url":"https://github.com/JREAM.png","language":"HTML","funding_links":[],"categories":["HarmonyOS"],"sub_categories":["Windows Manager"],"readme":"# Ubuntu Cheatsheet\n\nThis covers a wide assortment of quick references for the terminal/command-line. Additionally, near the bottom are more items for GUI and Troubleshooting.\n\n# Table of Contents\n- [Basics](#basics)\n- [Apt](#apt)\n  - [Apt Install](#apt-install)\n  - [Apt Update](#apt-update)\n  - [Apt Upgrade](#apt-upgrade)\n  - [Apt Remove](#apt-remove)\n  - [Apt Lock Error](#apt-lock-error)\n- [Listing and Navigating](#listing-and-navigating)\n- [Users](#users)\n- [Groups](#groups)\n- [Permissions](#permissions)\n    - [Easy Permissions](#easy-permissions)\n    - [Octal Permissions](#octal-permissions)\n    - [Octal Examples](#octal-examples)\n    - [Preserve Group Permissions](#preserve-group-permissions)\n- [OS Details](#os-details)\n    - [Operating System](#operating-system)\n    - [CPU Info](#cpu-info)\n    - [Usage Info](#usage-info)\n    - [Disk Space](#disk-space)\n    - [System Processes](#system-processes)\n    - [IP Address](#ip-address)\n    - [GUI Processes](#gui-processes)\n    - [CLI Processes](#cli-processes)\n- [Kernal](#kernal)\n    - [Remove Old Kernals](#remove-old-kernals)\n- [List all Keybindings](#list-all-keybindings)\n    - [See Keypressed](#see-keypressed)\n- [OS Shutdown](#os-shutdown)\n- [Crontab](#crontab)\n- [Services](#services)\n    - [Autostart](#autostart)\n    - [Remove Autostart](#remove-autostart)\n    - [Autostart Daemons](#autostart-daemons)\n    - [SystemD Commands](#systemd-commands)\n- [System State](#system-state)\n- [Processes](#processes)\n- [Bash](#bash)\n    - [Bash Paths](#bash-paths)\n    - [Add to Path](#add-to-path)\n    - [Bash Completions](#bash-completions)\n    - [Fix Broken Bash Completions](#fix-broken-bash-completions)\n    - [Log Script from Bash](#log-script-from-bash)\n- [Finding Files](#finding-files)\n- [Find in Files (GREP)](#find-in-files-grep)\n    - [Pipe Grep](#pipe-grep)\n- [Reading Files](#reading-files)\n- [Downloading Files](#downloading-files)\n    - [Using Wget](#using-wget)\n    - [Using cURL](#using-curl)\n- [Compressing and Uncompressing Files](#compressing-and-uncompressing-files)\n    - [Compressing Files](#compressing-files)\n    - [Decompressing Files](#decompressing-files)\n- [SCP](#scp)\n    - [Download from server to local](#download-from-server-to-local)\n    - [Upload from local to server](#upload-from-local-to-server)\n- [SSH](#ssh)\n    - [Connecting to a server](#connecting-to-a-server)\n    - [SSH Permissions](#ssh-permissions)\n    - [Using the Config](#using-the-config)\n    - [SSH to PEM](#ssh-to-pem)\n- [Firewall](#firewall)\n    - [UFW Status](#ufw-status)\n    - [UFW Enable/Disable](#ufw-enabledisable)\n    - [UFW Example Customization](#ufw-example-customization)\n    - [UFW More Options](#ufw-more-options)\n    - [UFW Deleting Rules](#ufw-deleting-rules)\n    - [UFW Reset Rules](#ufw-reset-rules)\n- [Regex](#regex)\n    - [Regex Examples](#regex-examples)\n- [MySQL](#mysql)\n    - [Connecting](#connecting)\n    - [Exporting Database to SQL](#exporting-database-to-sql)\n    - [Importing SQL Files](#importing-sql-files)\n    - [Exporting Compressed Database](#exporting-compressed-database)\n    - [Importing Compressed Database](#importing-compressed-database)\n    - [Get Database Encoding](#get-database-encoding)\n    - [Get Table Encoding](#get-table-encoding)\n    - [Get Column Encoding](#get-column-encoding)\n    - [Fix Broken Characters](#fix-broken-characters)\n- [Git](#git)\n    - [Populate a Repository](#populate-a-repository)\n    - [Add or Remove Files](#add-or-remove-files)\n    - [Ignoring files](#ignoring-files)\n    - [Create a Branch](#create-a-branch)\n    - [Switch Branches](#switch-branches)\n    - [Pull One File From Another Branch](#pull-one-file-from-another-branch)\n    - [Create a Tag](#create-a-tag)\n    - [Remove a Tag](#remove-a-tag)\n    - [Clone a Respository](#clone-a-repository)\n    - [Current Status](#current-status)\n    - [Commit Log and Show](#commit-log-and-show)\n    - [Reset Hard](#reset-hard)\n    - [Prune](#prune)\n- [Docker](#docker)\n    - [Docker Compose](#docker-compose)\n    - [Test Box Run](#test-box-run)\n    - [See Running Containers](#see-running-containers)\n    - [Run Container Interactively](#run-container-interactively)\n    - [Remove Container](#remove-container)\n    - [Bulk Remove Containers](#bulk-remove-containers)\n    - [Webserver Test Run](#webserver-test-run)\n    - [Stop Container](#stop-container)\n    - [Get New Docker Image](#get-new-docker-image)\n    - [Create Docker Image](#create-docker-image)\n    - [Remove Docker Image](#remove-docker-image)\n    - [Pushing Images](#pushing-images)\n- [Installing GUI's](#installing-guis)\n  - [Unity](#unity)\n  - [XUbuntu](#xubuntu)\n  - [Cinnamon - Linux Mint](#cinnamon-linux-mint)\n  - [GNOME](#gnome)\n  - [KDE](#kde)\n  - [LXQT](#lxqt)\n  - [Pantheon - ElementaryOS](#pantheon-elementaryos)\n  - [XFCE](#xfce)\n- [Troubleshooting](#troubleshooting)\n    - [Ubuntu Infinite Login](#ubuntu-infinite-login)\n- [Linux Facts](#linux-facts)\n\n# Common Commands\n***\n[(Back to Top)](#table-of-contents)\n\n| Command        | Description                                                        |\n|----------------|--------------------------------------------------------------------|\n| :q             | exits: MAN pages, VIM                                              |\n| clear          | dlears the terminal                                                |\n| date           | current datetime                                                   |\n| echo           | output to terminal                                                 |\n| echo -e        | output with variables and  escape characters.                      |\n| env            | See environment variables                                          |\n| hostname       | See your hostname                                                  |\n| locate crontab | I like mlocate more                                                |\n| man ls         | manual to give you a list of all command arguments for any command |\n| whatis ls      | tells you about the command                                        |\n| whereis bash   | find absolute location of bash                                     |\n| which python   | location of a program                                              |\n\n# Apt\n***\n[(Back to Top)](#table-of-contents)\n\nApt (Or Aptitude) is the **package manager** for Ubuntu to manage packages.\n\n\u003e There are some alternatives worth noting such as AppImage files and Snap packages, but that is out of scope here.\n\n\u003e Tip: You can use the `-y` flag in any apt command to skip the `[Y/n]` dialog.\n\n### Apt Install\n\nYou need super user permissions, or `sudo` before the command.\n\nTo install packages, let's use an example such as Ruby which should have a list of items.\n\n_@note: \u003cTAB\u003e means press the tab key_\n\n```sh\nsudo apt install rub\u003cTAB\u003e\u003cTAB\u003e\n# You should see a list of ruby installables.\n# If it's a long list you can type this is exit:\n:q\n```\n\n```sh\nsudo apt install ruby2.3\n```\n\n**TIP**: I like to add to my `~/.bashrc` file an alias for this as follows: `alias apt=sudo apt`\n\n### Apt Update\n\nUpdate will get the latest versions of all repositories (and custom ones you add in the future) and allow you to install\nnewer versions.\n\n- This lists are in: `/etc/apt/sources.list.d/`\n\n```sh\napt update\n```\n\n### Apt Upgrade\n\nThis will upgrade packages that have newer versions.\n\n```sh\napt upgrade\n# or, auto accept\napt upgrade -y\n```\n\n### Apt Remove\n\nRemoving a package is just as simple.\n\n```sh\napt remove someprogram\n# or, auto accept\napt remove someprogram -y\n```\n\nHowever, this will **not** remove configuration files, so if you were to re-install it they would be preserved.\n\nYou may also run the following:\n\n```sh\napt purge someprogram\n```\n\n### Apt Lock Error\n\nIf you get an error such as `Unable to lock the administration directory (/var/lib/dpkg/) is another process`, follow\nthese steps:\n\n- When you haven't booted in a while, be patient as this is one of the first things Ubuntu might do based on schedule.\n  _~5 mins_\n- Ensure another user is not running apt by typing: `who`\n- See if this has many operation running: `ps aux | grep apt` (Should return one line, which has no results and just the\n  command you typed)\n- If you need to, delete the lock and archive files:\n  - `rm /var/lib/apt/lists/lock`\n  - `rm /var/cache/apt/archives/lock`\n  - `dpkg --configure -a`\n- If the above does not work. Reboot the OS.\n\n# File Manager\n\n- The default file manager is `nautilus`.\n- Access From terminaal: `nautilus .`\n- Otherwise press \u003ckbd\u003eSUPER\u003c/kbd\u003e and type `files` to get to it.\n  - Set a Hotkey: \u003ckbd\u003eSettings\u003c/kbd\u003e, \u003ckbd\u003eCTRL+F\u003c/kbd\u003e, search for `keyboard` or `shortcut`.\n  - Change `Home Folder` to a hotkey of your choice, I prefer \u003ckbd\u003eSUPER + E\u003c/kbd\u003e since I came from Windows.\n\n# Listing and Navigating\n\n***\n[(Back to Top)](#table-of-contents)\n\n| Command     | Description                                     |\n|-------------|-------------------------------------------------|\n| cd ..       | go down a directory                             |\n| cd /        | go to lowest level                              |\n| cd /var/www | go to absolute path                             |\n| cd ~        | go to logged in user's home                     |\n| ls          | list files                                      |\n| ls -la      | list all files, ~~permissions~~, and hidden too |\n| pwd         | print working directory                         |\n\n### Manage Files and Folders\n\n| Command           | Description                                  |\n|-------------------|----------------------------------------------|\n| cp -R \u003cdir\u003e \u003cloc\u003e | copy directory from location to new location |\n| cp \u003cfile\u003e \u003cloc\u003e     | copy file from location to new | location |\n| mkdir \u003cdir\u003e | create a directory        |\n| mv \u003cdir\u003e \u003cloc\u003e      | move directory from location | to new location |\n| mv \u003cfile\u003e \u003cloc\u003e     | move file from location to new | location |\n| rm -rf \u003cdir\u003e        | remove a directory with | contents |\n| rmdir \u003cdir\u003e | remove an empty directory |\n| touch \u003cfile\u003e        | create an empty file |\n\n### Reading Files\n\n\n| Command           | Description               |\n|-------------------|---------------------------|\n| cat \u003cfile\u003e        | read entire file          |\n| head \u003cfile\u003e       | read top of a file        |\n| head \u003cfile\u003e -n 20 | read top of file 20 lines |\n| tail \u003cfile\u003e       | read bottom of a file     |\n| tail \u003cfile\u003e -f      | stream file as it's updated, | eg: an error log |\n| tail \u003cfile\u003e -n 20 | read bottom of file 20 lines |\n\n\n# Users\n***\n[(Back to Top)](#table-of-contents)\n\n\n| Command                                    | Description                     |\n|--------------------------------------------|---------------------------------|\n| passwd                                     | change logged in users password |\n| su - username                              | switch users                    |\n| sudo su                                    | switch to root                  |\n| useradd -m -s /bin/bash username           | Create User                     |\n| usermod -a -G existing_group existing_user | Add User to Group               |\n| who                                        | show all logged in users        |\n| whoami                                     | show which user you are         |\n\n# Groups\n***\n[(Back to Top)](#table-of-contents)\n\nDo not delete groups you don't know what they are used for, that's dangerous!\n\n\n| Command       | Description                             |\n|---------------|-----------------------------------------|\n| groups        | see what groups current user belongs to |\n| groupadd name | create a group                          |\n| groupadd -g 900 name        |create a group with | custom GroupID aka gid|\n|||\n|groupdel name               |delete a group|\n|useradd \u003cgroup\u003e             |add current user to a |group|\n|usermod -aG \u003cgroup\u003e \u003cuser\u003e  |append any user to an |additional group|\n|||\n|cat /etc/group              | list all groups|\n|cut -d: -f1 /etc/group      | list all groups, cleaner|\n\n# Permissions\n***\n[(Back to Top)](#table-of-contents)\n\nThere are two ways to manage permissions, one is by text the other is by an octal value.\n\n### Easy Permissions\n```\n; Change Mode\n; Options: (O)wner (U)sers (G)roup or (A)ll\n; File:    Owner: rwx, Group: rwx, User: rwx\n; Misc:    Besides rwx there is:\n;          s = setuid of owner for old/new files\n\n; Single File read/write permissions\nchmod g+rw file\nchmod og+rw file.txt\n\n; Change Ownership\nchown user:group files_or_folder\nchgrp group files_or_folder\n\n; Recursively:\nchown -R user:group files_or_folder\nchgrp -R group files_or_folder\nchmod -R og+rw files_or_folder\nchmod -R g+s files_or_folder\n```\n\n### Preserve Group Permissions\nA fantastic way to structure your users is within groups. A common example would be your `www-data` group.\nIf I have a user `jesse`, I can add him with `sudo usermod -aG www-data jesse`.\n\nAfter adding any users I would like, I want to have a folder where all the members of the `www-data` group\ncan read/write a folder. If they are using git, I also want the permissions to stay the same, meaning if they\npull the permissions will not change.\n\nTo accomplish this, here is an example:\n```\nsudo chown -R deploy:www-data /var/www\nsudo chmod -R g+rws /var/www\n```\n\nThe `g+s` sets the file(s)/folder(s) a gid (`setgid`) so that new files will inherit the original group!\n\n### Octal Permissions\nYou may have seen this a lot, you can use octal or decimal (begins with a 0) to do the same thing.\n```\nPermissions:\n0 = None\n1 = Execute (e)\n2 = Write (w)\n4 = Read (r)\n```\n\n- There are 3 Permission types (Read, Write, Execute), or 4 if you count \"None\".\n- There are 3 Sets: Owner/User/Group (In that order)\n- So if you did `chmod 700 file.txt` it would allow the user to Read, Write and Execute\n  - Because `7` is the total of `4 + 2 + 1`\n\n### Octal Examples\n```\nchmod 600 file.txt – Owner Read, Write\nchmod 660 file.txt – Owner Read, Write; User Read, Write\nchmod 770 file.txt – Owner Read, Write, Execute\nchmod 770 file.txt – Owner Read, Write, Execute; User Read, Write, Execute\nchmod 666 file.txt – All Read, Write\nchmod 777 file.txt – All Read, Write, Execute\n```\n\n# OS Details\n***\n[(Back to Top)](#table-of-contents)\n\nGet fundamental information about your OS with the following commands, you may have to run them as `sudo`, eg: `sudo lsb_release -a`.\n\n##  Operating System\n\n```\nlsb_release\nlsb_release -a\nlsb_release -as     # Short Information\nlsb_release --help\n```\n\n### CPU Info\n\n```\nnproc               # How many Processing Units\ncpuid               # Must install cpuid from terminal\ncat /proc/cpuinfo   # Lots of info\n```\n\n### Usage Info\n\n```\nfree -h             # Human readable, or do --help for options\nvmstat -s\ncat /proc/meminfo   # Lots of info\n```\n\n### Disk Space\n\n```\ndf\ndf -B MB    (In Megabtyes, KB for Kilobytes, GB for Gigabytes)\n```\n\n### System Processes\n\n```\ntop\nhtop  # If you installed it\n```\n\n### IP Address\nYour IP is after `inet addr`. If you are connect via ethernet it's under `eth0 (Ethernet)` otherwise, wirelessly it is likely under `wlan0 (Wireless LAN)`.\n\n```\nifconfig\nip\nip addr show\nip addr show wlan\nip addr show eth0\n```\n\n### GUI Processes\n\n```\ngnome-system-monitor\n```\n\n### CLI Processes\n```\ntop\nhtop     (My favorite, sudo apt-get install htop)\nnmon\n```\n\n# List all Keybindings\n***\n[(Back to Top)](#table-of-contents)\n\n```\ngsettings list-recursively  org.gnome.desktop.wm.keybindings | sort | more\n```\n\n### See Keypressed\n[(Back to Top)](#table-of-contents)\n\n```\nxev\n\n; Or for a lot of details:\n\nxev | grep KeyPress\n```\n\n# Kernal\n***\n[(Back to Top)](#table-of-contents)\n\nThe Kernal is the lowest level item that ties everything together from hardware to software.\nWithout a kernal you cannot do anything on linux.\n\n### Remove Old Kernals\n\nSee What version you are currently using\n```\nsudo uname -a\n```\n\nSee all the Kernals on the OS\n```\nsudo dpkg --get-selections | grep linux\n```\n\nThe BYOBU is quite nice\n```\nsudo apt install byobu\nsudo purge-old-kernels\n```\n\n# OS Shutdown\n***\n[(Back to Top)](#table-of-contents)\n```\nshutdown\nreboot\nshutdown -h now\nshutdown -h +10     (shutdown 10 mins)\nshutdown -r now     (reboot now)\n```\n\n# Crontab\n***\n[(Back to Top)](#table-of-contents)\n```\ncrontab -e              (edit crontab for current user)\ncrontab -l              (list crontab for other user)\ncrontab -u jesse -l     (see crontabs for specific user)\n```\n\n# Services\n***\n[(Back to Top)](#table-of-contents)\n\n## Service Commands\nUse the service command *(Requires sudo)*\n```\nservice ssh status      (service status)\nservice --status-all    (all services status)\n```\n\n\nAlmost every service has the following commands, some may have more like apache `graceful-restart`:\n```\nservice servicename start\nservice servicename stop\nservice servicename restart\nservice servicename status\nservice servicename force-reload\n```\n\n## Autostart\n\nAdd Service links:\n```\nsudo update-rc.d servicename defaults\n```\n\nWhether you get a warning if they already exist or not, enable it now:\n```\nsudo update-rc.d servicename enable\n```\n\n## Remove Autostart\nPass the Force flag\n```\nsudo update-rc.d -f servicename remove\n```\n\n\n## Autostart Daemons\n\nThere is are several startup popular daemons:\n- CentOS uses SystemV\n- Ubuntu 14 uses Upstart\n- Ubuntu 14.10+ uses SystemD (15, 16, 17..)\n\nFocus on **SystemD**.\n\n## SystemD Commands\nThis would only apply to Ubuntu 14.10+, otherwise you would use Upstart.\n\n```\nsystemctl     \u003c-- You'll use this more often\njournalctl    \u003c-- You'll use this more often\nupdate-rc.d   \u003c-- You'll use this more often\n                  --------------------------\n                  Installs/Removes System-V style init script links\n                  Note: System-V Style, but it's really SystemD. (Confusing huh?)\n\n                  \"NNname\" is the runlevel, lower means startup sooner\n                  ----------------------------------------------------\n                  The Location is: /etc/rcrunlevel.d/NNname\n                  The Target is:   /etc/init.d/name.\nnotify\nanalyze\ncgis\ncgtop\nloginctl\nnspawn\n```\n\n# System State\n***\n[(Back to Top)](#table-of-contents)\n```\nuname -a (get linux info)\n\ntop (See running processes/system status, I suggest installing `htop`)\ntop -u www-data\nhtop -u www-data\n\ndf          (display disk space in bytes, default)\ndf -h       (display disk space human readable)\ndf -Th      (display disk space with partitions)\n\nfree (see memory used)\nfree -g (in gigabytes)\n```\n\n# Processes\n***\n[(Back to Top)](#table-of-contents)\n```\nps -ef | more       (current running processes)\nps -efH | more      (current running processes in a tree)\n\nps -ef | grep vim   (find vim process id)\nkill -9 \u003cid\u003e        (no brackets)\n```\n\n# Bash\n***\n[(Back to Top)](#table-of-contents)\n\nBash is my shell of choice, which is why I have a `.bashrc` file.\n\n### Bash Paths\n\nExecutables and commands are automatically in the path, see your path with:\n```\necho $PATH\n```\n\n### Add to Path\n\n```\n# I suggest editing your ~/.profile\n\nvim ~/.profile\nif [ -d \"/path/to/your/bin\" ] ; then\n  PATH=\"$PATH:/path/to/your/bin\"\nfi\n```\n\n*Note: Order of Linux Reading files: ~/.bash_profile, ~/.bash_login, and ~/.profile, so don't try to use a ~/.profile variable within ~/.bash_profile*\n\n### Bash Completions\n\nThe locations for bash completio0ns can be found at:\n```\ncd /usr/share/bash-completion/completions.d/\ncd /etc/bash_completions.d/\n```\n\n### Fix Broken Bash Completions\n\n```\nsudo apt-get install --reinstall bash-completion\n```\n\n### Log Script from Bash\nAt the top of your file, find the executable you are using one of these, eg:\n```\nwhich bash     # /usr/bin/bash\nwhich python   # /usr/bin/python\nwhich php      # /usr/bin/php\n```\n\nAt the top of your [shebang](https://en.wikipedia.org/wiki/Shebang_(Unix)) for the executable file add:\n\n```\n#!/bin/bash\n#!/usr/bin/php\n#!/usr/bin/python\n```\n\nmake sure to `+x` it:\n```\nchmod +x app.sh\nchmod +x app.php\nchmod +x app.py\n```\n\nYou can then run the script via Bash:\n```\n/scripts/app.sh \u003e\u003e /scripts/output.log 2\u003e\u00261\n/scripts/app.php \u003e\u003e /scripts/output.log 2\u003e\u00261\n/scripts/app.py \u003e\u003e /scripts/output.log 2\u003e\u00261\n```\n\nYou could even crontab it the same way:\n```\n*/10 * * * * app.php \u003e\u003e /output.log 2\u003e\u00261\n*/10 * * * * app.py \u003e\u003e /output.log 2\u003e\u00261\n```\n\n# Finding Files\n***\n[(Back to Top)](#table-of-contents)\n\nGenerally the following arguments are as follows:\n- `-type f` file\n- `-type d` directory\n- `-iname` case insensistive (book.txt would the same as BOOK.TXT)\n- `*` is a wildcard to find anything, usually you put it at the start or end of a filename.\n```\nfind . -name tecmint.txt\nfind /home -name tecmint.txt\nfind /home -iname tecmint.txt                        (case ignore)\nfind / -type d -name Tecmint                         (directory)\nfind . -type f -perm 0777 -print (with perms)\nfind / -type f ! -perm 777 (find without)\nfind . -type f -name \"tecmint.txt\" -exec rm -f {} \\; (find and remove a file)\nfind . -type f -name \"*.txt\" -exec rm -f {} \\;       (find and remove multiple)\nfind /tmp -type f -empty                             (Find empty files)\nfind /tmp -type d -empty                             (find empty directories)\nfind / -size +50M -size -100M (findby swize)\n```\n\n# Find in Files (GREP)\n***\n[(Back to Top)](#table-of-contents)\n\nGREP means: Global Regular Expression Pattern (or Parser)\n\nSome common GREP flags:\n- `-r` is Recursive\n- `-n` is Line Number\n- `-w` Match the whole word\n- `-l` is lowercase only\n- `-c` supresses normal output and counts number of matching lines\n\n```\ngrep -rn /path - \"pattern_or_string\"\n\n; Output results to File\ngrep -rnw /path - \"pattern_or_string\" \u003e output.txt\n```\n\nLook only in certain filetypes\n```\n; notice I used a regex ^ starts with, you can use a string or regex\ngrep --include=*.sh '^mysql' ./\n```\n\nMore Examples:\n```\ngrep \"hello\" file.txt (if in file)\ngrep \"hello\" files*  (if in many files)\ngrep -i \"hello\"  file.txt  (case insesitive)\ngrep -iw \"is\" file.txt (get full words, case insensitive)\ngrep \"regex\" file.txt\n```\n\n### Pipe Grep\n```\nphp -i | grep ini\n```\n\n# Reading Files\n***\n[(Back to Top)](#table-of-contents)\n\nWithout having to open a file you can simply read a part of it without `nano`, `pico, `vi`, or `vim`:\n```\ncat file.txt            (view file contents)\ntail file.txt           (view end of file contents)\ntail -n20 file.txt      (view top 20 lines)\ntail -f filetxt         (follow a filename keep updating)\nhead file.txt           (view top of file contents)\nhead -n20 file.txt      (view top 20 lines)\n```\n\n# Downloading Files\n***\n[(Back to Top)](#table-of-contents)\n\n### Using Wget\n```\nwget http://file.com/something.txt                (Download a file locally)\nwget -O newname.txt http://file.com/something.txt (Download file locally w/new name)\n```\n\nYou can also use `SCP`, yet the above are easier for non-SSH connections.\n\n### Using cURL\n```\ncurl -O http://file.com/something.txt               (Download a file locally)\ncurl -o newname.txt http://file.com/something.txt   (Download file locally w/new name)\ncurl -O http://url_1 -O http://url_2                (Download multiple files)\n```\n\n# Compressing and Uncompressing Files\n***\n[(Back to Top)](#table-of-contents)\n\nTo Compress a file you can use a variety of tools. You can type `man gzip` to see the full manual and line of commands, and use `esc` + `:x` and `ENTER` to exit from the Manual (It usually uses the Vi editor).\n\nMost often in the Linux word you use and create `*.tar.gz` files, it has the most options. Whatever you prefer is up to you.\n\nWhat the flags often stand for:\n- `-c` is create\n- `-f` is file\n- `-k` is for Keep\n    - `gzip` \u0026 `bzip2` will remove the original file once compressed\n    -  Or they will remove the `.gz` when decompressing is done\n- `-r` is recursive (for gzip and zip)\n- `-v` is verbose (show details of what's happening)\n- `-z` is for tar to gzip as well\n- `--exclude='file'` is for tar (+gz if needed) to exclude certain files)\n\n###  Compressing Files\nNote: You can compress more than one file at a time eg: `bzip2 file1.txt file2.txt file3.txt`\n\n```\ngzip -vk file.txt                   (Creates file.txt.gz)\nbzip2 file.txt                      (Creates  file.txt.bz2)\ntar -cvf file.tar file.txt          (Creates tar)\ntar -czvf file.tar.gz file.txt      (Creates tar.gz)\nzip filename.zip file.txt           (Creates filename.zip)\nzip -r folder.zip path/to/folder    (Creates  folder.txt.bz2)\n```\n\nInclude/Exclude a few files:\n```\n; Exclude certain files\ntar -czvf file.tar.gz \u003cdirectory\u003e/ --exclude='*.jpg' --exclude='bigfile.sql'\n\n; Include one file type\ntar -czvf file.tar.gz \u003cdirectory\u003e/*.sh\n\n; Include multiple files types\ntar -czvf file.tar.gz `find \u003cdirectory\u003e | grep '.sh\\|.py'`\n```\n\n### Decompressing Files\nTo Uncompress we use similar commands for most of them\n```\ngunzip -dvk file.txt.gz\ngzip -dvk file.txt.gz       (Same as above)\nbzip2 -d file.txt.bz2\ntar -xvf file.tar\ntar -zxvf file.tar.gz\nunzip test.zip\n```\n\n# SCP\n***\n[(Back to Top)](#table-of-contents)\n\n### Download from server to local\n```\nscp root@server.com:/path/to/file.txt file.txt\n```\n\n### Upload from local to server\n```\nscp file.txt root@server.com:/path/to/file.txt\n```\n\n# SSH\n***\n[(Back to Top)](#table-of-contents)\n\n### Connecting to a server\n```\nssh name@server.com  (default port is 22)\nssh name@server.com -p 8000 (connect to specific port)\nssh name@server.com -i ~/.ssh/rsa_key.pub (connect with ssh key)\n```\n\n### .SSH Permissions\n\nThese are safe permissions to use for SSH\n```\nchmod 700 ~/.ssh\nchmod 644 ~/.ssh/id_rsa.pub\nchmod 600 ~/.ssh/id_rsa\n\n# Put your pubkeys (one per line) for SSH login\nchmod 600 ~/.ssh/authorized_keys\n```\n\n\n### Using the Config\nYou can also create a `~/.ssh/config` file and store entries such as:\n```\nHost aws\nHostname ec2-50-50-130-50.compute-1.amazonaws.com\nPort 22\nIdentityfile ~/.ssh/id_rsa\nUser myusername\n\nHost my-vps\nHostname 50.50.130.50\nPort 22\nUser root\n```\n\nYou can then simply type:\n```\nssh aws\nssh my-vps\n```\n\n### SSH to PEM\nSometimes you may need a `PEM` format SSH Key. You can easily add this alongside your other SSH keys.\n```\nopenssl rsa -in ~/.ssh/keyname_rsa -outform pem \u003e keyname_rsa.pem\nchmod 700 keyname_rsa.pem\n```\n\n# Firewall\n***\n[(Back to Top)](#table-of-contents)\n\nA firewall prevents unauthorized access to your machine, you should use `UFW` (Uncomplicated Firewall). You must always run this with `sudo`. If you don't have UFW installed, run:\n\n```\nsudo apt-get install ufw\n```\n\n### UFW Status\nTo see the Firewall Status run one of these:\n```\nsudo ufw status\nsudo ufw status verbose\n```\n\n### UFW Enable/Disable\n```\nsudo ufw enable\nsudo ufw disable\n```\n\n### UFW Example Customization\nPlease do not do this unless you know what you are doing.\n\nYou could start out with blocking all incoming connections.\n```\nsudo ufw default deny incoming\nsudo ufw default allow outgoing\n```\n\nThen we allow only what we want\n```\nsudo ufw allow ssh\nsudo ufw allow http\nsudo ufw allow https\nsudo ufw allow ftp\n```\n\nThese are the same as:\n```\nsudo ufw allow 22   # same as ssh\nsudo ufw allow 80   # same as http\nsudo ufw allow 443  # same as https\n```\n\n### UFW More Options\n\nIf SSH was on port `3333` rather than the default `22` you would do:\n```\nsudo ufw allow 3333/tcp\n```\n\nSome more options:\n\n```\nsudo ufw allow 25 # SMTP\nsudo ufw allow 110 # POP3\nsudo ufw allow 995 # POP3S\nsudo ufw allow 143 # IMAP\nsudo ufw allow 993 # IMAPS\nsudo ufw allow 3306 # MySQL\nsudo ufw allow 5432 # Postgres\nsudo ufw allow from 192.168.255.255 # Custom IP Address\n```\n\n### UFW Deleting Rules\nEasily delete named rules\n```\nsudo ufw delete allow ssh\n```\n\nDelete rules that are numbered\n```\nsudo ufw status numbered\nsudo ufw delete [number]\n```\n\n### UFW Reset Rules\n```\nsudo ufw reset\n```\n\n# Regex\n***\n[(Back to Top)](#table-of-contents)\n\nRegex stands for Regular Expression. It's used for locating or replacing files or\nstrings of text. It is used all the time. These can be used in Linux itself and programming\nlanguages.\n\n```\n; Symbolism\n; ------------------\n()          (captures groups)\n[]          (set)\n{}          (quantifier)\n?           (optional, matches 0 or 1 character)\n*           (matches 0 or more characters)\n.           (match any character)\n+           (match one or more character)\n\\           (escape character)\n!           (false, is not)\n^           (starts with)\n$           (ends with)\n|           (or statement, eg: (jesse|dan|jenkins) )\n\n; Basic Primer\n; ------------------\n\\w          (word)\n\\W          (non-word)\n\\s          (whitespace)\n\\S          (non-whitespace)\n\\d          (digit)\n\\D          (non-digit)\n[ab]        (character set)\n[^ab]       (negated set)\n[a-m]       (range)\n(hello)     (group)\n(hello)+    (group, more than once)\n\n; Groups\n; ------------------\n(hi)        (gets all \"hi\" occurances)\n(^hi)       (gets all text starting with \"hi\")\n(es$)       (gets all text ending with \"es\")\n(hi)\\1      (gets the first occurance of \"hi\")\n\n; Flags\n; ------------------\n/i          (case insensitive)\n/g          (global)\n/m          (multiline)\n\n; Escaped Characters\n; ------------------\n; Since characters such as \".\", \"+\", etc are actual Regex pattern makers, if you\n; need to check your content for the literal item you must escape them.\n\\.          (matches . character)\n\\+          (matches + character)\n\\?          (matches ? character)\n\\*          (matches * character)\n\\^          (matches ^ character)\n\\$          (matches $ character)\n\\[          (matches [ character)\n\\(          (matches ( character)\n\n\\t          (matches tab character)\n\\n          (matches newline)\n\\r          (matches return carriage)\n\\0          (matches NULL character)\n\\\\          (matches \\ character)\n\\/          (matches / character)\n```\n\n### Regex Examples\n```\nPut Examples here, like phones, names, etc..\n\n```\n\n# MySQL\n***\n[(Back to Top)](#table-of-contents)\n\n- `-u` is for User (default: root)\n- `-p` is for Password\n- `-p password` is for password which skips the prompt (not recommended)\n- `-h` is for host (default: localhost)\n- `-port or -P` is for a port, default is 3306\n- `-f` will force SQL import and skips errors\n- `-v` will display verbose output\n- In the `mysql\u003e` terminal you can get clean data by doing `\\g`:\n    - `mysql\u003e SELECT * FROM users LIMIT 10\\g\";`\n\n### Connecting\n```\nmysql -u root -p (username, password prompt)\nmysql -u root -p -h localhost (username, password prompt, host)\nmysql -u root -p password -h localhost -P 3306\n\n; AWS Example (AWS Defaults to 3306 as most MySQL connections do)\nmysql -u username -p password -h myinstance.123456789012.us-east-1.rds.amazonaws.com\n```\n\n### Exporting Database to SQL\nYou can dump a single database easily:\n```\nmysqldump -u root -p DATABASE_NAME \u003e file.sql\n```\n\nOr Dump all databases on your MySQL server with the `--all-databases` flag:\n```\nmysqldump -u root -p --all-databases \u003e file.sql\n```\n\n### Importing SQL Files\nYou can do this through the shell only, or MySQL, first is the shell:\n```\nmysql -u root DATABASE_NAME \u003c path/to/file.sql\n```\n\nTo continue when there are MySQL Errors use -f or --force below:\n```\nmysql -u root DATABASE_NAME \u003c path/to/file.sql --force\n```\n\nTo use a password, just pass in the -p flag and type it in after running:\n```\nmysql -u root -p DATABASE_NAME \u003c path/to/file.sql --force\n```\n\nSecond, you can do it through MySQL once you connect:\n```\nmysql\u003e use DATABASE_NAME;\nmysql\u003e source path/to/file.sql;\n```\n\n### Exporting Compressed Database\nThis will save a lot of space in this one liner:\n```\nmysqldump -u root -p DATABASE_NAME | tar -cvzf \u003e output.sql.tar.gz\nmysqldump -u root -p DATABASE_NAME | gzip -v \u003e output.sql.gz\n```\n\n### Importing Compressed Database\nHere is how you can import with the one liner:\n```\nmysql -u root -p DATABASE_NAME | tar -xzOf output.sql.tar.gz\nmysql -u root -p DATABASE_NAME | gunzip \u003c output.sql.gz\n```\n\n### Get Database Encoding\n```\nUSE DATABASE_NAME;\nSELECT @@collation_database;\n```\n### Get Table Encoding\n```\nSELECT default_character_set_name FROM information_schema.SCHEMATA\nWHERE schema_name = \"TABLE_NAME\";\n```\n\n### Get Column Encoding\nLook at the collation table. Numeric fields won't have a collation.\n```\nSHOW FULL COLUMNS FROM TABLE_NAME\n```\n\n### Fix Broken Characters\n\nFirst, try this query without affecting anything to see:\n```\nSELECT CONVERT(BINARY CONVERT('Weâ€™re Here!' using latin1) using utf8);\n```\nThat should fix the encoding problem.\n\nTo update a column:\n```\nUPDATE TABLE_NAME SET COLUMN_NAME = CONVERT(BINARY CONVERT(COLUMN_NAME using latin1) USING utf8);\n```\n\n# Git\n***\n[(Back to Top)](#table-of-contents)\n\n### Populate a Repository\nYou have to first create a repostory, through BitBucket, GitHub, GitLab, etc.\n```\ngit init\ntouch README.md\ngit remote add origin git@github.com/username/yourrepo.git\ngit add .\ngit commit -m \"Starting with one file\"\ngit push origin master\n```\n### Add or Remove Files\n```\ngit add file.txt\ngit rm file.txt\n```\n\n### Ignoring files\nCreate a `.gitignore` file, and place something like this in it:\n```\n.tmp\n.py[co]\n.cache\n.DS_Store\n```\n\n### Create a Branch\nBranches are used like when you don't want to ruin a main branch with working code.\n\n```\ngit checkout -b develop\ngit push origin develop\n```\n\n### Switch Branches\n```\ngit checkout master\ngit checkout develop\n```\n\n### Pull One File From Another Branch\nIf you were on your `master` branch and only wanted to pull a single file from `develop` branch, you can do this:\n```\n; Make sure you're on the branch you want to pull into\ngit checkout master\n\n; Pull a single file into master from develop\ngit checkout develop -- relative/path.txt\n\n; Continue by comitting and pushing to master\n```\n\n### Create a Tag\nTags create a snapshots of current code, you may name it as a version such as `1.0.1` and it produces a `tar.gz` and `zip` format for downloads.\n```\ngit tag -a 1.0\ngit tag -a 1.0 -m \"Optional Message\"\ngit push --tags\n```\n\n### Remove a Tag\nThis will remove a tag from the Git host.\n```\ngit tag -d 1.0\ngit push origin :refs/tags/1.0\n```\n\n### Clone a Respository\n```\ngit clone git@github.com/username:your_repo.git\n```\n\nClone into current directory\n```\ngit clone git@github.com/username:your_repo.git .\n```\n### Current Status\n```\ngit status\n```\n\n### Commit Log and Show\nTo see log data and more details use the short or long commit ID.\n```\ngit log\ngit show eb7c86a5fbdc6c64df608f4c143c2718a100983b\n```\n\n### Reset Hard\nThis will reset your repository to the last revision and undo everything, use with caution.\n```\ngit reset --hard HEAD\n```\n\n### Prune\nRemoves cached items no longer read by git\n```\ngit prune\n```\n\n# Docker\n***\n[(Back to Top)](#table-of-contents)\n\nTo install visit [https://docs.docker.com/engine/installation/linux/ubuntulinux/](https://docs.docker.com/engine/installation/linux/ubuntulinux/)\n- **Images**: (Blueprints of an application)\n    - **Image BASE**: No parent Image (An OS)\n    - **Image CHILD**: Builds on a Base Image (Eg: Webserver, MySQL)\n- **Containers**: Created from an IMAGE and run an application.\n- **Docker Daemon**: Background service that builds, runs, and does everything.\n- **Docker Client**: Allows us to interact with the Docker Daemon.\n- **Docker Hub**: A registry of images (Like: npmjs, pip, packagist, bower)\n\n### Docker Compose\nThis is a great utility that makes managing docker easier from a `docker-compose.yml` file, you should install this after playing around with the below options. See: [https://docs.docker.com/engine/installation/linux/ubuntulinux/](https://docs.docker.com/engine/installation/linux/ubuntulinux/)\n```\ndocker-compose up\nopen http://localhost:3000\n```\n\n### Test Box Run\nThis is a sample box to test once you installed docker\n```\ndock pull busybox\ndocker images\ndocker run busybox \"Hi from the box\"\n```\n\n### See Running Containers\n```\ndocker ps (running containers)\ndocker ps -a (see all containers that ran)\n```\n\n### Run Container Interactively\nThis allows you to get inside the container\n```\ndocker run -it busybox sh (interactive)\n```\n\n\n### Remove Container\nRemoves a CONTAINER, not an IMAGE\n\n```\ndocker ps -a\ndocker rm \u003cCONTAINER ID\u003e\n```\n\n### Bulk Remove Containers\nYou can remove containers based on their status in bulk, eg:\n```\ndocker rm $(docker ps -a -q -f status=exited)\ndocker rm $(docker ps -a -q -f status=created)\n```\n\n### Webserver Test Image\nThis will download the IMAGE and run it if it doesn't exist\n```\ndocker run prakhar1989/static-site\n```\n\nThis doesn't expose ports for us to use, so we do the following:\n```\ndocker run -d -P --name static-site prakhar1989/static-site\n```\n\n- `-d` detaches terminal so we can run commands in our terminal\n- `-P` publishes all exposed ports to random ports\n\nBy doing the above command we are given random ports, eg:\n```\n  443/tcp -\u003e 0.0.0.0:32768\n  80/tcp -\u003e 0.0.0.0:32769\n```\n\nYour ports may be different, you can use specific ports with a lowercase `-p`:\n```\ndocker run -p 8888:80 prakhar1989/static-site\n```\n\n### Stop Container\n```\ndocker stop static-site\n```\n\n### Get New Docker Image\nThis would be a docker BASE IMAGE\n```\ndocker pull ubuntu:14.04\n```\n\n### Create Docker Image\nThis is a flask Example using a Python-3 Base IMAGE\n\n- Create `requirements.txt` and just put `flask`\n- Create an `app.py`\n- Use the following sample code in `app.py`:\n\n```\nfrom flask import Flask\napp = Flask(__name__)\n\n@app.route('/')\ndef hello_world():\n    return 'Hello, World!'\n```\n\n- Create a docker file, title it `Dockerfile`\n- Enter the following\n\n```\nFROM python:3-onbuild\nEXPOSE 5000\nCMD [\"python\", \"./app.py\"]\n```\n\nNow build the image\n\n```\ndocker build -t boyus .\ndocker images\n```\n\n### Remove Docker Image\nGet a list of images, then just delete by image id with `rmi` aka `remove image`:\n```\ndocker images\ndocker rmi \u003cIMAGE ID\u003e\n```\n\n\n### Pushing Images\nYou need a repository at docker.io to push this, or probably some private hosting.\n```\ndocker push boyus\n```\n\n\n# Installing GUI's\n***\n[(Back to Top)](#table-of-contents)\n\nLinux has a lot of GUI's and you are not limited to what you get. I'll list a few popular ones with the installation instructions in Ubuntu. You can have as many GUI options as you like, just change the default at the login screen.\n\n\u003e Tip: After you install, logout and in the login menu or the top right you can select what GUI you want to login with. Whenever you install a new GUI you can select a Display Manager, I recommend using `lightdm`.\n\n--\n\n### Unity\n\n[**Unity Website**](https://unity.ubuntu.com/)\n\n```\nInstalled in Ubuntu 12+ by Default (`ubuntu-desktop`)\n```\n\n### XUbuntu\n\n[**XUbuntu Website**](https://xubuntu.org/)\n\n```\n; Install:\nsudo apt-get install xubuntu-desktop\n\n; Remove:\nsudo apt-get remove xubuntu-desktop\n```\n\n### Cinnamon (Linux Mint)\n\n[**Linux Mint Website**](https://www.linuxmint.com/)\n\n```\n; Install:\nsudo add-apt-repository ppa:moorkai/cinnamon\nsudo apt-get update \u0026\u0026 sudo apt-get install cinnamon\n\n; Remove\nsudo ppa-purge ppa:moorkai/cinnamon\n```\n\n\n### GNOME\n\n[**GNOME Website**](https://www.gnome.org)\n\nThis has been one of the all time most popular GUI's for Linux ever made, in particular the `gnome-classic`.\n\n```\n; Install:\nsudo apt-get install ubuntu-gnome-desktop    (For legacy gnome use you can use gnome-shell, this install both)\n\n; Remove:\nsudo apt-get remove ubuntu-gnome-desktop     (Removes gnome-shell as well)\n```\n\n\u003e Gnome3 has been my favorite GUI due to how I can customize it. However, for unknown reasons I have issues running only Gnome3 in VMWare Workstation 11. It works fine as a complete install.\n\nNoteworthy: Visit [Gnome Shell Extensions](https://extensions.gnome.org/) to customize anything you want. Make sure to use Firefox.\n\n\n### KDE\n\n[**KDE Website**](https://www.kde.org/)\n\nThis is a very popular GUI for people that are used to Windows Desktops.\n\n```\n; Install:\nsudo add-apt-repository ppa:kubuntu-ppa/backports\nsudo apt-get update \u0026\u0026 sudo apt-get dist-upgrade\nsudo apt-get install kubuntu-desktop\n\n; Remove:\nsudo apt-get remove kubuntu-desktop\n```\n\n### LXQT\n\n[**LXQT Website**](http://lxqt.org/)\n\n```\n; Install:\nsudo apt-get install lxqt\n; Remove:\nsudo apt-get remove lxqt\n```\n\n### Pantheon (ElementaryOS)\n\n[**Elementary OS Website**](https://elementary.io/)\n\nFor the best stability I use Elementary OS which is based off of Ubuntu.\n\n```\n; Install:\nsudo add-apt-repository ppa:elementary-os/stable\nsudo apt-get update\nsudo apt-get install elementary-desktop\n\n; Remove:\nsudo apt-get remove elementary-desktop\n```\n\n### XFCE\n\n[**XFCE Website**](http://www.xfce.org/)\n\n```\n; Install:\nsudo apt-get install xfce4\n\n; Remove:\nsudo apt-get remove xfce4\n```\n\n# Troubleshooting\n***\n[(Back to Top)](#table-of-contents)\n\nSometimes the system has problems, seldmoly but I'll list things that helped me fix rare occasions.\n\n### Ubuntu Infinite Login\nWhen you try to login to Ubuntu and it relogs you back into the login screen, this is an infinite loop. The only way I was able to fix it depsite all the guides was combining a few of these together for Ubuntu 16.04.\n\nIf you are using Gnome as I do, I would jump down to the **Apt Auto Remove Problem** in the list.\n\nThe first step is to login to a terminal.\n\n```\nCTRL + ALT + F1  (Or F3)\n```\n\nNext, Login as your user who must be able to run `sudo`.\n\n- **Temp Folder Permissions**\n  - `ls -ld /tmp` should have these permission exactly as: `drwxrwxrwt`\n  - The user:group must be `root:root` on `/tmp`.\n  - To Fix: `sudo chmod a+wt /tmp`\n- **Xauthority Ownership**\n  - `ls -lta | grep .Xa` should be owned by your user, for example `jesse jesse`\n   - If it is `root root` or anything than your user/group it's wrong.\n   - To Fix: `sudo chown jesse:jesse .Xauthority`\n- **Xsession Errors**\n  - This is just to make sure there are no syntax errors for your reference:\n    - To Check: `cat ~/.xsession-errors`\n    - You don't need to do anything if there are syntax errors, we will move the file.\n- **Try Moving XAuthority**\n  - Sometimes it's as easy to moving Xauthority so a new is generated at login.\n  - To Fix: `sudo ~/.Xauthority ~/.Xauthority.bkup`\n- **Try Reconfiguring LightDM**\n  - Fix: `dpkg-reconfigure lightdm`, then select lightdm in the menu\n  - Lastly restart lightdm: `sudo service lightdm restart`\n- **Apt Auto Remove Problem**\n  - I read that it's possible `apt-autoremove` may accidentally remove `xubuntu-desktop`, `ubuntu-desktop` and LightDM reports no errors.\n    - The `ubuntu-desktop` will load the Unity interface\n    - The `xubuntu-desktop` will load a different interface I'm not familiar with.\n    - To Fix: `sudo apt-get install xubuntu-desktop ubuntu-desktop`\n  - **If you are using Gnome**, try following the post at [OMGUbuntu](http://www.omgubuntu.co.uk/2016/05/install-gnome-3-20-ubuntu-16-04-lts)\n    - After the Above Try: `sudo apt-get autoremove gnome-software \u0026\u0026 sudo apt-get install gnome-software`\n    - I was able to get Gnome-Classic working but not Gnome.\n- **How to Ensure it Works**\n  - You might be able to login after one of the steps above if you don't reboot. However, to be certain, you want to reboot to ensure it is fixed, otherwise you'll be doing this over and over.\n\n# Linux Facts\n***\n[(Back to Top)](#table-of-contents)\n\n- **Linux Versions** refers to The Kernel which ties the OS together.\n- **Linux Distributions** are the named Linux \"Flavors\" below.\n  - **Debian**\n    - **Linux Mint** (LMDE) forked from Debian\n    - **Ubuntu** forked from Debian\n      - **Elementary OS** forked from Ubuntu\n      - **Linux Mint** forked from Ubuntu\n      - **Kubuntu** forked from Ubuntu\n  - **Fedora**\n    - **Red Hat Enterprise Linux** (RHEL) forked from Fedora\n      - **CentOS** forked from RHEL (Community Edition of RHEL)\n  - **Gentoo**\n- ..And many others. Debian -\u003e Ubuntu has been the most popular.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJREAM%2Fubuntu-cheatsheet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FJREAM%2Fubuntu-cheatsheet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJREAM%2Fubuntu-cheatsheet/lists"}