Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.

share|improve this question
add comment

4 Answers

up vote 144 down vote accepted

You just need to do apt-get install <packagename>. This will upgrade only that single package.

share|improve this answer
3  
This upgrades the package alright, but it also installs it if it's not installed, so it's not really an equivalent to upgrading only one package. –  ℝaphink Aug 4 '11 at 11:31
1  
@Raphink: Your comment about the upgrade is right, but install is considered as an equivalent to upgrading one package; install is followed **by one** or more packages desired for installation or upgrading , If you have a better answer, you can answer the question.It would be great. –  Binarylife Aug 4 '11 at 11:56
38  
apt-get install --only-upgrade <packagename> will not install any new packages –  taneli Oct 15 '12 at 11:29
1  
Will the install command upgrade also the dependencies of that single package if necessary? –  Pino May 31 '13 at 8:18
1  
@Pino It will, it makes sense to do so. What if the version you are upgrading to depends on a newer version of another package? You're hosed if you don't upgrade both. This is why install is the right command for this, even if it seems counter-intuitive. –  mattedgod Aug 22 '13 at 19:57
show 3 more comments

In order to update a single package using the CLI:

sudo apt-get --only-upgrade install <packagename>

e.g., sudo apt-get --only-upgrade install ack

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Skipping **ack**, it is not installed and only upgrades are requested.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
share|improve this answer
1  
I get an error with this command: E: Sense only is not understood, try true or false. –  Michael Sep 20 '13 at 18:15
add comment

There are two possible ways I can think of:

  1. sudo apt-get install nameofpackage

    This will upgrade the package even if is already installed:

    ~$ sudo apt-get install emesene
    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    The following packages will be upgraded:
      emesene
    1 upgraded, 0 newly installed, 0 to remove and 5 not upgraded.
    Need to get 1,486 kB of archives.
    After this operation, 696 kB disk space will be freed.
    Get:1 http://il.archive.ubuntu.com/ubuntu/ natty-updates/universe emesene all 2.11.4+dfsg-0ubuntu1 [1,486 kB]
    
  2. UsingSynaptic Package Manager: Right click→Mark for upgrade:

    enter image description here

    Note: Sometimes it may asks for additional packages or dependencies, it is normal.

share|improve this answer
    
great, so it works after all, thanks –  lurscher May 20 '11 at 16:41
    
Yeah , it should , and sudo apt-get install whatever should do upgrade by itself. –  Binarylife May 20 '11 at 16:44
3  
upgrade doesn't take a package argument. –  ℝaphink Aug 4 '11 at 11:31
    
Right, thanks , it upgrades all of the packages. –  Binarylife Aug 4 '11 at 12:13
add comment

For a command line solution that doesn't install the package if it doesn't already exist:

dpkg -s <package> 2>/dev/null | grep -q Status.*installed && sudo apt-get install <package>

This can easily be made into a script, e.g.:

upgrade-package.sh:

#!/bin/bash

[[ -z $1 ]] && { echo "Usage: $(basename $0) package"; exit 1; }

if dpkg -s "$1" 2>/dev/null | grep -q Status.*installed; then
    echo "Attempting to upgrade $1"
    sudo apt-get install "$1"
else
    echo "Package $1 is not installed"
fi
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.