On the test, I will update the Zabbix Agent on different versions of the Ubuntu operating systems.
First of all, update the Zabbix server so that it is not older than the Zabbix agent, for example, as I described in this article:
Upgrading Zabbix 3.2 to 4.2 on Ubuntu
Check the version of Zabbix agent:
zabbix_agentd -V
Suppose I have installed Zabbix agent 3.2, and on the official website https://www.zabbix.com/download there is version 4.2.
So delete the source with the old version:
sudo rm -Rf /etc/apt/sources.list.d/zabbix.list
And add with a new one, for example for Ubuntu 14.04 (Trusty):
sudo wget https://repo.zabbix.com/zabbix/4.2/ubuntu/pool/main/z/zabbix-release/zabbix-release_4.2-2+trusty_all.deb
sudo dpkg -i zabbix-release_4.2-2+trusty_all.deb
sudo apt update
Or for Ubuntu 16.04 (Xenial):
sudo wget https://repo.zabbix.com/zabbix/4.2/ubuntu/pool/main/z/zabbix-release/zabbix-release_4.2-2+xenial_all.deb
sudo dpkg -i zabbix-release_4.2-2+xenial_all.deb
sudo apt update
Or for Ubuntu 18.04 (Bionic):
sudo wget https://repo.zabbix.com/zabbix/4.2/ubuntu/pool/main/z/zabbix-release/zabbix-release_4.2-2+bionic_all.deb
sudo dpkg -i zabbix-release_4.2-2+bionic_all.deb
sudo apt update
And perform the update:
sudo apt-get install --only-upgrade zabbix-agent
Done, even version 2.0 should be updated in the same way.
Make sure that the Zabbix agent starts after the system restarts:
sudo systemctl is-enabled zabbix-agent
sudo systemctl enable zabbix-agent
sudo systemctl restart zabbix-agent