Learn how to use the dpkg command to find out where apt installed a package and what is the name of the executable program on Debian and Ubuntu.
If you are using Debian or Ubuntu, you probably know how to use the apt package manager to install, update, and remove packages. But sometimes, you may encounter a problem when you try to run a program that you just installed with apt. You may get an error message saying that the command is not found, or you may not know what is the name of the executable program. In this article, we will show you how to find out where apt installed a package and what is the name of the executable program on Debian and Ubuntu.
Table of Contents
- How apt Installs Packages on Debian and Ubuntu
- Use dpkg to Find the Location of an apt Package
- Use grep to Search for an apt Package
- Frequently Asked Questions (FAQs)
- Question: How do I uninstall a package that I installed with apt?
- Question: How do I update a package that I installed with apt?
- Question: How do I install a local package file that I downloaded from the internet?
- Summary
How apt Installs Packages on Debian and Ubuntu
When you install a package with apt, it downloads the package file from the official repository and extracts the files to the appropriate locations on your system. Usually, the executable programs are placed in the /usr/bin or /usr/sbin directories, which are part of the search path of your shell. The search path is a list of directories that the shell looks for programs when you enter a command. You can see the directories in your search path by examining the $PATH environment variable:
echo $PATH
You will see the directories in your search path separated by a colon (:) character.
However, sometimes the name of the executable program does not match the name of the package, or the program is installed in a different directory that is not in your search path. In that case, you need to use another tool to find out where apt installed the package and what is the name of the executable program.
Use dpkg to Find the Location of an apt Package
The tool that you need to use is dpkg, which is a low-level package manager that can manipulate Debian packages. You can use dpkg to list the files that a package installed on your system, and find the executable program among them. To do that, you need to use the -L (capital L) option with the dpkg command, followed by the name of the package. For example, to examine the firefox-esr package, you can use this command:
dpkg -L firefox-esr
You will see the paths of each file that the package installed, including the executable program. The executable program is typically in a bin directory, which stands for binary. In this case, the executable program is /usr/lib/firefox-esr/firefox-esr, which is a symbolic link to /usr/bin/firefox-esr. A symbolic link is a special file that points to another file or directory. You can run the program by using the full path, or by adding the directory to your search path.
Use grep to Search for an apt Package
Sometimes, you may not know the exact name of the package that you installed, or you may want to search for a specific keyword in the package name or description. In that case, you can use the grep command to filter the output of apt list –installed, which shows all the installed packages on your system. For example, to search for packages that contain the word python, you can use this command:
apt list --installed | grep python
You will see the packages that match your search term, along with their versions and some other information. You can also use regular expressions with grep to refine your search. For example, to search for packages that start with python3, you can use this command:
apt list --installed | grep ^python3
The ^ character means the beginning of the line in regular expressions.
Frequently Asked Questions (FAQs)
Question: How do I uninstall a package that I installed with apt?
Answer: To uninstall a package that you installed with apt, you need to use the apt remove command, followed by the name of the package. For example, to uninstall the firefox-esr package, you can use this command:
sudo apt remove firefox-esr
You may need to enter your password to confirm the operation. This command will remove the package and its configuration files, but it will not remove the dependencies that the package installed. If you want to remove the dependencies as well, you can use the apt autoremove command, which will remove the packages that are no longer needed by any other package.
Question: How do I update a package that I installed with apt?
Answer: To update a package that you installed with apt, you need to use the apt update command, which will refresh the list of available packages from the repository, and then use the apt upgrade command, which will install the newest versions of all the packages that are installed on your system. For example, to update the firefox-esr package, you can use these commands:
sudo apt update
sudo apt upgrade firefox-esr
You may need to enter your password to confirm the operation. These commands will also update the dependencies of the package, if any.
Question: How do I install a local package file that I downloaded from the internet?
Answer: To install a local package file that you downloaded from the internet, you need to use the dpkg -i command, followed by the name of the package file. For example, to install the google-chrome-stable_current_amd64.deb package file, you can use this command:
sudo dpkg -i google-chrome-stable_current_amd64.deb
You may need to enter your password to confirm the operation. This command will install the package and its dependencies, if any. However, if the package has dependencies that are not available on your system, you may get an error message. In that case, you can use the apt -f install command, which will fix the broken dependencies and complete the installation.
Summary
In this article, we learned how to find out where apt installed a package and what is the name of the executable program on Debian and Ubuntu. We also learned how to use dpkg to list the files that a package installed, how to use grep to search for a package, and how to uninstall, update, and install packages with apt and dpkg. We hope that this article was helpful and informative for you.