How do I update a single package? As far as man apt-get
says apt-get upgrade
doesn't take a package/list of packages as parameter:
upgrade
upgrade is used to install the newest versions of all packages currently installed on the system from the sources enumerated in
/etc/apt/sources.list
. Packages currently installed with new versions available are retrieved and upgraded; under no circumstances are currently installed packages removed, or packages not already installed retrieved and installed. New versions of currently installed packages that cannot be upgraded without changing the install status of another package will be left at their current version. An update must be performed first so that apt-get knows that new versions of packages are available.
You just need to do
apt-get install --only-upgrade <packagename>
. This will upgrade only that single package, and only if it is installed.If you wish to install the package if it doesn't exist, or upgrade it if it does, you may leave out
--only-upgrade
.In order to update a single package using the CLI:
e.g.,
sudo apt-get install --only-upgrade ack
There are two possible ways I can think of:
sudo apt-get install nameofpackage
This will upgrade the package even if is already installed:
Using
Synaptic Package Manager
: Right click→Mark for upgrade:Note: Sometimes it may asks for additional packages or dependencies, it is normal.
In my experience on Ubuntu 12.04 LTS, using the command below will not upgrade the package if using a separate PPA -
Similarily, I did not want to run the upgrade command, which would upgrade all packages on my server -
For example, I have PHP 5.3 installed and have added the ondrej PPA to my apt.sources using -
If I run
it will just reinstall PHP 5.3.
I have to, first, determine the version number to upgrade to, using
This will list all available version numbers. You should find the version number you want to upgrade to, and then copy the whole string that references it. For example, the string for PHP 5.5 on Ubuntu is "5.5.16+dfsg-1+deb.sury.org~precise+2".
Now, you can run the apt-get install command with the specific version number, and voila!
I only added this because I was unable to find this information anywhere else!
On Ubuntu 9.04 Jaunty,
yields:
The command
worked in my case.
For a command line solution that doesn't install the package if it doesn't already exist:
This can easily be made into a script, e.g.:
upgrade-package.sh:
To upgrade a single package on Ubuntu 18.04 LTS:
To upgrade multiple packages: