How to upgrade a single package using apt-get?
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.
7 Answers 7
You just need to do apt-get install —only-upgrade . 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 .
apt-get install —only-upgrade
@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.
Does this remove the «auto» mark? Sometimes when you install libraries specifically the package is marked as manually installed. I don’t like running ‘install’ on libraries for this reason.
I just tested, since all information is pretty vague; on Ubuntu 16.04 ( apt 1.0.1 ), upgrading a package using apt install does not affect the auto mark, whether —only-upgrade is supplied or not. Though of course using —only-upgrade makes sense if you don’t want to accidentally install something new. It will also upgrade any required dependencies.
In order to update a single package using the CLI:
sudo apt-get install --only-upgrade
e.g., sudo apt-get install —only-upgrade 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.
You should pass —only-upgrade to install subcommand, not directly to apt-get , then you’ll not have to append true .
There are two possible ways I can think of:
- 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]
How To Update All Packages On Ubuntu
If you are new to Ubuntu, you might be having a difficult time adjusting to the Gnome environment. If you are confused about what a package is, compare it to a real-life example. In real life, a package can be a box containing different items. You can access the items in the box by unpacking the said package. Similarly, a package in Ubuntu is a compressed file archive containing a list of files and scripts required to run a particular application. For Ubuntu to access those files, it needs to unpack or in computer terminology install/update the said package.
Updating packages in Ubuntu is, to be honest, quite a simple task that can be done with just two mouse clicks, or by typing two commands if you are updating via terminal. There are two major ways that you can go about completing this task. You can update your packages via command line, or if you like to perform tasks using GUI, you can update your packages graphically using Package Updater. The choice is yours to make.
Method 1:Via Terminal
On the Ubuntu desktop, go to the terminal by clicking the terminal icon in the shell or simple press Ctrl+Alt+T.
In the terminal type, the following command
After typing the above command, you will be asked for your password. Type the password in the terminal. No characters will be shown on the terminal when you are writing your password. After typing the password, hit enter.
Now contrary to popular belief, this command doesn’t update your system. Instead, it updates your Ubuntu repositories. So your system checks against the repositories. It checks if there are newer versions available of the program installed. It won’t update your existing packages right away; instead, it will update the information about the existing packages and their versions available. This is the reason that when this command finishes execution, Ubuntu shows you the number of packages that can be updated.
In the picture above, you can see that when this command finishes execution, Ubuntu shows you the list of packages that can be updated. In order to view these packages type the following command
You can update a particular package, or you can update all of the updatable packages on your Ubuntu. To update all your packages, just type the following command in the terminal.
After typing the above command again, Ubuntu will ask you for your password. Like before, type in the password and hit enter.
After 2 or 3 seconds Ubuntu will show you the amount needed to update these packages and will further ask for your confirmation. To continue, type y in the terminal and press enter. Once you do this, Ubuntu will start downloading and updating your packages.
This command will download and update all of the packages that need updating. A little pro tip here to make this updating task easy. You can also type the following command instead of typing in these two commands.
As the two commands require to run in succession, we can combine them into a single command. The && between the two commands combines them. So now the first command before the && sign runs. When the first command has completed execution, the rest of the command after the && is executed. The -y at the end will save you one keystroke where Ubuntu asks you whether you want to install the upgrades or not. You should run this command from time to time to keep your system up to date.
Method 2: Update using Package Updater:
Go to the menu and in the search bar type “Software Updater.”. Now run it.
It will check if there are any packages on your system that can be updated.
If there are any such packages, it will give you the option to install the updates
Click on Install Now. It will ask for your password. Type your password and hit Authenticate.
After authenticating, Ubuntu will start downloading and installing the updates.
In some cases, you might be asked to restart your system after the updates. This is so that the installed, updated packages can take full effect and function properly.
In most of the cases after updating, there are some packages the are of no further use to the user. You can delete them, which will free up your system space and keep your system clean and tidy, which is always a good thing. To do so type the following command in the terminal
This tutorial is valid for all the versions of Ubuntu and other Linux distros based on Ubuntu like Linux Lite, Linux Mint, etc.
Conclusion:
I hope this tutorial will be helpful to you. One of the many things you hear about Ubuntu is that it’s a lot safer than Windows. The proof can be seen when updating. Whenever you make any changes to the system, Ubuntu asks you your password for authentication. Updating packages in Ubuntu is quite simple. Bear in mind that this tutorial is for updating packages in Ubuntu. It doesn’t update your Ubuntu version. Also note that this tutorial, including the command line method, is valid for all the versions of Ubuntu and other Linux distros based on Ubuntu like Linux Lite, Linux Mint, etc.