Installing Ubuntu 20.04 LTS (Focal Fossa) Minimal Server (Page 2)

botond published Jan. 2020, 09, 23:17 p.m. time

Content

  1. page: Perform Ubunu 20.04 LTS installation steps
  2. page: Perform post-installation settings and configurations

 

2. page content

 

Continuation

Ubuntu 20.04 LTS (Focal Fossa) Minimal Server Installation Guide on the first page we have followed the steps of the installer, and on this page we will make the necessary settings so that this server can serve as a suitable basis for future server installations.

 

First login

After restarting the machine, first enter the console:

 

 

Minimal server - Ubuntu 20.04 LTS (Focal Fossa) installation - First login

After the first login we can see a lot of information, including the machine IP addressesand that there are updates available:

Minimal server - Ubuntu 20.04 LTS (Focal Fossa) installation - First login

 

Package repository and update packages

Update the package store our database and packages as follows:

sudo apt-get update
sudo apt-get upgrade

After the commands, our user's password must be entered.

Or you can run it as a command so you don't have to enter the password twice:

sudo apt-get update && sudo apt-get upgrade

As you can see, there are quite a few upgrades to the system:

Minimal server - Installing Ubuntu 20.04 LTS (Focal Fossa) - Updating packages

Continue with the "Y" option and wait for the updates to install.

 

Enable Root User (Optional)

By default, Ubuntu login with the root user is disabled. Developers and the Ubuntu community strongly recommend direct access to the root user. Instead, they recommend using sudo when you need root privileges to perform a task. However, root access is allowed, but it is only used when it is really needed!
sudo passwd root

 

 

The command first asks for the password of our plain user for sudo and then asks for a password for the root user, which must be repeated:

Minimal server - Ubuntu 20.04 LTS (Focal Fossa) installation - Root password setting

If you want to use the sudo command without a password, you can find out more here.

 

Remote SSH login

Using a machine running in VirtualBox in console mode is a bit inconvenient in my opinion. Eg clipboard, mouse handling, etc. Therefore, I personally open a terminal window on my desktop (Debian) machine and log in from there SSHbecause I have more control over everything in my usual terminal window. Of course, those who use Windows can log in from there, for example Putty help. But those who qualify for the VirtualBox host console may remain in it.

If you did not select the SSH server installation during the installation, you can do so with the following command:

sudo apt-get -y install ssh openssh-server

When I first logged in, I wrote that the IP address of the machine would also be displayed. Well, those who still choose SSH can log in first with this IP address from the local network, such as the host machine, except for the username specified during installation. For example, about Linux:

ssh linuxportal@192.168.100.9
The IP address may be different for each network. For example, the addresses I had before that were reserved for desktop, laptop, etc., so it was my first free address. So everyone uses his or her own address, for example. the router.
In addition, it is important that the host machine can only access our newly installed guest machine if the In VirtualBox for networks, we have set up Bridge mode for our network card.

When you first log in to SSH, a message appears stating that the server does not yet know this client and whether you want to store your digital fingerprint in the list of known machines. To do this, type "Yes" and then log in to the server:

Minimal server - Ubuntu 20.04 LTS (Focal Fossa) installation - Remote login via SSH

When you log in, even write that you need to restart the server. However, this will be covered later after setting up the network components.

 

Configure Nano (Optional)

GNU nano word processor I think is the best word processor when working in a terminal. The LTS (Focal Fossa) version of Ubuntu 20.04 is included by default, so you don't have to install it anymore, you just need to do a little fine-tuning to make it even more convenient to use.

 

 

You can do this as a plain user and as root, so that your favorite editor works the same for both. Create the nano configuration file in the user's home directory:

nano ~/.nanorc

Then let's add some settings to it, then save it:

set tabsize 4
set smooth
set mouse
set constantshow

Line items have the following meaning:

  • set tabsize 4: Tab size 4 characters. By default, 8 characters, which is too much. 4 is used in most places.
  • set smooth: Fine scrolling. As a result, scrolling is done line by line, making it easier to scroll over larger files.
  • set mouse: Enables mouse operations. For example, positioning the cursor with the mouse, etc.
  • set constantshow: Display row, column, character position information. This also comes in handy if, for example, the x in a particular config file. a setting must be made in a row. This makes it easy to navigate to the right line. (equivalent to the "set const" setting in previous Nano versions).

Of course still nano has a lot of settingsso everyone can spice it up to their liking.

After saving and exiting, the next time you start nano, the settings will take effect.

 

Set up a network

Ubuntu installer DHCPconfigured the network via, which results in dynamic address allocation. And a static IP address is required to run a server. If you are building the server in a home development or test environment, this is not important, in this case it is enough to set a fixed IP address in your router by assigning it to the MAC address of the machine, and you can skip this section. However, if you are setting up a server for live use, you will need to set a fixed IP address in Ubuntu (as well), which can be done as follows.

Configure Netplan

In Ubuntu 20.04, the network is configured using Netplan. To set it up, open for editing /etc/netplan/01-netcfg.yaml file:

sudo nano /etc/netplan/00-installer-config.yaml

(The previously known / etc / network / interfaces file is no longer in use.)

The default DHCP-based configuration of the server looks like this in the first round in this file:

# This is the network config written by 'subiquity'
network:
  ethernets:
    enp0s3:
      dhcp4: true
  version: 2

Here we need to configure the static IP address according to our own network and needs. On this Ubuntu 20.04 server, I will use the IP address 192.168.100.130 as well as google name servers, but set it up according to everyone’s needs. So in the example I have, I first comment out the current settings to keep the original settings, and then paste my own settings. Then the file looks like this to me:

# This is the network config written by 'subiquity'
#network:
#  ethernets:
#    enp0s3:
#      dhcp4: true
#  version: 2
network:
    version: 2
    renderer: networkd
    ethernets:
        enp0s3:
            dhcp4: no
            dhcp6: no
            addresses: [192.168.100.130/24]
            gateway4: 192.168.100.1
            nameservers:
                addresses: [8.8.8.8,8.8.4.4]
Important!
Pay attention to the indents here, because this is the only way the system will interpret the yaml file. Tabs are not allowed, only spaces can be used for indents. I used the "standard" 4-character indent in the configuration file so it is clearer.

The configuration I present may differ elsewhere. For example, the name of the network device (enp0s3) and the gateway IP address (gateway4 address) may be different on another machine or network. Check these (print the name of the network device when you log in, and the gateway address, for example, ip r | grep default or the route you can query it with one of the commands. For the latter a net-tools package installation required).
Also, the IP address of 192.168.100.130 that I specified is a special setting, so everyone should set it to the appropriate address for their network and for them (I set this Ubuntu 20.04 virtual machine series to 130). In the case of a live server (eg VPS or leased server), we use the static IP address provided for the subscription.
For name servers, the Google's public name servers i gave it, it works everywhere.

Save and exit the editor.

Then the netplan generate command from the yaml file creates a configuration that can be understood by the background network management system. So let's run it (as root):

sudo netplan generate

If there is a syntax error in the yaml file above, it throws an error here and does not normally output.

Then run the following command to apply the changes:

sudo netplan apply

After executing the command, the new IP address of the server will be updated, so if we have connected here via SSH, our connection will be lost, so we will have to log in again with the new IP address. If you have already thrown it out, restart the entire server from the console, as it will need to restart anyway due to the updates. Run the following command from the console:

sudo reboot

 

Set host name

I set the hostname of this machine to "ubuntu20". The FQDN and I set its name to ubuntu20.linuxportal.vm. Here, too, of course, everyone chooses their own hostname. To set it, open / Etc / hosts file:

sudo nano /etc/hosts

 

 

From this base it can be found:

127.0.0.1 localhost
127.0.1.1 ubuntu20

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

Expand it as follows (everyone uses their own name and the IP address used above):

127.0.0.1 localhost
192.168.100.130 ubuntu20.linuxportal.vm ubuntu20

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

Let's save it. Then run the following two commands to set the name:

sudo echo ubuntu20 > /etc/hostname 
sudo hostname ubuntu20

The first hostname command overwrites the hostname in the /etc/hostname file, which will be used on restart, and the second command also sets it for this session, so you don't have to restart the machine.

Finally, let's check our hostname:

hostname
hostname -f

The above commands should output something like this:

Minimal server - Ubuntu 20.04 LTS (Focal Fossa) installation - Hostname setting

 

Extras

Without wishing to be exhaustive, I will list here a few settings that are not mandatory, but if we make them, we can make the work in the terminal with them more comfortable.

Bash programmable command line extension

A Bash Command Line Addition, also known as Bash programmable completion let us know the Tab press to enter the desired commands or file names faster. I will write about this in more detail in another article, the point here is that the root user does not have the programmable Bash add-on enabled by default, but only the basic add-on (Bash completion), which means that he can only add commands and filenames. . However, many times it may be necessary to program the add-on for different commands.

This feature is available on the system already pre-installed bash completion package, just need to be enabled. To do this, open in the root directory .bashrc file:

sudo nano ~/.bashrc

Then scroll to the bottom where we see this section:

# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
#if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
#    . /etc/bash_completion
#fi

Here, take the comment from the last three lines, as I have highlighted in red.

Save and then source the .bashrc file to take effect:

source .bashrc

vagy

. .bashrc

commands.

From here, for example, if you enter, say systemctl and then press two Tab , you will already have listed the other options for this command:

Minimal server - Ubuntu 20.04 LTS (Focal Fossa) installation - Bash programmable command line add-on

 

Configuring aliases

There are also a couple of alias commands set by default, but I'll vary this a bit more as follows (this can be done for both plain users and root):

 

 

nano ~/.bashrc
[...]
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
    test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
    alias ls='ls --color=auto'

    export LS_OPTIONS='--color=auto --group-directories-first'

    #alias dir='dir --color=auto'
    #alias vdir='vdir --color=auto'

    alias grep='grep --color=auto'
    alias fgrep='fgrep --color=auto'
    alias egrep='egrep --color=auto'
fi

# colored GCC warnings and errors
#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'

# some more ls aliases
#alias ll='ls -alF'
#alias la='ls -A'
#alias l='ls -CF'

# Saját ls aliasok
alias ls='ls $LS_OPTIONS'
alias ll='ls $LS_OPTIONS -l'
alias l='ls $LS_OPTIONS -lAh'
[...]

I added one at the top of the .bashrc detail export LS_OPTIONS starting line with which I set common switches for my own ls aliases below. THE --group-first-directories a very useful one ls switch to list the directories in advance so you can get a much clearer list of directories.

And at the bottom of the detail, I commented on the factory ls aliases and added my own instead. Of these, I use the most recent one, which runs the ls command by the "l" command, which inherits the following switches:

  • --color = auto: Use color output.
  • --group-first-directories: Pre-listing of the libraries mentioned above.
  • -l: Detailed list mode
  • -THE: It also lists the hidden files, but omits the root directory (.) And parent directory (..) from the directories (in the long run I find it annoying, many and .. at the beginning of the lists).
  • h: "Human-readable", that is to divide the file size into bytes instead of bytes into Kb, Mb, Gb. This makes the file size much easier to read.

Of course, everyone can customize the whole thing according to their own needs, so I get used to it, so it's convenient for me to use.

I've written about using the color ls command before in this description, so there are still opportunities.

Color root prompt

By default the color prompt is turned on for the normal user, but not for the root user. To enable it, log in as root and then open the .bashrc file:

nano ~/.bashrc

Here (in the 39 line of the factory file) you will find one of the following options:

#force_color_prompt=yes

Let's take a comment from this and save it.

Then source the root .bashrc file:

. ~/.bashrc

And then the prompt changed color.

About using the color prompt in this description we can find out more.

 

Download virtual machine

The virtual machine is available on the download page:
Ubuntu 20.04 LTS (Focal Fossa) minimal server download

 

Conclusion

So this would be a minimal Ubuntu 20.04 LTS (Focal Fossa) server installation, which will be an excellent basis for future LAMP, or perfect server installations. We have set up a lot of things, so we can work comfortably on the server later.

 

What's next?

Creating a minimal server can be an excellent step LAMP server to this Ubuntu 20.04 LTS (Focal Fossa) server at the following link: Install Ubuntu 20.04 LTS (Focal Fossa) LAMP Server v1.0

 

 

 

 

Navigation

This description consists of several pages: