Managing packages in Ubuntu is one of the most basic tasks for each Linux server administrator. Whenever a new service, tool or an application needs to be deployed on Ubuntu server, first you need to check whether the related package files are already installed or not. If the package files are not installed by default, you have to install package files before the server could provide those services. The package files consist of system files, meta-data, and the help tutorials files for a particular service that you may wish to configure. Here, we will explain how to install, update, and remove packages in Ubuntu using dpkg command line tool. If you are looking for apt-get and apt-cache command line tools, read this article.
Few of the packages can be installed and work without dependencies, while few packages may depend on other packages to work properly.
DPKG Debian GNU/Linux Package Manager
Dpkg is a Debian-based package manager tool that allows you to install, update, and remove packages in Ubuntu Linux system. Here, we will go through few of the most command tasks performed by dpkg tool with examples.
Listing Packages Using dpkg Tool
To list a specific package using dpkg command line tool, use the following syntax:
sudo dpkg –l |grep <package name>
If you want to list the files installed by a package using dpkg along with package files’ location, use the following command:
sudo dpkg –L <package name>
For example, to list the installed files and location of telnet package, execute the following command.
sudo dpkg -L telnet
Verifying Package Installation
To check whether a specific package is already installed or not, use the following command.
sudo dpkg -s <package name>
Installing Packages Using dpkg Tool
In order to install a Debian package using dpkg, you need to use the following syntax:
sudo dpkg –i <package-name.deb>
Updating Old Package With New One
To upgrade/update/replace an older package with new one, use the following command syntax:
sudo dpkg --update-avail <package-name>
Removing Packages Using dpkg Tool
In order to remove a package in Ubuntu using dpkg tool, use the following syntax:
sudo dpkg -r <package-name>
There are a lot more can be accomplished with dpkg tool. There are dozens of command line options that can be used with dpkg tool. For more information about dpkg tool, you can use the man dpkg command. This command will let you know the details of dpkg tool and its available command’s options usage. However, Linux administrators hardly use dpkg tool to manage packages in Debian based Linux such as Ubuntu. The most preferred and popular tool for managing packages in Ubuntu is apt-get that we have explained in a separate post.