Disable apt auto update and upgrade

Running Ubuntu Server LTS in a virtual machine, is helpful to test out software installations. Therefore is helpful that apt maintains the update and upgrade periodically. On the other hand if you don’t want that behavior, this post demonstrates how to disable it.

Login into the virtual machine, remember that you have to map the ssh port in the virtual machine to a different one in your host. In this example it is 1122 and the public key authentication is used.

tan@omega:~$ ssh localhost -p 1122
Welcome to Ubuntu 16.04.1 LTS (GNU/Linux 4.4.0-51-generic x86_64)
 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage
19 packages can be updated.
8 updates are security updates.
Last login: Fri Dec  9 16:28:50 2016

You will notice if you try to install or remove anything, that apt is already used by the apt-daily.timer.

tan@ubuntu:~$ sudo apt-get dist-upgrade
E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable)
E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?

To disable it for the next time:

tan@ubuntu:~$ sudo systemctl stop apt-daily.timer
tan@ubuntu:~$ sudo systemctl disable apt-daily.timer
tan@ubuntu:~$ sudo systemctl disable apt-daily.service
tan@ubuntu:~$ sudo systemctl daemon-reload