How to upgrade a single package if needed using apt.

This command will update a single package upon request. This would be very useful if you want to update only a certain package.

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

I found this tip here: http://askubuntu.com/questions/44122/how-to-upgrade-a-single-package-using-apt-get. This would be very useful to someone using Ubuntu or Debian.

Here is an example.

[email protected]:~$ dpkg -s libav-tools 2>/dev/null | grep -q Status.*installed && sudo apt-get install libav-tools
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  dkms g++-4.8 gcc-4.8-base:i386 gsettings-ubuntu-touch-schemas lib32gcc1 libappindicator1 libass4 libaudclient2 libaudcore1 libavdevice53 libavfilter3 libavresample1 libbaloocore4
  libbaloofiles4 libbalooxapian4 libbonobo2-0 libbonobo2-common libbonoboui2-0 libbonoboui2-common libboost-iostreams1.54.0 libboost-program-options1.54.0 libboost-serialization1.54.0
  libboost-thread1.54.0 libc6-i386 libdbus-cpp2 libdee-qt5-3 libdvbpsi8 libepub0 libgnome-media-profiles-3.0-0 libgnome2-0 libgnome2-bin libgnome2-common libgnomecanvas2-0
  libgnomecanvas2-common libgnomeui-0 libgnomeui-common libgnomevfs2-0 libgnomevfs2-common libgnutls28 libgtk-vnc-1.0-0 libhud-client2 libidl-common libidl0 libindicator7
  libjavascriptcoregtk-1.0-0 libkactivities-models1 libkidletime4 libllvm3.4:i386 libmagickcore5 libmagickcore5-extra libmagickwand5 libmediascanner-2.0-0 libmikmod2 libmirclient7
  libmirclientplatform-mesa libmirplatform libmirplatformgraphics-mesa libmirserver18 libmowgli2 libnepomukcleaner4 libnepomukcore4abi1 liboil0.3 liborbit-2-0 liborbit2 libpoppler-qt4-4
  libprocess-cpp1 libqmobipocket1 libsoprano4 libstdc++-4.8-dev libtar0 libts-0.0-0 libubuntu-application-api-mirclient1 libubuntu-application-api-mirserver1 libubuntu-application-api-test1
  libubuntu-application-api1 libubuntu-location-service0 libubuntu-platform-hardware-api1 libupstart-app-launch2 liburcu1 libvirtodbc0 libwebkitgtk-1.0-0 libwebkitgtk-1.0-common
  libwireshark3 libwiretap3 libwsutil3 libwxbase2.8-0 libwxgtk2.8-0 libxine1 libxine1-bin libxine1-ffmpeg libxine1-misc-plugins libxine1-plugins libxine1-x libyate5.0.0 libzip2
  linux-headers-3.13.0-32 linux-headers-3.13.0-32-generic linux-image-3.13.0-32-generic linux-image-extra-3.13.0-32-generic nepomuk-core-data nepomuk-core-runtime
  phonon-backend-gstreamer1.0 python-appindicator python-gnome2 python-gtk-vnc python-pyorbit qtdeclarative5-dee-plugin qtdeclarative5-qtmultimedia-plugin shared-desktop-ontologies
  soprano-daemon tsconf ubuntu-purchase-service virtuoso-minimal virtuoso-opensource-6.1-bin virtuoso-opensource-6.1-common vlc-plugin-pulse
Use 'apt-get autoremove' to remove them.
The following packages will be upgraded:
  libav-tools
1 to upgrade, 0 to newly install, 0 to remove and 10 not to upgrade.
Need to get 416 kB of archives.
After this operation, 3,072 B disk space will be freed.
Get:1 http://de.archive.ubuntu.com/ubuntu/ vivid/universe libav-tools amd64 6:11.1-1 [416 kB]
Fetched 416 kB in 2s (167 kB/s)       
(Reading database ... 335106 files and directories currently installed.)
Preparing to unpack .../libav-tools_6%3a11.1-1_amd64.deb ...
Unpacking libav-tools (6:11.1-1) over (6:11-2) ...
Processing triggers for man-db (2.7.0.2-4) ...
Setting up libav-tools (6:11.1-1) ...

This is how you can only update one package without needing to install them all at once.

No comments have been made. Use this form to start the conversation :)

Leave a Reply