Archive for May, 2020

Awk To Get The Last Elemet After a Delimiter

I have to write these things, so I can find them when I inevitably need them again.

This will give you the last element in a delimited string:

awk -F “:” ‘{print $NF}’

Here is an example:

$ echo “elemet1:element2:element3:element4” | awk -F “:” ‘{print $NF}’
element4

Ubuntu: Disable Automatic Updates

UPDATE: What outlined below did not work, so here is what I ended up doing:

Change directory to:

$ cd /etc/apt/apt.conf.d

Edit the 20auto-upgrades, and change the Lists setting from 1 to 0:

$ sudo vi 20auto-upgrades
APT::Periodic::Update-Package-Lists “0”;
APT::Periodic::Unattended-Upgrade “1”;

Now, with the list disabled the service should never find anything to update.

Another option is just get rid of the service:

$ sudo apt remove unattended-upgrades

Note: The following did not work in Ubuntu 18.x:

For reason, I don’t know if this an Azure deployment issue or an Ubuntu decision, but I have found automatic updates turned on by default in a couple VMs. Not sure why you would ever want your production server automatically updating, so:

Check to status of the unattended-upgrades service:

$ sudo systemctl status unattended-upgrades

Stop the service:

$ sudo systemctl stop unattended-upgrades

Disable the service. NOTE: Services that have this as a dependency will start the service despite it being disabled. I am not aware of any for this service, but just putting it out there.

$ sudo systemctl disable unattended-upgrades

To prevent the unintended situation above, mask will create a link to /dev/null to prevent the service from being started whether there are dependencies or not.

$ sudo systemctl mask unattended-upgrades

Return top

INFORMATION