Installation and Configuration of Ubuntu on Linux Server

Ubuntu is based on Debian's free Linux distribution, which Ubuntu officially promises:

  • Ubuntu will always be free, including enterprise and security upgrades.
  • Ubuntu will provide commercial support to hundreds of companies worldwide.
  • Ubuntu includes the best translations and localizations provided by the free software community.
  • Ubuntu discs contain only free software, encourage users to use free and open source software, and improve and disseminate it.

Ubuntu seems more radical than the RedHat release.If you want to experience the latest Linux kernels, the latest software repository, Ubuntu is definitely the best choice!Today Jugo is talking to you about how to install the Ubuntu Server operating system in a virtual machine.

1. System Installation

1.1 Preparation

Before installing, we need to download the required system image files from the official website, such as:

Since this installation is a server version of Ubuntu, click the 18.04 LTS button under Ubuntu Server to start the download (LTS-marked long-term support version).After downloading, we get mirrored files such as ubuntu-18.04.3-live-server-amd64.iso;

Next, we need to prepare the following:

  1. Install virtualization software such as VMware Workstation or VirtualBox on your own computer;
  2. Create virtual machines, add disks, set up virtual machine networks (you can set them to bridge mode first);
  3. Add the downloaded mirror file to the CD drive;
  4. Start the virtual machine and start the installation.

1.2 Installation System

Select the installation language: Keep the default and press Enter to proceed to the next step

Select keyboard layout: Keep default and press Enter to proceed to the next step

Select a network connection: DHCP dynamically acquires IP addresses by default.You can keep the default here and modify the network parameters later in the system.Press Enter to Next Step

Setting up a proxy server: No setup required here, just press Enter to proceed to the next step

Set up the mirror source: You can manually change the default Using the domestic software source can speed up the software installation.When the input is complete, press the Tab key, select Done, and press Enter to proceed to the next step

Disk Partition: You can select the menu by the up and down arrow keys, where you can choose the second option, that is, use the whole disk and set the LVM, press Enter to start the setup

Disk partition: Keep default and press Enter to proceed to the next step

Disk partition: By default, 4 GB of storage space is allocated to / directory, and no SWAP partition is set.We can adjust this 4GB space to a SWAP partition and then allocate all the remaining space to /.

By using the up and down arrow keys, select to edit the default/root mount point, and return to select the [Edit] menu, such as:

In the Format menu, adjust it to swap swap partition, then return to confirm

Create partitions in the remaining disk space: Select the ubuntu-vg(new) option for the available devices by using the up and down arrow keys, then return and select the Create Logical Volume menu to create the primary partition:

Set its space to maximum and in the Mount menu: Enter and choose Mount to / Root

Press Tab, select Done at the bottom of the page, and press Enter to save disk partition settings

Select Continue, return to confirm partition rules, execute partition

Set user parameters:

Here we need to choose to install the SSH service, keep the cursor on the Install OpenSSH server option, and press the space bar to select it.Then press the Tab key, select Done, and proceed to the next step

Choose other optional services as needed: We won't install them here for the moment, keep the default, choose Done to start installing the system.

Waiting for the system installation to complete, select Reboot to restart the virtual machine to complete the installation when the following interface appears.

2. System Configuration

2.1 Initial Configuration

2.1.1 Setting ROOT user password

By default, the root user does not have a password.The following commands allow you to set a password for it:

sudo passwd root

Then enter the password and confirm it as prompted.

2.1.2 Update System

Update the software or upgrade the system as needed through the following commands:

# Update Software Warehouse Information
sudo apt-get update

# Update software
sudo apt-get upgrade

# Upgrade System
sudo apt-get dist-upgrade

2.1.3 Install common software

For the convenience of subsequent use, Jugo organized some common software for you.Can be installed at one time:

sudo apt-get install -y gcc g++ make cmake build-essential zlib1g-dev libyaml-dev libssl-dev libgdbm-dev libreadline-dev libncurses5-dev libffi-dev curl openssh-server checkinstall libxml2-dev libxslt-dev libcurl4-openssl-dev libicu-dev logrotate python-docutils pkg-config libexpat1-dev gettext libz-dev

2.2 Network Configuration

2.2.1 Basic parameters

The new version of Ubuntu Server uses netplan to configure the network. Its configuration file is modified in the /etc/netplan directory:

sudo vim 50-cloud-init.yaml

You can refer specifically to the following configurations:

    version: 2
        dhcp4: no
        dhcp6: no
        addresses: []
          addresses: [,,]

Update network configuration:

sudo netplan apply 

2.2.2 Firewall Configuration

1 Check firewall status:

sudo ufw status verbose

If the output: Status: inactive indicates that the firewall is not activated.

(2) Activate and enable firewalls:

sudo ufw enable 
sudo ufw default deny

To close the firewall, execute:

sudo ufw disable

(3) Examples of opening/disabling ports or services

# Allow external access to port 80
sudo ufw allow 80

# Prohibit external access to port 80
sudo ufw delete allow 80

# Allow this IP access to all local ports
sudo ufw allow from

# Prohibit external access to smtp services
sudo ufw deny smtp

# Delete a rule created above
sudo ufw delete allow smtp

# Port 22 to reject all TCP traffic from to addresses
sudo ufw deny proto tcp from to port 22

# All RFC1918 networks (LAN/WLAN) can be allowed access to this host (/8, /16, /12 is Cisco's network rating)
sudo ufw allow from
sudo ufw allow from
sudo ufw allow from

2.3 Clean up expired cores

As the system is updated and upgraded, some obsolete and old cores will take up some disk space and we can remove them.

First look at the current version of the kernel being used:

uname -a

View the existing cores in the system:

dpkg --get-selections|grep linux

Remove expired kernels, such as:

sudo apt-get remove linux-image-xxxxxx-generic
sudo apt-get remove linux-headers-xxxxxx
sudo apt-get remove linux-headers-xxxxxx-generic

If you clean up a record that still has a deinstall status, such as

linux-image-4.8.0-36-generic			deinstall
linux-image-extra-4.8.0-36-generic		deinstall

Cleanup can be performed

dpkg -P linux-image-4.8.0-36-generic
dpkg -P linux-image-extra-4.8.0-36-generic

2.4 APT-GET usage

2.4.1 What is apt-get

Advanced Packaging Tools (APT) is the package manager for Debian and its derived distributions (such as ubuntu).APT can automatically download, configure, and install packages in binary or source format, which simplifies the process of managing software on Unix systems. apt-get commands generally require root privileges to execute, so sudo commands are generally followed.It root yum, pacman, installpkg and other similar properties, is the management tool of system software.Will use one of them will basically be used.

2.4.2 apt-get Chinese parameters

# Usage: apt-get [options] command, such as:
sudo apt-get [option] install|remove pkg1 [pkg2 ...]  
sudo apt-get [option] source pkg1 [pkg2 ...]  
# apt-get is a simple command line interface for downloading and installing software packages.  
# The most common commands are update and install.  
########### command ###########

# Update Local Package Cache List
sudo apt-get update

# Update installed packages
sudo apt-get upgrade

# Install a new package  
sudo apt-get install

# Remove Package
sudo apt-get remove

# Automatically remove all unused packages
sudo apt-get autoremove

# Remove Packages and Profiles
sudo apt-get purge

# Download Source
sudo apt-get source

# Configure compilation dependencies for source packages
sudo apt-get build-dep

# Upgrade System
sudo apt-get dist-upgrade

# Upgrade according to dselect selection
sudo apt-get dselect-upgrade

# Clear downloaded installation packages
sudo apt-get clean

# Clean up old downloaded archives
sudo apt-get autoclean

# Check for broken dependencies
sudo apt-get check  
########### option ###########
 -h This help file.  
 -q Output to Log - No progress indication  
 -qq No information output, except errors  
 -d Download Only - Do not install or unzip archive files  
 -s Not actually installed.Simulate Execution Command  
 -y Assume yes for all queries, no prompt  
 -f Attempt to fix system dependency corruption  
 -m If the archive cannot be located, try to continue  
 -u Also show a list of update packages  
 -b Compile after getting the source package  
 -V Show detailed version number  
 -c=? Read this profile  
 -o=? Set custom configuration options, such as -o dir::cache=/tmp

2.4.3 apt-get common examples

# Search packages
sudo apt-cache policy #package#

# Search packages
sudo apt-cache search #package#

# Get information about the package, such as description, size, version, and so on
sudo apt-cache show #package#

# Installation package
sudo apt-get install #package#

# Reinstall Package
sudo apt-get install --reinstall #package#

# Forced installation, "-f = --fix-missing" should be a repair installation...
sudo apt-get -f install #package#

# Delete Package
sudo apt-get remove #package#

# Delete packages, including configuration files
sudo apt-get remove --purge #package#

# Delete packages and dependent packages + profiles, etc.
sudo apt-get autoremove --purge #package#

# Update Source
sudo apt-get update

# Update installed packages
sudo apt-get upgrade

# Upgrade System
sudo apt-get dist-upgrade

# Upgrade using dselect
sudo apt-get dselect-upgrade

# Understanding Use Dependencies
sudo apt-cache depends #package#

# Learn about a specific dependency when it comes to seeing which packages the package depends on
sudo apt-cache rdepends #package#

# Install related compilation environments
sudo apt-get build-dep #package#

# Download the source code for the package
sudo apt-get source #package#

# Clean up archives of downloaded files &&Clean up obsolete packages only
sudo apt-get clean && apt-get autoclean

# Check for broken dependencies
sudo apt-get check

# Find which package filename belongs to
sudo dpkg -S #filename#

# Find which package filename belongs to
sudo apt-file search #filename#

# List the contents of the package
sudo apt-file list #package#

# Update apt-file database
sudo apt-file update

# List the package name after unpacking the package.
sudo dpkg --info #package#

# Lists all packages in the current system. Can be used with parameter less in a split screen view. (similar to rpm-qa)
sudo dpkg -l

# View packages associated with Package Name in the system.
sudo dpkg -l |grep -i #package#

# Query the details of installed packages.
sudo dpkg -s

# Query the location of installed packages in the system. (similar to rpm-ql)
sudo dpkg -L

# Look for deb package details and see if you don't need to install a package after it's downloaded locally (take a look).
sudo sudo dpkg -I 

# Manual installation of packages (this command does not solve the dependency problem before the package), if you encounter a dependency problem when installing a package, you can use apt-get-f install to solve the trust problem.
sudo dpkg -i #package#

# Uninstall the package. Not a complete uninstall, but its configuration file still exists.
sudo dpkg -r #package#

# Uninstall all (but still does not resolve package dependencies)
sudo dpkg -P #package#

# Reconfiguration
sudo dpkg -reconfigure

2.4.4 FAQ

Updates appear:

The following packages have been kept back:
    linux-generic-hwe-18.04 linux-headers-generic-hwe-18.04 linux-image-generic-hwe-18.04

This is mainly because kernel updates have been detected and commands need to be executed:

sudo apt-get dist-upgrade

3. Summary

Ubuntu Desktop is currently the most successful and popular graphical interface version of Linux distribution; Ubuntu Server also accounts for a large part of the server-side market.Today, I'm going to give you a detailed description of the installation and configuration of Ubuntu Server. I hope it will help you.With regard to the use of virtualization software such as VMware and VirtualBox, Jugo will introduce them in more detail in subsequent articles. Please pay attention!

For more knowledge of dry goods, please pay attention to my public number: Dagger

Tags: Programming sudo Ubuntu Linux network

Posted on Wed, 05 Feb 2020 08:57:36 -0800 by dsoukup