Run a script on boot using systemd on Ubuntu 18.04

Previous versions of Ubuntu had /etc/rc.local. that get executed after system boot.

On Ubuntu 18.04, you can use systemd to start a bash script on system boot.

Create file

Add

Create file /etc/rc.local with

You can replace “touch /root/OK” with whatever command you need to execute.

Make it executable with

Reload systemd

Enable the service

Now reboot the server, you will see /root/OK get created.

Install AnyDesk on Ubuntu using flatpak

AnyDesk ubuntu flatpak

AnyDesk is a remote desktop sharing application like TeamViewer and Google Remote Desktop. I normally use Google Chrome Remote desk as it is completely free. TeamViewer is popuplar alternative, but if they found out you are using it more often, they will limit your session to 5 minutes, some times even less to force you pay for paid version.

AnyDesk available for Ubuntu in deb file. I don’t like installing .deb package as it run a background process on port 7070 or somthing like that. So i decided to go with flatpak version.

First install flatpak with command

Add remote

Now you can install AnyDesk with command

flatpak install anydesk

To run AnyDesk, run

Configure Failover IP in Ubuntu 18.04 OVH VPS

Default /etc/network/interfaces in Ubuntu 18.04 in OVH VPS look like following

First install

Configure Main IP

use “ip a” command to find out interface name and IP of the VPS

In this case,

IP = 51.77.149.182
Interface Name = ens3

Use “route -n” command to find out gateway.

GATEWAY = 51.77.148.1

Edit /etc/network/interfaces

Add following

In the above, replace INTERFACE_NAME, SEVER_MAIN_IP and GATEWAY_IP.

For this server, i added.

Now reboot the server.

Once server is back online, you can configure failover IPS.

Configure Failover IP

Use following script to generate your config, add in end of /etc/network/inferfaces file

php script to generate ip config

Once configured, you need to reboot the servr.

Verify IP is up with fping command.

fping
/etc/inetnet/interfaces

Ubuntu Slow Boot

Last day my PC become very slow to boot.

It take 3 minutes and 17 seconds to boot up.

This happend after i did some changes to my 2nd hard disk and added ZFS partition. First thing i thought it was ZFS that make my PC slow.

systemd-analyze blame did not show any useful info.

systemd analyze blame

To find the problem, i edited the file

Find the line

Replace it with

Now rebuild grub.cfg with

Rebooted the PC. Now instead of showing Ubuntu splash screen, you get lot of text, that shows what actually your PC is doing.

Ubuntu Grub Disable Splash

From the boot message i found system waiting 1 minutes 30 seconds for mounting one of the disk partition. This is because i re-partitioned my 2nd hard disk and forget to remove the disk from /etc/fstab.

I removed the non existant disk entry from /etc/fstab and rebooted PC. Now it boot much faster.

systemd analyze

See Ubuntu

Enable Native Notification in Google Chrome

To enable/disable native notification in Google chrome, go to

Google Chrome Native Notification

Once native notification is enabled/disabled, you will be asked to restart browser.

On Ubuntu 18.04, i disable Native Notification as it is buggy, come can’t control how long notification shown if you use native notification. With chrome provided notification, you can use javascript to disable notification after predefined time. On Ubuntu 16.04, native notification is disabled by default.

Chrome

OVH VPS Configure failover IP in Ubuntu

On Ubuntu

Default config look like

/etc/network/interfaces.d/50-cloud-init.cfg is used to auto configure network interface with dhcp.

First find the gateway used by the VPS.

We found the gateway IP 51.254.32.1

The VPS had main IP of the server is 51.254.35.58 and secondary IPS 94.23.153.137, 178.32.52.159, 178.32.49.157

Here is the modified /etc/network/interfaces

Here is a PHP script to create OVH failover IP config for Ubuntu/Debian.

https://gist.github.com/serverok/991f7ccd1be36cbc579e8d55caf39715