Ubuntu server tutorial for beginners

Most people probably know of Ubuntu as a desktop operating system. But Ubuntu’s massive popularity and strong footing in the Linux community have allowed Canonical to produce a very viable server edition and still maintain their desktop release. Ubuntu Server is a great choice if you are looking for an operating system for your production servers such as web servers, database servers, file servers, etc. It is free, stable, scalable, and has optional support plans.

After downloading Ubuntu Server and installing the operating system, there is some initial setup and configuration that administrators should do. In this tutorial, we will guide you through some of the most common tasks that beginners should know about, so you can get your Ubuntu Server up and running smoothly.

In this tutorial you will learn:

  • How to keep Ubuntu server up to date
  • How to enable and secure SSH
  • How to install and enable a firewall
  • How to install necessary services
  • How to enable the root user
  • How to configure network settings
Ubuntu server tutorial for beginners
Ubuntu server tutorial for beginners
Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Ubuntu Linux
Software N/A
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non-privileged user

Ubuntu server tutorial for beginners



Twitter icon Follow LinuxConfig.org on Twitter for the latest tips and tricks about Linux!


Below we have outlined several major things for administrators to do when first getting started with Ubuntu Server.

Keep Ubuntu Server Up to Date

Security patches and critical updates are being released all of the time for Ubuntu and the installed applications or services. On a weekly basis, an administrator should check for and install updates by using the following commands:

$ sudo apt update
$ sudo apt full-upgrade
NOTE
apt full-upgrade will also upgrade the system kernel (if an update is available) and will require a restart. If you want to update all packages except for the kernel, then just use apt upgrade instead.

Afterwards, you can remove the left over packages that Ubuntu no longer needs:

$ sudo apt autoremove

Enable and Secure SSH

SSH is the primary method of remote access and administration for Ubuntu Server. Using SSH to remotely log into Ubuntu Server will give you a command line terminal that you can fully access as if you were physically in front of the machine. This is a very convenient way to manage your server.

To install SSH server on Ubuntu Server:

$ sudo apt update
$ sudo apt install ssh

Afterwards, see our other tutorial on How to secure SSH best practices for different ways that you can harden your SSH service in order to keep unintended users and hackers from gaining entry to your system.

Install and Enable Firewall

It is best practice to block all incoming connections to your server, other than those on certain ports. For example, a web server may want to allow incoming connections on HTTP port 80, and HTTPS port 443, but then should block connection attempts that are trying to access other ports. The best way to do this on Ubuntu is with the ufw firewall.

Install and enable UFW:

$ sudo apt install ufw
$ sudo apt enable ufw
$ sudo apt start ufw




Afterwards, only open up the ports that you need:

$ sudo ufw allow ssh
$ sudo ufw allow http
etc...

Read more: How to install UFW and use it to set up a basic firewall

Install Necessary Services

Most servers only fulfill one purpose. For example, a web server hosts a web site. It would not be common practice to also use a web server as a file server or backup server. These are separate jobs that should be delegated to separate servers. With this in mind, what do you plan on doing with your server? Depending on the purpose of your server, you will need to install the pertinent services. Here are some examples:

Install a database (MariaDB / MySQL):

$ sudo apt install mariadb-server mariadb-client
$ sudo mysql_secure_installation

Install an Apache web server with PHP support:

$ sudo apt install apache2 php libapache2-mod-php

Install an NGINX web server:

$ sudo apt install nginx

Enable the Root User

This one is completely optional, but Ubuntu does not give the root account a password, and instead expects you to use a normal user account and gain administrator privileges through sudo. This convention is cumbersome for some administrators, so they may wish to enable direct access to the root account. Here is how to do it:

$ sudo passwd

After giving the root account a password (make sure it is a very secure one) you can log in to the root acount through the usual method:

$ su -

Configure Network Settings

Servers ordinarily have a reserved IP address. This makes your services always accessible at a predictable place. You can easily check your IP information on Ubuntu, or configure a static IP address, DNS info, default gateway, etc.

See IP address:

$ ip a




Display default gateway:

$ ip r

In case you need to configure a static IP address, check out our guide on Ubuntu Static IP configuration.

Closing Thoughts

In this tutorial, we saw how to get started with basic tasks on an Ubuntu Server Linux system. Ubuntu Server is easy to use and you can breeze through the installation to get up and running in no time, but the hints in our tutorial will give you a good starting point after the installation is done.