The user can install and uninstall any software in Ubuntu by using Ubuntu Software Center or command line. Many commands and programs are installed by default in Ubuntu. Sometimes the user needs to know the name of the package name of any installed program or command. This task can be done very easily by executing some commands from the terminal. How the user can find out the package name of any installed program or command using command line is shown in this tutorial.
Using app-file command
app-file is a useful command line tool that can be used to search the package name of any installed program of the Ubuntu operating system. This program keeps index of all the packages that are available in system repositories and allows the users to find out the package name by using name of the installed command or programs with keyword that defines the location of the command or program. app-file command is not installed on Ubuntu by default. So you have to install this command first to use it. Press Att+Ctrl+T to open the terminal and write the following command to install it.$ sudo apt-get install apt-file
After installation, execute the following command to update apt-file.$ sudo apt-file update
Suppose, you have to find the package lists of calendar program, type the following command to find the package name list associated with this program.$ sudo apt-file search calendar
Using dpkg command
Another most useful command of Ubuntu operating system is dpkg command. It is a low level tool that is mainly used to install, uninstall or provide information of any debian package file. Without these operations, the user can apply this command for many other purposes. This command can be used as the alternative to app-file command to find the package name of installed program or command. dpkg is installed by default in the Ubuntu operating system. So you don't need to install it. To find the package name using dpkg command you have to write the command like the given format below. Here, the option -S indicates that command is used for searching.dpkg -S
Suppose, you want to know the package name of the mostly used 'cat' command. We know 'cat' command is stored in '/bin' folder. So you have to run the following command using dpkg to find the package name of 'cat' command. It is shown in the output that coreutils is the package name of the 'cat' command.$ dpkg -S /bin/cat
There are many others use of dpkg command related to the package that are shown below. You can check these commands to get many others information about the packages. If you want to know the status information of any package then run dpkg command with - -s and package name.$ dpkg --s coreutils
The output shows the details status information of the status, such as size, version, priority, status, pre-depends package name, commands list under this package etc.
Run the following command if you want to know the list of all installed packages of the system.$ dpkg -l
Installed package list will be shown as output.
Run the following command if you want to count the total number of installed packages. Here, wc command is used to count the total package number.$ dpkg -l|wc -l
You can also use dpkg command to check any package is installed or not. If the particular package is installed then it will show the list of all files related to the package with location. You an use the next command of dpkg to check C shell package is installed or not. The output indicates that C shell is not installed on the system.$ dpkg -L csh
Use the following command to check PERL package is installed or not.$ dpkg -L perl
By default PERL package is installed on Ubuntu. So the following output will appear after the execution of the command.
Using dpkg-query command
dpkg-query command can also search package name of any installed program or command from dpkg database. You can use -S or -search with this command to search any package based on keyword. Suppose if you want to know the package name of the 'nano' command then run the following command.$ dpkg-query -S 'nano'
If the nano program is installed on the system then the following output will appear.
The use of - -search option is shown in the following command where the package name of cp command is searched.$ dpkg-query -search '/bin/cp'
So, you can find out the package name of any installed program and details information about installed packages from command line by using above commands very easily.