Ubuntu Terminal Cheatsheet
This covers a wide assortment of quick references for the terminal/command-line. Additionally, near the bottom are more items for GUI and Troubleshooting.
| Command | Description | |----------------|--------------------------------------------------------------------| | :q | exits: MAN pages, VIM | | clear | dlears the terminal | | date | current datetime | | echo | output to terminal | | echo -e | output with variables and escape characters. | | env | See environment variables | | hostname | See your hostname | | locate crontab | I like mlocate more | | man ls | manual to give you a list of all command arguments for any command | | whatis ls | tells you about the command | | whereis bash | find absolute location of bash | | which python | location of a program |
Apt (Or Aptitude) is the package manager for Ubuntu to manage packages.
There are some alternatives worth noting such as AppImage files and Snap packages, but that is out of scope here.
Tip: You can use the
-yflag in any apt command to skip the[Y/n]dialog.
You need super user permissions, or
sudobefore the command.
To install packages, let's use an example such as Ruby which should have a list of items.
@note: means press the tab key
sudo apt install rub # You should see a list of ruby installables. # If it's a long list you can type this is exit: :q
sudo apt install ruby2.3
TIP: I like to add to my
~/.bashrcfile an alias for this as follows:
alias apt=sudo apt
Update will get the latest versions of all repositories (and custom ones you add in the future) and allow you to install newer versions.
/etc/apt/sources.list.d/
apt update
This will upgrade packages that have newer versions.
apt upgrade # or, auto accept apt upgrade -y
Removing a package is just as simple.
apt remove someprogram # or, auto accept apt remove someprogram -y
However, this will not remove configuration files, so if you were to re-install it they would be preserved.
You may also run the following:
apt purge someprogram
If you get an error such as
Unable to lock the administration directory (/var/lib/dpkg/) is another process, follow these steps:
who
ps aux | grep apt(Should return one line, which has no results and just the command you typed)
rm /var/lib/apt/lists/lock
rm /var/cache/apt/archives/lock
dpkg --configure -a
nautilus.
nautilus .
filesto get to it.
keyboardor
shortcut.
Home Folderto a hotkey of your choice, I prefer SUPER + E since I came from Windows.
| Command | Description | |-------------|-------------------------------------------------| | cd .. | go down a directory | | cd / | go to lowest level | | cd /var/www | go to absolute path | | cd ~ | go to logged in user's home | | ls | list files | | ls -la | list all files, ~~permissions~~, and hidden too | | pwd | print working directory |
| Command | Description | |-------------------|----------------------------------------------| | cp -R
| Command | Description | |-------------------|---------------------------| | cat | read entire file | | head | read top of a file | | head -n 20 | read top of file 20 lines | | tail | read bottom of a file | | tail -f | stream file as it's updated, | eg: an error log | | tail -n 20 | read bottom of file 20 lines |
| Command | Description | |--------------------------------------------|---------------------------------| | passwd | change logged in users password | | su - username | switch users | | sudo su | switch to root | | useradd -m -s /bin/bash username | Create User | | usermod -a -G existinggroup existinguser | Add User to Group | | who | show all logged in users | | whoami | show which user you are |
Do not delete groups you don't know what they are used for, that's dangerous!
| Command | Description | |---------------|-----------------------------------------| | groups | see what groups current user belongs to | | groupadd name | create a group | | groupadd -g 900 name |create a group with | custom GroupID aka gid| ||| |groupdel name |delete a group| |useradd |add current user to a |group| |usermod -aG |append any user to an |additional group| ||| |cat /etc/group | list all groups| |cut -d: -f1 /etc/group | list all groups, cleaner|
There are two ways to manage permissions, one is by text the other is by an octal value.
; Change Mode ; Options: (O)wner (U)sers (G)roup or (A)ll ; File: Owner: rwx, Group: rwx, User: rwx ; Misc: Besides rwx there is: ; s = setuid of owner for old/new files; Single File read/write permissions chmod g+rw file chmod og+rw file.txt
; Change Ownership chown user:group files_or_folder chgrp group files_or_folder
; Recursively: chown -R user:group files_or_folder chgrp -R group files_or_folder chmod -R og+rw files_or_folder chmod -R g+s files_or_folder
A fantastic way to structure your users is within groups. A common example would be your
www-datagroup. If I have a user
jesse, I can add him with
sudo usermod -aG www-data jesse.
After adding any users I would like, I want to have a folder where all the members of the
www-datagroup can read/write a folder. If they are using git, I also want the permissions to stay the same, meaning if they pull the permissions will not change.
To accomplish this, here is an example:
sudo chown -R deploy:www-data /var/www sudo chmod -R g+rws /var/www
The
g+ssets the file(s)/folder(s) a gid (
setgid) so that new files will inherit the original group!
You may have seen this a lot, you can use octal or decimal (begins with a 0) to do the same thing.
Permissions: 0 = None 1 = Execute (e) 2 = Write (w) 4 = Read (r)
chmod 700 file.txtit would allow the user to Read, Write and Execute
7is the total of
4 + 2 + 1
chmod 600 file.txt – Owner Read, Write chmod 660 file.txt – Owner Read, Write; User Read, Write chmod 770 file.txt – Owner Read, Write, Execute chmod 770 file.txt – Owner Read, Write, Execute; User Read, Write, Execute chmod 666 file.txt – All Read, Write chmod 777 file.txt – All Read, Write, Execute
Get fundamental information about your OS with the following commands, you may have to run them as
sudo, eg:
sudo lsb_release -a.
lsb_release lsb_release -a lsb_release -as # Short Information lsb_release --help
nproc # How many Processing Units cpuid # Must install cpuid from terminal cat /proc/cpuinfo # Lots of info
free -h # Human readable, or do --help for options vmstat -s cat /proc/meminfo # Lots of info
df df -B MB (In Megabtyes, KB for Kilobytes, GB for Gigabytes)
top htop # If you installed it
Your 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).
ifconfig ip ip addr show ip addr show wlan ip addr show eth0
gnome-system-monitor
top htop (My favorite, sudo apt-get install htop) nmon
gsettings list-recursively org.gnome.desktop.wm.keybindings | sort | more
xev; Or for a lot of details:
xev | grep KeyPress
The Kernal is the lowest level item that ties everything together from hardware to software. Without a kernal you cannot do anything on linux.
See What version you are currently using
sudo uname -a
See all the Kernals on the OS
sudo dpkg --get-selections | grep linux
The BYOBU is quite nice
sudo apt install byobu sudo purge-old-kernels
shutdown reboot shutdown -h now shutdown -h +10 (shutdown 10 mins) shutdown -r now (reboot now)
crontab -e (edit crontab for current user) crontab -l (list crontab for other user) crontab -u jesse -l (see crontabs for specific user)
Use the service command (Requires sudo)
service ssh status (service status) service --status-all (all services status)
Almost every service has the following commands, some may have more like apache
graceful-restart:
service servicename start service servicename stop service servicename restart service servicename status service servicename force-reload
Add Service links:
sudo update-rc.d servicename defaults
Whether you get a warning if they already exist or not, enable it now:
sudo update-rc.d servicename enable
Pass the Force flag
sudo update-rc.d -f servicename remove
There is are several startup popular daemons: - CentOS uses SystemV - Ubuntu 14 uses Upstart - Ubuntu 14.10+ uses SystemD (15, 16, 17..)
Focus on SystemD.
This would only apply to Ubuntu 14.10+, otherwise you would use Upstart.
systemctlSystem State
(Back to Top) ``` uname -a (get linux info)
top (See running processes/system status, I suggest installing
htop) top -u www-data htop -u www-datadf (display disk space in bytes, default) df -h (display disk space human readable) df -Th (display disk space with partitions)
free (see memory used) free -g (in gigabytes) ```
Processes
(Back to Top) ``` ps -ef | more (current running processes) ps -efH | more (current running processes in a tree)
ps -ef | grep vim (find vim process id) kill -9 (no brackets) ```
Bash
Bash is my shell of choice, which is why I have a
.bashrcfile.Bash Paths
Executables and commands are automatically in the path, see your path with:
echo $PATHAdd to Path
# I suggest editing your ~/.profilevim ~/.profile if [ -d "/path/to/your/bin" ] ; then PATH="$PATH:/path/to/your/bin" fi
Note: Order of Linux Reading files: ~/.bashprofile, ~/.bashlogin, and ~/.profile, so don't try to use a ~/.profile variable within ~/.bash_profile
Bash Completions
The locations for bash completio0ns can be found at:
cd /usr/share/bash-completion/completions.d/ cd /etc/bash_completions.d/Fix Broken Bash Completions
sudo apt-get install --reinstall bash-completionLog Script from Bash
At the top of your file, find the executable you are using one of these, eg:
which bash # /usr/bin/bash which python # /usr/bin/python which php # /usr/bin/phpAt the top of your shebang for the executable file add:
#!/bin/bash #!/usr/bin/php #!/usr/bin/pythonmake sure to
+xit:chmod +x app.sh chmod +x app.php chmod +x app.pyYou can then run the script via Bash:
/scripts/app.sh >> /scripts/output.log 2>&1 /scripts/app.php >> /scripts/output.log 2>&1 /scripts/app.py >> /scripts/output.log 2>&1You could even crontab it the same way:
*/10 * * * * app.php >> /output.log 2>&1 */10 * * * * app.py >> /output.log 2>&1Finding Files
Generally the following arguments are as follows: -
-type ffile --type ddirectory --inamecase insensistive (book.txt would the same as BOOK.TXT) -*is a wildcard to find anything, usually you put it at the start or end of a filename.find . -name tecmint.txt find /home -name tecmint.txt find /home -iname tecmint.txt (case ignore) find / -type d -name Tecmint (directory) find . -type f -perm 0777 -print (with perms) find / -type f ! -perm 777 (find without) find . -type f -name "tecmint.txt" -exec rm -f {} \; (find and remove a file) find . -type f -name "*.txt" -exec rm -f {} \; (find and remove multiple) find /tmp -type f -empty (Find empty files) find /tmp -type d -empty (find empty directories) find / -size +50M -size -100M (findby swize)Find in Files (GREP)
GREP means: Global Regular Expression Pattern (or Parser)
Some common GREP flags: -
-ris Recursive --nis Line Number --wMatch the whole word --lis lowercase only --csupresses normal output and counts number of matching linesgrep -rn /path - "pattern_or_string"; Output results to File grep -rnw /path - "pattern_or_string" > output.txt
Look only in certain filetypes
; notice I used a regex ^ starts with, you can use a string or regex grep --include=*.sh '^mysql' ./More Examples:
grep "hello" file.txt (if in file) grep "hello" files* (if in many files) grep -i "hello" file.txt (case insesitive) grep -iw "is" file.txt (get full words, case insensitive) grep "regex" file.txtPipe Grep
php -i | grep iniReading Files
Without having to open a file you can simply read a part of it without
nano,pico,vi, orvim:cat file.txt (view file contents) tail file.txt (view end of file contents) tail -n20 file.txt (view top 20 lines) tail -f filetxt (follow a filename keep updating) head file.txt (view top of file contents) head -n20 file.txt (view top 20 lines)`Downloading Files
Using Wget
wget http://file.com/something.txt (Download a file locally) wget -O newname.txt http://file.com/something.txt (Download file locally w/new name)You can also use
SCP, yet the above are easier for non-SSH connections.Using cURL
curl -O http://file.com/something.txt (Download a file locally) curl -o newname.txt http://file.com/something.txt (Download file locally w/new name) curl -O http://url_1 -O http://url_2 (Download multiple files)Compressing and Uncompressing Files
To Compress a file you can use a variety of tools. You can type
man gzipto see the full manual and line of commands, and useesc+:xandENTERto exit from the Manual (It usually uses the Vi editor).Most often in the Linux word you use and create
*.tar.gzfiles, it has the most options. Whatever you prefer is up to you.What the flags often stand for: -
-cis create --fis file --kis for Keep -gzip&bzip2will remove the original file once compressed - Or they will remove the.gzwhen decompressing is done --ris recursive (for gzip and zip) --vis verbose (show details of what's happening) --zis for tar to gzip as well ---exclude='file'is for tar (+gz if needed) to exclude certain files)Compressing Files
Note: You can compress more than one file at a time eg:
bzip2 file1.txt file2.txt file3.txtgzip -vk file.txt (Creates file.txt.gz) bzip2 file.txt (Creates file.txt.bz2) tar -cvf file.tar file.txt (Creates tar) tar -czvf file.tar.gz file.txt (Creates tar.gz) zip filename.zip file.txt (Creates filename.zip) zip -r folder.zip path/to/folder (Creates folder.txt.bz2)Include/Exclude a few files: ``` ; Exclude certain files tar -czvf file.tar.gz / --exclude='*.jpg' --exclude='bigfile.sql'
; Include one file type tar -czvf file.tar.gz /*.sh
; Include multiple files types tar -czvf file.tar.gz
find | grep '.sh\|.py'```Decompressing Files
To Uncompress we use similar commands for most of them
gunzip -dvk file.txt.gz gzip -dvk file.txt.gz (Same as above) bzip2 -d file.txt.bz2 tar -xvf file.tar tar -zxvf file.tar.gz unzip test.zipSCP
Download from server to local
scp [email protected]:/path/to/file.txt file.txtUpload from local to server
scp file.txt [email protected]:/path/to/file.txtSSH
Connecting to a server
ssh [email protected] (default port is 22) ssh [email protected] -p 8000 (connect to specific port) ssh [email protected] -i ~/.ssh/rsa_key.pub (connect with ssh key).SSH Permissions
These are safe permissions to use for SSH ``` chmod 700 ~/.ssh chmod 644 ~/.ssh/idrsa.pub chmod 600 ~/.ssh/idrsa
Put your pubkeys (one per line) for SSH login
chmod 600 ~/.ssh/authorized_keys ```
Using the Config
You can also create a
~/.ssh/configfile and store entries such as: ``` Host aws Hostname ec2-50-50-130-50.compute-1.amazonaws.com Port 22 Identityfile ~/.ssh/id_rsa User myusernameHost my-vps Hostname 50.50.130.50 Port 22 User root ```
You can then simply type:
ssh aws ssh my-vpsSSH to PEM
Sometimes you may need a
PEMformat SSH Key. You can easily add this alongside your other SSH keys.openssl rsa -in ~/.ssh/keyname_rsa -outform pem > keyname_rsa.pem chmod 700 keyname_rsa.pemFirewall
A firewall prevents unauthorized access to your machine, you should use
UFW(Uncomplicated Firewall). You must always run this withsudo. If you don't have UFW installed, run:sudo apt-get install ufwUFW Status
To see the Firewall Status run one of these:
sudo ufw status sudo ufw status verboseUFW Enable/Disable
sudo ufw enable sudo ufw disableUFW Example Customization
Please do not do this unless you know what you are doing.
You could start out with blocking all incoming connections.
sudo ufw default deny incoming sudo ufw default allow outgoingThen we allow only what we want
sudo ufw allow ssh sudo ufw allow http sudo ufw allow https sudo ufw allow ftpThese are the same as:
sudo ufw allow 22 # same as ssh sudo ufw allow 80 # same as http sudo ufw allow 443 # same as httpsUFW More Options
If SSH was on port
3333rather than the default22you would do:sudo ufw allow 3333/tcpSome more options:
sudo ufw allow 25 # SMTP sudo ufw allow 110 # POP3 sudo ufw allow 995 # POP3S sudo ufw allow 143 # IMAP sudo ufw allow 993 # IMAPS sudo ufw allow 3306 # MySQL sudo ufw allow 5432 # Postgres sudo ufw allow from 192.168.255.255 # Custom IP AddressUFW Deleting Rules
Easily delete named rules
sudo ufw delete allow sshDelete rules that are numbered
sudo ufw status numbered sudo ufw delete [number]UFW Reset Rules
sudo ufw resetRegex
Regex stands for Regular Expression. It's used for locating or replacing files or strings of text. It is used all the time. These can be used in Linux itself and programming languages.
; Symbolism ; ------------------ () (captures groups) [] (set) {} (quantifier) ? (optional, matches 0 or 1 character) * (matches 0 or more characters) . (match any character) + (match one or more character) \ (escape character) ! (false, is not) ^ (starts with) $ (ends with) | (or statement, eg: (jesse|dan|jenkins) ); Basic Primer ; ------------------ \w (word) \W (non-word) \s (whitespace) \S (non-whitespace) \d (digit) \D (non-digit) [ab] (character set) [^ab] (negated set) [a-m] (range) (hello) (group) (hello)+ (group, more than once)
; Groups ; ------------------ (hi) (gets all "hi" occurances) (^hi) (gets all text starting with "hi") (es$) (gets all text ending with "es") (hi)\1 (gets the first occurance of "hi")
; Flags ; ------------------ /i (case insensitive) /g (global) /m (multiline)
; Escaped Characters ; ------------------ ; Since characters such as ".", "+", etc are actual Regex pattern makers, if you ; need to check your content for the literal item you must escape them. . (matches . character) + (matches + character) ? (matches ? character) * (matches * character) ^ (matches ^ character) $ (matches $ character) [ (matches [ character) ( (matches ( character)
\t (matches tab character) \n (matches newline) \r (matches return carriage) \0 (matches NULL character) \ (matches \ character) / (matches / character)
Regex Examples
Put Examples here, like phones, names, etc..MySQL
-uis for User (default: root)
-pis for Password
-p passwordis for password which skips the prompt (not recommended)
-his for host (default: localhost)
-port or -Pis for a port, default is 3306
-fwill force SQL import and skips errors
-vwill display verbose output
mysql>terminal you can get clean data by doing
\g:
mysql> SELECT * FROM users LIMIT 10\g";
mysql -u root -p (username, password prompt) mysql -u root -p -h localhost (username, password prompt, host) mysql -u root -p password -h localhost -P 3306; AWS Example (AWS Defaults to 3306 as most MySQL connections do) mysql -u username -p password -h myinstance.123456789012.us-east-1.rds.amazonaws.com
You can dump a single database easily:
mysqldump -u root -p DATABASE_NAME > file.sql
Or Dump all databases on your MySQL server with the
--all-databasesflag:
mysqldump -u root -p --all-databases > file.sql
You can do this through the shell only, or MySQL, first is the shell:
mysql -u root DATABASE_NAME < path/to/file.sql
To continue when there are MySQL Errors use -f or --force below:
mysql -u root DATABASE_NAME < path/to/file.sql --force
To use a password, just pass in the -p flag and type it in after running:
mysql -u root -p DATABASE_NAME < path/to/file.sql --force
Second, you can do it through MySQL once you connect:
mysql> use DATABASE_NAME; mysql> source path/to/file.sql;
This will save a lot of space in this one liner:
mysqldump -u root -p DATABASE_NAME | tar -cvzf > output.sql.tar.gz mysqldump -u root -p DATABASE_NAME | gzip -v > output.sql.gz
Here is how you can import with the one liner:
mysql -u root -p DATABASE_NAME | tar -xzOf output.sql.tar.gz mysql -u root -p DATABASE_NAME | gunzip < output.sql.gz
USE DATABASE_NAME; SELECT @@collation_database;
SELECT default_character_set_name FROM information_schema.SCHEMATA WHERE schema_name = "TABLE_NAME";
Look at the collation table. Numeric fields won't have a collation.
SHOW FULL COLUMNS FROM TABLE_NAME
First, try this query without affecting anything to see:
SELECT CONVERT(BINARY CONVERT('We’re Here!' using latin1) using utf8);That should fix the encoding problem.
To update a column:
UPDATE TABLE_NAME SET COLUMN_NAME = CONVERT(BINARY CONVERT(COLUMN_NAME using latin1) USING utf8);
You have to first create a repostory, through BitBucket, GitHub, GitLab, etc.
git init touch README.md git remote add origin [email protected]/username/yourrepo.git git add . git commit -m "Starting with one file" git push origin master
git add file.txt git rm file.txt
Create a
.gitignorefile, and place something like this in it:
.tmp .py[co] .cache .DS_Store
Branches are used like when you don't want to ruin a main branch with working code.
git checkout -b develop git push origin develop
git checkout master git checkout develop
If you were on your
masterbranch and only wanted to pull a single file from
developbranch, you can do this: ``` ; Make sure you're on the branch you want to pull into git checkout master
; Pull a single file into master from develop git checkout develop -- relative/path.txt
; Continue by comitting and pushing to master ```
Tags create a snapshots of current code, you may name it as a version such as
1.0.1and it produces a
tar.gzand
zipformat for downloads.
git tag -a 1.0 git tag -a 1.0 -m "Optional Message" git push --tags
This will remove a tag from the Git host.
git tag -d 1.0 git push origin :refs/tags/1.0
git clone [email protected]/username:your_repo.git
Clone into current directory
git clone [email protected]/username:your_repo.git .
git status
To see log data and more details use the short or long commit ID.
git log git show eb7c86a5fbdc6c64df608f4c143c2718a100983b
This will reset your repository to the last revision and undo everything, use with caution.
git reset --hard HEAD
Removes cached items no longer read by git
git prune
To install visit https://docs.docker.com/engine/installation/linux/ubuntulinux/ - Images: (Blueprints of an application) - Image BASE: No parent Image (An OS) - Image CHILD: Builds on a Base Image (Eg: Webserver, MySQL) - Containers: Created from an IMAGE and run an application. - Docker Daemon: Background service that builds, runs, and does everything. - Docker Client: Allows us to interact with the Docker Daemon. - Docker Hub: A registry of images (Like: npmjs, pip, packagist, bower)
This is a great utility that makes managing docker easier from a
docker-compose.ymlfile, you should install this after playing around with the below options. See: https://docs.docker.com/engine/installation/linux/ubuntulinux/
docker-compose up open http://localhost:3000
This is a sample box to test once you installed docker
dock pull busybox docker images docker run busybox "Hi from the box"
docker ps (running containers) docker ps -a (see all containers that ran)
This allows you to get inside the container
docker run -it busybox sh (interactive)
Removes a CONTAINER, not an IMAGE
docker ps -a docker rm
You can remove containers based on their status in bulk, eg:
docker rm $(docker ps -a -q -f status=exited) docker rm $(docker ps -a -q -f status=created)
This will download the IMAGE and run it if it doesn't exist
docker run prakhar1989/static-site
This doesn't expose ports for us to use, so we do the following:
docker run -d -P --name static-site prakhar1989/static-site
-ddetaches terminal so we can run commands in our terminal
-Ppublishes all exposed ports to random ports
By doing the above command we are given random ports, eg:
443/tcp -> 0.0.0.0:32768 80/tcp -> 0.0.0.0:32769
Your ports may be different, you can use specific ports with a lowercase
-p:
docker run -p 8888:80 prakhar1989/static-site
docker stop static-site
This would be a docker BASE IMAGE
docker pull ubuntu:14.04
This is a flask Example using a Python-3 Base IMAGE
requirements.txtand just put
flask
app.py
app.py:
from flask import Flask app = Flask(__name__)@app.route('/') def hello_world(): return 'Hello, World!'
Dockerfile
FROM python:3-onbuild EXPOSE 5000 CMD ["python", "./app.py"]
Now build the image
docker build -t boyus . docker images
Get a list of images, then just delete by image id with
rmiaka
remove image:
docker images docker rmi![]()
You need a repository at docker.io to push this, or probably some private hosting.
docker push boyus
Linux 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.
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.
--
Installed in Ubuntu 12+ by Default (`ubuntu-desktop`)
; Install: sudo apt-get install xubuntu-desktop; Remove: sudo apt-get remove xubuntu-desktop
; Install: sudo add-apt-repository ppa:moorkai/cinnamon sudo apt-get update && sudo apt-get install cinnamon; Remove sudo ppa-purge ppa:moorkai/cinnamon
This has been one of the all time most popular GUI's for Linux ever made, in particular the
gnome-classic.
; Install: sudo apt-get install ubuntu-gnome-desktop (For legacy gnome use you can use gnome-shell, this install both); Remove: sudo apt-get remove ubuntu-gnome-desktop (Removes gnome-shell as well)
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.
Noteworthy: Visit Gnome Shell Extensions to customize anything you want. Make sure to use Firefox.
This is a very popular GUI for people that are used to Windows Desktops.
; Install: sudo add-apt-repository ppa:kubuntu-ppa/backports sudo apt-get update && sudo apt-get dist-upgrade sudo apt-get install kubuntu-desktop; Remove: sudo apt-get remove kubuntu-desktop
; Install: sudo apt-get install lxqt ; Remove: sudo apt-get remove lxqt
For the best stability I use Elementary OS which is based off of Ubuntu.
; Install: sudo add-apt-repository ppa:elementary-os/stable sudo apt-get update sudo apt-get install elementary-desktop; Remove: sudo apt-get remove elementary-desktop
; Install: sudo apt-get install xfce4; Remove: sudo apt-get remove xfce4
Sometimes the system has problems, seldmoly but I'll list things that helped me fix rare occasions.
When 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.
If you are using Gnome as I do, I would jump down to the Apt Auto Remove Problem in the list.
The first step is to login to a terminal.
CTRL + ALT + F1 (Or F3)
Next, Login as your user who must be able to run
sudo.
ls -ld /tmpshould have these permission exactly as:
drwxrwxrwt
root:rooton
/tmp.
sudo chmod a+wt /tmp
ls -lta | grep .Xashould be owned by your user, for example
jesse jesse
root rootor anything than your user/group it's wrong.
sudo chown jesse:jesse .Xauthority
cat ~/.xsession-errors
sudo ~/.Xauthority ~/.Xauthority.bkup
dpkg-reconfigure lightdm, then select lightdm in the menu
sudo service lightdm restart
apt-autoremovemay accidentally remove
xubuntu-desktop,
ubuntu-desktopand LightDM reports no errors.
ubuntu-desktopwill load the Unity interface
xubuntu-desktopwill load a different interface I'm not familiar with.
sudo apt-get install xubuntu-desktop ubuntu-desktop
sudo apt-get autoremove gnome-software && sudo apt-get install gnome-software