To upgrade or update a single package using apt-get
on Ubuntu, you can use the following command:
sudo apt-get install --only-upgrade package-name
This command will update the specified package to the latest version available in the repositories.
Alternatively, you can use the command
sudo apt-get update package-name
to update the package to the version available in the repositories, but it will not upgrade to the latest version.
You can also use the apt-get
command with the -y
option to automatically answer “yes” to all prompts, which will allow the command to run without any user interaction.
For example, the following command will upgrade the package “nginx” to the latest version and automatically answer yes to all prompts:
sudo apt-get -y install --only-upgrade nginx
It’s also important to note that before running any update or upgrade command, it’s always recommended to run sudo apt-get update
to update the package list and sudo apt-get upgrade
to upgrade all packages.