How To Install and Get Started With Ubuntu Desktop 18.04 LTS
How To Install and Get Started With Ubuntu Desktop 18.04 LTS
| HOME
TABLE OF CONTENTS (HIDE)
1. Introduction
2. Installing Ubuntu Desktop for Programmers/Developers
2.1 Ubuntu "Desktop" vs. Ubuntu "Server"
2.2 Installing Ubuntu Desktop alongside an Operating System
2.3 Post Installation - Updating Software
2.4 Errors that I have encountered
3. Getting Started with Ubuntu
3.1 "Unity" Desktop
3.2 Using Terminal - MUST READ Before You Start Programming
3.3 Applications and Utilities
4. APT for Managing Software
4.1 APT Tools
4.2 apt vs. apt-get/apt-cache
4.3 Upgrading (Maintaining) System
4.4 Installing/Removing Packages
4.5 APT Configuration Files
4.6 Checking the Status of the Installed Packages
5. How to Install JDK on Ubuntu
6. How to Install Eclipse on Ubuntu
7. How to Install NetBeans on Ubuntu
8. How to Install LAMP (Linux-Apache-MySQL-PHP) Server on Ubuntu
8.1 How to Install Apache 2.4 on Ubuntu 20.04LTS
8.2 (Advanced) Working with the UFW Firewall
8.3 (Advanced) How to Setup HTTPS for Apache 2.4 on Ubuntu 16.04LTS
8.4 How to Install MySQL 5.7 on Ubuntu 16.04LTS
8.5 How to install PHP 7 on Ubuntu 16.04LTS
8.6 How to install PhpMyAdmin
8.7 IDE for PHP Program Development
8.8 How to install xDebug PHP Extension
8.9 How to install Zend Debugger for PHP
8.10 How to install Firebug plugin for Firefox for debugging Client-side HTML/CSS/JavaScript
9. How to Install Tomcat 7/8 on Ubuntu
9.1 Install via APT
9.2 Install Manually
10. How to Install Postfix as a Send-Only Mail Server
11. How to Install SSH Server
12. C/C++ Programming on Ubuntu
13. Ubuntu's Tips and Tweaks
13.1 Terminal
13.2 User Administration
13.3 System Administration
13.4 "Nautilus" File Manager
13.5 gedit
13.6 Accessing Remote Server
13.7 Ubuntu Applications
13.8 Miscellaneous
Ubuntu runs the GNOME desktop manager. It includes the OpenOffice suite, Firefox Web browser,
Mozilla Thunderbird, Pidgin IM client, and a collection of tools and games. It uses Advanced Packaging
Tool (APT) - Debian's high-level package management system - for managing the software on the
system.
The first Ubuntu version was released in October 2004. Since then, there are two releases per year, in
April (YY-04) and October (YY-10), e.g., 14.04, 14.10. Some version are marked as LTS (Long Term
Support), which will be supported over the next 5 years, e.g., 14.04 LTS. LTS is recommended.
Ubuntu has many flavors: Ubuntu Desktop, Ubuntu Server, Ubuntu Cloud, Ubuntu Netbook, Ubuntu
Core, Kubuntu, EdUbuntu, Xubuntu, and others.
The following procedure was tested on Windows 10 with Ubuntu Desktop 20.04 LTS in May 2020.
1. Assume that you have an operational Windows OS.
2. BACKUP!!!
3. Download the latest Ubuntu Desktop LTS (Long Term Support)
from https://www.ubuntu.com/download/desktop (e.g., ubuntu-20.04-desktop-
amd64.iso 2.5GB).
4. Read the latest installation guides available in the same download page.
5. Create a bootable USB stick (BIOS/UEFI compatible) using Rufus (a free and open source
USB stick writing tool):
a. Download the latest Rufus from https://rufus.ie/ (rufus-3.10.exe).
b. Insert a free USB stick (at least 4GB) ⇒ Run Rufus
a. Under "Drive Properties":
a. In "Device" ⇒ Select the USB stick
b. In "Boot Selection" ⇒ choose "FreeDOS" for
bootable
c. In "Partition Scheme" ⇒ MBR (default)
d. In "Target System" ⇒ BIOS (or UEFI-CSM)
(default)
b. Under "Format Options":
a. In "Volume Label": enter "Ubuntu 20_04 LTS"
b. In "File System" ⇒ FAT32 (default)
c. In "Cluster size" ⇒ 4096 bytes (default)
c. Click on the word "SELECT" and select the Ubuntu disk image
downloaded in the previous step (e.g., ubuntu-20.04-
desktop-amd64.iso).
d. Push "Start" button.
6. Free disk space to install Ubuntu:
a. Right-click Start button ⇒ Command Prompt (Admin) to start the CMD
shell ⇒ Enter "diskmgmt.msc" to run the Disk Management utility.
b. Select a drive with free space (e.g., C:) ⇒ Right-click ⇒ Shrink Volume ⇒
Enter the amount to shrink (at least 20GB or 20000MB, more if you can
afford e.g., 64GB or 65536MB) ⇒ Shrink ⇒ Reboot
7. Disable Windows "Fast Boot": Control Panel ⇒ System and Security ⇒ Power Options ⇒
Choose "what the power buttons do" ⇒ Change settings that are currently unavailable
⇒ Uncheck "Turn on fast startup" ⇒ Save changes ⇒ Restart
8. Change the boot order in your BIOS/UEFI setup to enable booting from USB: Power-On
⇒ Hit a hotkey to enter BIOS/UEFI Setup (ESC, F12, F10 or F2 depending on your
computer) ⇒ Look for "Boot order" and check/change the settings.
9. Now you are ready to install Ubuntu from the bootable USB stick. Read "Install Ubuntu"
@ https://www.ubuntu.com/download/desktop/install-ubuntu-desktop.
10. Boot from the Bootable USB stick:
a. In Boot menu ⇒ Using "tab" key to choose "Install Ubuntu"
b. In "Keyboard Layout" ⇒ Choose your preferences.
c. In "Wireless" ⇒ Connect to your wifi network.
d. In "Updates and other software" ⇒ Use the defaults
e. In "Installation Type" ⇒ choose "Something else" (so that you can
customize your disk partition for Ubuntu).
f. I installed Ubuntu in one single partition (without the swap partition as I
have 16GB of RAM, also without a separate "home" partition).
Select "free space" ⇒ Hit "+" button.
In "Create Partition" menu, Set:
a. Size = all free space (default)
b. Type for the new partition = Primary (default)
c. Location for the new partition = Beginning (default)
d. Use as = EXT4 journaling file system (default)
e. Mount point = choose "/" (for root)
Push "Install Now" button.
g. Choose your region.
h. Pick up a username and password for your administrator (superuser or
sudo) account.
a. Your name = same as username (lowercase letters, digits,
without space or special characters; root is already used)
b. Your computer name = your chosen computer name (e.g.,
myUbuntu)
i. Remove USB stick and reboot.
[SeatDefaults]
allow-guest=false
sudo update-grub
sudo grub-install /dev/[Windows Boot partition e.g., sda1]
The first command could fix the problem. The second command is used to manually add Windows
partition into the GRUB boot menu.
How to disable default OS in GRUB boot menu
GRUB maintains its configuration in /etc/default/grub.
The default "printing location" is at ~/PDF. You can configure the printer setting via "System Setting"
⇒ Printers.
APT can properly handle the dependencies. It automatically finds and downloads all the dependencies
of the packages to be installed. It can also resume installation after an interruption.
// Syntax:
$ sudo apt install --reinstall <package>
// or
// $ sudo apt-get install --reinstall <package>
$ sudo apt purge <package> // Also purge the configuration files in "/etc"
$ sudo apt remove --purge <package> // Same as above
// or
// $ sudo apt-get purge <package>
$ which apache2
/usr/sbin/apache2
$ whereis apache2
apache2: /usr/sbin/apache2 /etc/apache2 /usr/lib/apache2 /usr/share/apache2
/usr/share/man/man8/apache2.8.gz
$ man apache2
......
As shown in the above output, the Apache 2 server program "apache2" (called "httpd" in Apache 1) is
installed in /usr/sbin (System Software Binaries).
Step 3: Configure Apache 2.4
Apache 2.4 keeps its configuration files in /etc/apache2 directory, which includes:
• apache2.conf: The main configuration file, which includes ports.conf, mods-
enabled/*.load, mods-enabled/*.conf, conf-enabled/*.conf, and sites-
enabled/*.conf.
• ports.conf: Defines the server's listening TCP port numbers. The default configuration
defines port 80 for HTTP and port 443 for HTTPS.
• sites-available/*.conf and sites-enabled/*.conf: for managing application web
sites. All *.conf in sites-enabled are included in apache2.conf.
To create a new site, you should create a configuration in sites-available; and use
helper utility a2ensite to make a symlink to the sites-enabled (instead of duplicating
the file). Similarly, use helper utility a2dissite to remove a site from sites-
enabled (which removes the symlink).
The "000-default.conf" provided (called "default.conf" in Apache 2.2), which is
enabled by default, defines a virtual host:
o Listening at port 80 (enabled in "port.conf").
o DocumentRoot at "/var/www/html" (or "/var/www" in Apache 2.2).
• mods-available/*.load|*.conf and mods-enabled/*.load|*.conf: for manage
modules. Use helper utilities a2enmod or a2dismod to enable or disable a module via
symlinking.
• conf-available/*.conf and conf-enabled/*.conf: for additional configuration (such
as phpMyAdmin). Use helper utilities a2enconf or a2disconf to enable or disable a
configuration via symlinking.
• envvars: defines the environment variables used by Apache 2, such as
o APACHE_RUN_USER: www-data
o APACHE_RUN_GROUP: www-data
o APACHE_RUN_DIR: /var/run/apache2
o APACHE_LOG_DIR: /var/log/apache2
A special user www-data is used to run the apache server. This user www-data should have
"r" permission to all the files in the public www directory and "rx" permission to its
subdirectories. It should also have "rx" permission to all the parent-directories leading to
the public www directory.
• magic: defines the MIME types.
Step 4: Start/Shutdown Apache Server
Apache is installed as a service called "apache2" (configured at "/etc/init.d/apache2"). The Apache
server is started automatically after the installation.
$ man apache2ctl
If your firewall is active, it must allow HTTP and HTTPS to run a server. You can check your UFW Firewall
application profiles via:
To Action From
-- ------ ----
Apache Full ALLOW Anywhere
Apache Full (v6) ALLOW Anywhere (v6)
DocumentRoot /var/www/html
SSLEngine on
SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
• If you want to create a certificate with different host name, you can use:
// Check
$ ll /etc/apache2/sites-enabled
......
lrwxrwxrwx 1 root root 35 Jan 18 00:39 default-ssl.conf -> ../sites-available/default-
ssl.conf
Step 4 : You can access the site with a web browser via https://localhost.
Warning Message "[warn] RSA server certificate CommonName (CN) ... does
NOT match server name!?"
In the config file, add a ServerName directive right below the ServerAdmin under <VirtualHost>:
ServerName your-hostname-or-IPaddr
// Set the certificate (no key file needed if you use make-ssl-cert)
SSLCertificateFile /etc/ssl/private/my-apache-ssl.crt
# SSLCertificateKeyFile /etc/ssl/private/apache.key
If you are not using the default HTTPS port of 443, you need to add the port number to
"/etc/apache2/ports.conf" and access the SSL site via https://localhost:port.
8.4 How to Install MySQL 5.7 on Ubuntu 16.04LTS
Step 1: Install MySQL
Open a new Terminal and issue this command:
[mysqld]
user = mysql
port = 3306
basedir = /usr
datadir = /var/lib/mysql
......
log_error = /var/log/mysql/error.log
......
$ mysql -u root -p
// Enter the password for the root user you have set in Step 1
mysql> exit
MORE on MySQL
READ "MySQL" section.
(For Java Programmers) Install MySQL JDBC Driver
1. Download the latest JDBC driver from http://www.mysql.com/downloads ⇒ MySQL
Connectors ⇒ Connector/J ⇒ Compressed TAR archive (e.g., mysql-connector-java-
{5.x.xx}.tar.gz, where {5.x.xx} is the latest release number).
2. Double-click on the downloaded TAR file (at ~/Downloads) to expand into folder
"mysql-connector-java-{5.x.xx}".
3. Open the expanded folder. Copy the JAR file "mysql-connector-java-{5.x.xx}-
bin.jar" to JDK's extension directory at
"/usr/local/java/jdk1.8.0_{xx}/jre/lib/ext ".
4. $ cd /usr/local/java/jdk1.8.0_{xx}/jre/lib/ext
$ sudo cp ~/Downloads/mysql-connector-java-{5.x.xx}/mysql-connector-java-
{5.x.xx}-bin.jar .
[TODO] more
// Say hello
$ php -r 'echo "Hello, world!\n";'
Hello, world!
// Run phpinfo()
$ php -r 'phpinfo();'
......
The PHP configuration files are "/etc/php/7.0/apache2/php.ini" for the Apache interface; and
"/etc/php/7.0/cli/php.ini" for standalone command-line interface.
Write a PHP script called "test.php" (place under Apache's base at "var/www/html") to
run phpinfo() under Apache, as below.
<?php
phpinfo();
?>
Run the script via http://localhost/test.php. The output shows that the loaded configuration files are
"/etc/php/7.0/apache2/php.ini" and "/etc/php/7.0/apache2/conf.d/*.ini ". The "conf.d"
contains links to "/etc/php/7.0/mods-available".
The Apache loads the PHP module via "/etc/apache2/apache2.conf" ⇒ "/etc/apache2/mods-
enabled/php7.0.conf|php7.0.load" ⇒ "/etc/apache2/mods-
available/php7.0.conf|php7.0.load".
8.6 How to install PhpMyAdmin
"PhpMyAdmin" is a PHP app running under Apache, which provides an GUI for managing MySQL.
Run apt install to install phpmyadmin:
$ sudo apt install phpmyadmin
......
The following NEW packages will be installed:
dbconfig-common dbconfig-mysql javascript-common libjs-jquery
libjs-sphinxdoc libjs-underscore php-gd php-gettext php-mbstring php-pear
php-phpseclib php-tcpdf php-xml php7.0-gd php7.0-mbstring php7.0-xml
phpmyadmin
......
Select 'apache2' in 'Server Selection'
Select 'yes' to use dbconfig.common to setup the database
Choose a password for MySQL user 'phpmyadmin'
$ whereis phpmyadmin
phpmyadmin: /etc/phpmyadmin /usr/share/phpmyadmin
You can access PhpMyAdmin via http://localhost/phpmyadmin .
PHP's configuration file for Apache is "/etc/phpmyadmin/apache.conf", which is included into
Apache's main config file "/etc/apache2/apache2.conf" thru "/etc/apache2/conf-
enabled/phpmyadmin.conf". In the configuration, an alias "/phpmyadmin" is defined which is mapped
to phpMyAdmin's web pages at "/usr/share/phpmyadmin".
NOTE: If you did not select apache2 during the installation, make a symlink
called phpmyadmin.conf in /etc/apache2/conf-available to /etc/phpmyadmin/apache.conf ; and
use a2enconf to enable the configuration.
$ cd /etc/apache2/conf-available
$ sudo ln -s /etc/phpmyadmin/apache.conf phpmyadmin.conf
$ sudo a2enconf phpmyadmin.conf
$ sudo service apache2 restart
/usr/share/doc/php-xdebug/copyright
19. Check the location of "xdebug.so" module, which is kept under
"/usr/lib/php/20151012", where the number depends on the PHP version.
20. The installation creates a configuration file "/etc/php/7.0/mods-
available/xdebug.ini" with the following line (otherwise, create one):
zend_extension=xdebug.so
NOTE: in the previous version, you need to specify the full-path filename, e.g.,
"zend_extension=/usr/lib/php/20151012/xdebug.so ".
Include the following lines into "xdebug.ini" to enable remote debugging from Eclipse
PDT:
xdebug.remote_enable = On
xdebug.remote_port = 9000
xdebug.remote_host = 127.0.0.1
Recall that Apache loads PHP configuration files "/etc/php/7.0/apache2/php.ini " and
"/etc/php/7.0/apache2/conf.d/*.ini". To enable the above xdebug configuration
file, create the following symlink in "/etc/php/7.0/apache2/conf.d " (already created
for the latest version - check first):
$ cd /etc/php/7.0/apache2/conf.d
$ sudo ln -s ../../mods-available/xdebug.ini 20-xdebug.ini
$ ls -l
lrwxrwxrwx 1 root root 31 Sep 11 19:42 20-xdebug.ini -> ../../mods-
available/xdebug.ini
21. Check PHP configuration file "/etc/php/7.0/apache2/php.ini" for the following
settings:
22. ; Turn on the error display for development system,
23. ; but not for production system.
24. display_errors = On
25.
26. ; Format error in HTML
html_errors = On
27. Restart the Apache2:
30. <?php
31. phpinfo();
?>
Issue http://localhost/test.php , and search for xdebug (as shown below) to confirm
You can use either xdebug or Zend Debugger, but not both?!
NOTE: I have problems setting up Zend Debugger. I suggest you use xDebug (descried in the previous
section).
1. Download the Zend PHP debugger
from http://www.zend.com/en/products/studio/downloads.
2. Extract the tarball.
3. Check your PHP version via "php --version".
4. Copy the "ZendDebugger.so" module from the corresponding PHP version folder
into /usr/lib/php5. At the time of writing, PHP 5.4 is not supported!!!
5. Edit the php configuration file /etc/php5/apache2/php.ini to append the below:
6. ; The section name is optional, but it's always a good idea to add it,
7. ; especially if you are not using a separate file
8. [Zend]
9.
10. ; This directive needs the full path to the Zend Debugger binary
11. zend_extension =/usr/lib/php5/ZendDebugger.so
12.
13. ; This directive allows Zend Debugger to start a debug session with:
14. zend_debugger.allow_hosts=127.0.0.1/32
15.
16. ; This directive allows Zend Debugger to expose itself
17. ; upon request (this is used in some service functionality).
18. ; The possible options are:
19. ; never – do not expose (default)
20. ; always – expose to whoever wants to know
21. ; allowed_hosts – expose only if the request comes from an IP listed above
zend_debugger.expose_remotely=always
To start/stop tomcat:
$ source /etc/profile
// To verify:
$ echo $JAVA_HOME
[/usr/local/java/jdk1.8.0_{xx}]
$ cd /usr/local/tomcat/apache-tomcat-8.0.{xx}/bin
// All the following commands can be used to start tomcat
$ ./startup.sh
$ ./catalina.sh run
$ ./catalina.sh start
// use "sudo" if permissions denied
If you will get an error "permission denied" on running the script, you need to set the script to be
executable, via command "chmod uga+x *.sh".
Check for the Tomcat server's TCP port number from the console messages. The default is 8080.
To verify if the Tomcat server is started, start a browser and issue URL http://localhost:8080,
suppose that Tomcat is running on the default TCP port number of 8080.
Also try URL http://localhost:8080/examples which shows the Servlet/JSP examples.
To shutdown the Tomcat server, you can simply press control-c on the tomcat console, or issue
command:
$ cd /usr/local/tomcat/apache-tomcat-8.0.{xx}/bin
// All the following commands can be used to shutdown tomcat
$ ./shutdown.sh
$ ./catalina.sh stop
// To start
$ sudo service tomcat8 start
$ sudo /etc/init.d/tomcat8 start // same as above
// To stop
$ sudo service tomcat8 stop
$ sudo /etc/init.d/tomcat8 stop // same as above
Postfix is an MTA (Mail Transfer Agent), an application used to send and receive email.
$ sendmail -v [email protected]
Subject: test
This is a test message
Ctrl-D
inet_interfaces = loopback-only
$ gcc --version
gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
#include <stdio.h>
int main() {
printf("Hello world from C!\n");
}
$ cd <your-c-directory>
// Compile the program
$ gcc Hello.c
// To run the program
$ ./a.out
Hello, world!
C++ Programming
Check if GNU C++ compiler "g++" is installed:
$ g++ --version
g++ (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
#include <iostream>
using namespace std;
int main() {
cout << "Hello world from C++!" << endl;
}
$ cd your-directory
// Compile the program
$ g++ Hello.cpp
// To run the program
$ ./a.out
Hello, world!
C/C++ IDE
You could use Eclipse or NetBeans as C/C++ IDE. Read the "Eclipse How-To" or "NetBean How-To".
stty intr ^J
2. How to Change the Display Name : The display name is kept in /etc/passwd.
You can avoid editing /etc/passwd directly by using utility chfn:
3. $ less /etc/passwd
4. ......
5. // Change user information
6. $ sudo chfn <username>
7. $ less /etc/passwd
......
Note: You can check the integrity of /etc/passwd via utility pwck.
8. How to change a username :
$ sudo usermod -l <new-username> <old-username>
This does not affect the file ownerships, as they are based on UID instead of username.
You also need to move the home folder as follows:
$ sudo usermod -d /home/<new-user-dir> -m <new-username>
10. $ last
11. // from /var/log/wtmp
12. $ last -f /var/log/wtmp.1
13. // from older file
14. $ last -num
// number of lines
Or, via Webmin ⇒ Users and Groups ⇒ Button "Display Logins by".
13.3 System Administration
1. How to change the hostname : Your hostname is defined in two
files: /etc/hostname and /etc/hosts.
2. $ sudo gedit /etc/hostname
$ sudo reboot
Or, via Webmin ⇒ System ⇒ Bootup and Shutdown ⇒ Button "Reboot System", or
"Shutdown System".
15. How to set the Grub dual-boot to wait for enter key
GRUB_TIMEOUT=-1
18. Multiple Display: The display configurations are saved in ~/.config/monitor.xml. You
can remove it to re-configure.
19. Show date/time: via command "date".
20. Ubuntu Software Updater vs apt: [TODO]
13.4 "Nautilus" File Manager
1. Show directory path in File Manager : Press Ctrl-l to show path, ESC to show
icons.
2. How to show files in list view instead of icon view : Edit ⇒ Preference ⇒
choose "Views" tab ⇒ Default View ⇒ View new folders using ⇒ choose "List view". You
can also choose the columns to be displayed under "List Columns" tab.
3. View dot (hidden) files : Select "File" menu ⇒ Preferences ⇒ View ⇒ Show hidden
files.
4. Bookmark Folders (in the sidebar) : Select the desired folder, click the
"options" icon ⇒ Bookmark this location. The bookmarked folder will be shown in the
sidebar.
5. How to remove pre-set bookmarks from the sidebar such as
Videos : Edit ~/.config/user-dirs.dirs, and comment out the unwanted ones.
Create a file ~/.config/user-dirs.conf with a line enabled=false. Logout and sign-
in again.
13.5 gedit
1. Enable spell check : under "tool" menu ⇒ edit ⇒ preferences.
13.6 Accessing Remote Server
You can login to a remote server via command-line SSH, and transfer files via SCP. You can also use
GUI client such as FileZilla.
SSH (Secured Shell)
A terminal-based command-line client for logging in to the remote server.
$ ssh <username>@<server-name>
// OR
$ ssh <server-name> -l <username>