- Installing software using dpkg
- Removing software using dpkg in Debian
- List programs using dpkg in Debian
- List files belonging to a program using dpkg
- Show installation directories using dpkg
- apt repositories
- Install software using apt
- Remove software using apt
- Searching packages using apt
- Listing packages using apt
- apt troubleshooting
- Installing software with aptitude
- Updating repositories using aptitude
- Removing software with aptitude
- Upgrading software using aptitude
- Related articles on LinuxHint
dpkg is the Linux Debian packages manager. When apt or apt-get are used they invoke the dpkg program to install or remove applications while including additional functions dpkg doesn’t like dependencies resolution. The program dpkg can be used to install or remove programs, list them or specific information on them.
Note: To show examples the package net-tools will be used, you use any .deb package, to use the net-tools package on the terminal run:
Installing software using dpkg Debian:
To install packages use the parameter -i (install):
Note: replace <PackageName> for your .deb package.
Removing software using dpkg in Debian:
The remove packages the parameter –remove is needed as in the example below:
List programs using dpkg in Debian:
To print a list of installed packages use the parameter -l (list):
Search packages or files belonging to programs using dpkg in Debian:
The -s (search) parameter is useful to search specific packages but this command will also display software metadata.
List files belonging to a program using dpkg:
With the dpkg command you can list all files associated or belonging to an installed package by using the -L parameter:
Show installation directories using dpkg:
Before installing a new package we can know it’s installation directories by using the -c parameter:
The command apt is advantageous over dpkg because it resolves dependencies and downloads updated software automatically. To download software this command points to a series of software repositories located in the file /etc/apt/sources.list. Initially after installing Debian we need to edit this file commenting the line pointing to Debian DVD/USB installation path and adding the proper repositories.
The apt command uses the dpkg program to manage packages.
You can edit the sources.list file using nano and you can read it by running:
In my case for Debian Stretch the file /etc/apt/sources.list should have all lines commented except for lines:
deb-src http://deb.debian.org/debian stretch main
deb http://deb.debian.org/debian-security/ stretch/updates main
deb-src http://deb.debian.org/debian-security/ stretch/updates main
deb-src http://deb.debian.org/debian stretch-updates main
When updating the apt as I show later in this tutorial, all repositories on the sources.list and under the /etc/apt/ directory will be included, you add add new files with additional repositories instead of editing the sources.list file.
Install software using apt:
Installing software using apt requires the option install previous to the program’s name. To try apt install the package manager aptitude used in future instructions.
Note: you can add the option -y to avoid being asked for confirmation when installing programs.
Removing software using apt:
To remove packages with the apt command run:
Note: also when removing software you can use the option -y to avoid being asked for confirmation.
Search packages using apt:
Using the option search you can look for specific packages, in the following image nikto is search, to search a package type:
Listing packages using apt:
You can list installed packages by executing:
Sometimes due to bad software removal or similar issues apt may fail, it has some commands to fix common apt package manager problems.
apt-get -f install
apt-get --fix-missing install
apt-get --purge autoremove
The aptitude packages managers works similarly to apt. It also allows to download and install software and has an interactive mode within the terminal. This package manager has an interactive mode which allows to see and browse packages by status, install and remove packages. It can also be used from the command line with similar options to the apt package manager, aptitude uses the same repositories apt does. To see the interactive mode just call the program running the command aptitude without additional options in the console.
To quit the interactive mode, just press Q and confirm pressing Y.
To update your repositories using aptitude you can run:
Install packages using aptitude:
Similarly to apt, to install software using aptitude you can run:
Remove packages using aptitude:
Search packages using aptitude:
To search packages with aptitude we can use commands or the interactive console running “aptitude” without options as mentioned before. To search packages from the command line run:
List packages using aptitude:
Aptitude can also be used to list programs in the following way:
Upgrading with aptitude:
To upgrade software using aptitude run:
Just as with apt, when using aptitude you can add the -y option to prevent being asked for installation removal or upgrade confirmation.
That’s basically what you need to know to manage packages on Debian, if you have any inquiry on Linux in general contact us through our support channel at https://support.linuxhint.com or through twitter @linuxhint.