Home of Me on the world wild web

Category: Ubuntu

MySQL or MariaDB root pass reset!

A customer needed help with their database for their website today, the developer had forgotten the root pass of the database holding all of their information, so of course we had to help out!

Start by stopping the service

systemctl stop mariadb

Now we set a flag for it to start with, on next start up

sudo systemctl set-environment MYSQLD_OPTS="--skip-grant-tables"

Start it

systemctl start mariadb

Now check that the flag we set actually took

sudo systemctl status mariadb
Look for the flag we set

Now you should be able to login to the database without a password

mysql -u root

Now to set the new root password, just follow along and set your new password in the ‘YourNerPasswordHere’ box 😀

USE mysql;
UPDATE user SET password=PASSWORD('YourNewPasswordHere') WHERE User='root' AND Host = 'localhost';

Thats it you have set a new password for ‘root’

Now lets stop the service again, unset the environment variable and kickstart the database with a brand new root password.

systemctl stop mariadb
sudo systemctl unset-environment MYSQLD_OPTS
systemctl start mariadb

Now the service is running and your root account have a brand spanking new password.

Happy trails my fellow IT nerds

Install Oracle Java 16

On Ubuntu Ubuntu 14.04, Ubuntu 16.04, Ubuntu 18.04, Ubuntu 20.04, Ubuntu 20.10

Firstly add the repository

sudo add-apt-repository ppa:linuxuprising/java

Now update the cache and install java

sudo apt update

sudo apt install oracle-java16-installer

You have the possibility to not set java 16 as default, just type this instead

sudo apt install oracle-java16-installer --no-install-recommends

You will be asked to agree to the license agreement, tab and choose “ok

and if you want to remove the ppa

sudo add-apt-repository --remove ppa:linuxuprising/java

and you can also completely remove java 16 again with this command

sudo apt-get remove oracle-java16-installer

But that would kinda ruin the whole exercise of installing it in the first place.


Open-source monitoring software

After trying and testing out different monitoring software over the last couple of days and my choice fell on Zabbix.

It was the most intuitive and customizable, and came with A LOT of templates right out of the box. The community, around this product is strong and there are templates for your every desire ready to download from the forum.

So a here is a fast installation guide :

Zabbix version: 5.4
Linux Ubuntu server version: 20.04

Lets first of obtain root access, then we don’t have to elevate the command all the time. You can do it without this, but then you need to add ‘sudo’ to every command that requires elevation.

sudo su -

Type your password and we are good to go!

Adding .deb

Lets get the .deb, add it to the repository and then update.

wget https://repo.zabbix.com/zab# wget https://repo.zabbix.com/zabbix/5.4/ubuntu/pool/main/z/zabbix-release/zabbix-release_5.4-1+ubuntu20.04_all.deb

dpkg -i zabbix-release_5.4-1+ubuntu20.04_all.deb

apt update

Now lets install the agent, server and frontend.

apt install -y zabbix-server-mysql zabbix-frontend-php zabbix-apache-conf zabbix-sql-scripts zabbix-agent

Creation of database and configuration.

Installation of MariaDB

We need SQL to handle the database for zabbix, I chose MariaDB

apt -y install mariadb-common mariadb-server-10.3 mariadb-client-10.3

Ones installed lets kickstart Maria..DB

systemctl start mariadb && systemctl enable mariadb

Onwards to secure our installation of MariaDB
I will use these database passwords:

root: DBpassRoot
zabbix: DBpassZabbix
You should definitely get creative and conjure up some of your passwords of your own choice for obvious security reasons!


Enter current password for root (enter for none): Press the Enter
Set root password? [Y/n]: Y
New password: <Enter root DB password>
Re-enter new password: <Repeat root DB password>
Remove anonymous users? [Y/n]: Y
Disallow root login remotely? [Y/n]: Y
Remove test database and access to it? [Y/n]:  Y
Reload privilege tables now? [Y/n]:  Y

Creation of database and user

Ask Maria nicely to create a database zabbix with password DBpassRoot

mysql -uroot -p'DBpassRoot' -e "create database zabbix character set utf8 collate utf8_bin;"

Then the user zabbix@localhost password DBpassZabbix and set privileges.

mysql -uroot -p'DBpassRoot' -e "grant all privileges on zabbix.* to zabbix@localhost identified by 'DBpassZabbix';"

Lets aviod the import ERROR 1118 🙂

mysql -uroot -p'DBpassRoot' zabbix -e "set global innodb_strict_mode='OFF';"

Our next task is to import initial schema and data.
Beware your installation didn’t break, it just takes some time
Pop open a soda, make a cup of coffee or read about configuration of Zabbix

zcat /usr/share/doc/zabbix-sql-scripts/mysql/create.sql.gz | mysql -uzabbix -p'DBpassZabbix' zabbix

We need to be a little strict and enter strict mode

mysql -uroot -p'DBpassRoot' zabbix -e "set global innodb_strict_mode='ON';"

Lets enter the database password in the config files

nano  /etc/zabbix/zabbix_server.conf

Look for the DBPassword key in the config file and write your password after the equals sign.

Search (ctrl+w and enter to search) for the value DBPass
Remove the # sign and enter our password DBpassRoot


Save the file and exit (ctrl+x, followed by y and enter

Configuration of the firewall

ufw allow 80/tcp
ufw allow 10050/tcp
ufw allow 10051/tcp
ufw reload

Lets fire up the Zabbix server and agent processes

systemctl restart zabbix-server zabbix-agent apache2

systemctl enable zabbix-server zabbix-agent apache2

Timezone PHP configuration needs a tweek

nano /etc/zabbix/apache.conf

Search (ctrl+w and enter to search) for the value data.timezone

remove the # sign and change the timezone information to your location.

php_value date.timezone Europe/Stockholm

Save the file and exit (ctrl+x, followed by y and enter

Restart Apache and lets make it start with the system.

systemctl restart apache2
systemctl enable apache2

Ladies and gentlemen, we have lift-off!

Now lets start configuring the Zabbix frontend.

Open your favorite browser and connect to you sparkeling new server:


In the wizard you only need to enter the password for the Zabbix database user we created DBpassZabbix for everything else just hit the next button.

You did it!

Use Zabbix default admin username “Admin” and password “zabbix” (without quotes) to login to Zabbix frontend at URL “http://server_ip_or_dns_name/zabbix” via your browser.

Have fun configuring the server!

Display network traffic

Ubuntu server

Looking for an easy simple way to display network traffic, just run the command

sudo iftop

Type you sudoers password, and bingo

Simple nothing to disturb you, just the simple facts

Should it, against better judgement, not be installed, then just run

sudo apt install iftop

You just gotta love it!

Install the NFS Client

Ubuntu 18.4 – the Client Side

Install NFS on the client system and mount the share.

Step 1: Install NFS-Common Package

Start by updating the system packages and repositories before anything else.

sudo apt update

Next, install nfs-common packages.

sudo apt install nfs-common

Step 2: Create a NFS Mount Point on Client

Next, you will have to create a mount point on which you will mount the NFS share from the server. Run the command:

sudo mkdir -p /mnt/nfs_clientshare

Step 3: Mount NFS Share on Client System

The last step remaining is mounting the NFS share that is shared by the NFS server. This will enable the client system to access the shared directory.

Let’s check the NFS Server’s IP address.


To achieve this run the command:

sudo mount  /mnt/nfs_clientshare

Great your are done!

Ubuntu 18.04 – Install and Configure an NFS Server

Installing and configuring NFS Server on Ubuntu

To install and configure the NFS server:

Step 1: Install NFS Kernel Server in Ubuntu

The first step is to install the nfs-kernel-server package on the server.
But before we do this, let’s first update the system packages.

sudo atp update

Once the update is complete, proceed and install the nfs-kernel-server package as shown below. This will store additional packages, which are equally crucial to the setup of the file share.

sudo apt install nfs-kernel-server

Step 2: Create an NFS Export Directory

The second step will be creating a directory that will be shared among client systems. This is also referred to as the export directory and it’s in this directory that we shall later create files which will be accessible by client systems.

Run the command below by specifying the NFS mount directory name.

sudo mkdir -p /mnt/nfs_share

Since we want all the client machines to access the shared directory, remove any restrictions in the directory permissions.

sudo chown -R nobody:nogroup /mnt/nfs_share/

You can also tweak the file permissions to your preference. Here’s we have given the read, write and execute privileges to all the contents inside the directory.

sudo chmod 777 /mnt/nfs_share/

Step 3: Grant NFS Share Access to Client Systems

Permissions for accessing the NFS server are defined in the /etc/exports file. So open the file using your favorite text editor:

sudo nano /etc/exports

You can provide access to a single client, multiple clients or specify an entire subnet.

In this guide, we have allowed en entire subnet to have access to the NFS share.


Explanation about the options used in the above command.

  • rw: Stands for Read/Write.
  • sync: Requires changes to be written to the disk before they are applied.
  • No_subtree_check: Eliminates subtree checking.

To grant access to a single client, use the syntax:

/mnt/nfs_share  client_IP_1 (re,sync,no_subtree_check)

For multiple clients, specify each client on a separate file:

/mnt/nfs_share  client_IP_1 (re,sync,no_subtree_check)
/mnt/nfs_share  client_IP_2 (re,sync,no_subtree_check)

Step 4: Export the NFS Share Directory

After granting access to the client systems, export the NFS share directory and restart the NFS server for the changes to take effect.

sudo exportfs -a
sudo systemctl restart nfs-kernel-server

Step 5: Allow NFS Access through the Firewall

For the client to access the NFS share, you need to allow access through the firewall otherwise, accessing and mounting the shared directory will be impossible. To achieve this run the command:

sudo ufw allow from to any port nfs

Reload or enable the firewall (if it was turned off) and check the status of the firewall. Port 2049, which is the default file share, should be opened.

sudo ufw enable
sudo ufw status

We’re done installing and configuring the NFS service on the Server, let’s now install NFS on the client system.

Ubuntu Server 18.4

Change back to default repository

Here is how to revert you changes back to default, if you for some reason changed your repositories in Ubuntu i.e install php updates or other 😉

Go to https://repogen.simplylinux.ch.

Select your Country and Ubuntu Release.

For the default set of repositories, you need to enable these repositories.

  • All of the Ubuntu Branches repositories.
  • Security – Important Security Updates.
  • Security Sources Repository
  • Updates – Recommended Updates
  • Updates Sources Repository

If you want to install software from Canonical Partner Repositories (closed source software), enable the Ubuntu Partner Repositories (both of them).

Enable any 3rd party repository you wish to enable.

Now, click the Generate List button at the bottom of that page and you’ll see your generated sources.list.

Replace the old sources.list with the new one

Run the following commands in a Terminal.

sudo mv /etc/apt/sources.list /etc/apt/sources.list.old
sudo nano /etc/apt/sources.list

Copy/paste all the text from the newly generated sources.list to this file. Save it and close Gedit.

Now, update apt.

sudo apt-get update

This will update your repository index with the current sources.list and then you can install any software using Software Center, Synaptic or apt-get.


Enjoy and have fun updating without errors, again!

© 2021 Thomas Christiansen

Theme by Anders NorenUp ↑