It just happens that we install a .deb from the source. And, if the package we have installed doesn't get upgraded along with the system then it can be a huge security issue. Furthermore, we recommend you to prefer installing packages through standard Ubuntu repository. But, it is not possible at all the times. Sometimes, there are packages we need which are not there in standard Ubuntu repository. In that case, we don't have much options left. It is pretty easy to upgrade a package using dpkg in Ubuntu if you have already installed a package (.deb) from source.
Note: Following operations would require you to have superuser privileges. In case you don't have one then, we advise you to contact your System Administrator for assistance.
Upgrade a package using dpkg
dpkg is a Debian's package manager. If you have already installed the package through dpkg the first time. Then, we need to repeat the same command after downloading the updated package.
Following syntax we need to use to upgrade the package using dpkg -
sudo dpkg -i <package_name>
where, -i is used to do both install as well as upgrade the package.
For instance, if you have installed a package - xyz.deb through dpkg
sudo dpkg -i xyz.deb
Then, to upgrade the package we need to first download the updated .deb package file. So, this time it could be xyz-version-1.deb
Now, to upgrade the package -
sudo dpkg -i xyz-version-1.deb
If there are dependency related errors and if they are available through standard Ubuntu repository then, use the following command to install relevant dependencies -
sudo apt install -f
Note: Always install packages and related dependencies from trusted sources.
In conclusion, we have discussed how to upgrade a package using dpkg in Ubuntu here. Upgrading and installing packages through dpkg can be done through same option, -i. All we need to do is run the same command again on the updated package.