Posts Tagged ‘Debian’
Build Debian Packages From Source
Debian and Debian-based systems like Ubuntu uses Advanced Package Tool, or APT in short, for installing, updating, upgrading and removing software from command line. Usually, the APT package manager stores the list of repositories in the file named /etc/apt/sources.list and in any file with the suffix .list under the directory /etc/apt/sources.list.d/. When we install a package, apt command retrieves the binary or pre-compiled version of the given package from these repositories. In addition to installing binary packages, APT can also lets you to download the source code of a package. So you can then add some features in the source, build the package from the source code, and finally install the modified version of the package. This guide explains how to build debian packages from source on Debian, Ubuntu and other APT-based systems like Linux Mint.
Why should we build a package from source?
There could be many reasons to build a package from source. Here are a few reasons I could think of now:
- Inspect the source code to find a bug.
- Add new features in the packages that aren’t being actively developed any longer.
- Install the most recent version of a package from source. Generally, the packages in the official repositories might be bit old.
- And more importantly – learn to build Debian packages from source.
Build Debian Package From Source Tarball, Build Debian Package From Tarball, Build Debian Packages, Build-essential Package Debian Install, Debian Build Package Install, How To Build Debian Packages, Ubuntu Build Debian Source Package
List Installed Packages on Debian
Apt is a command-line interface for the package management system and combines the most commonly used functionalities from apt-get
and apt-cache
including option to list installed packages.
To lists all packages installed on your system run the following command:
sudo apt list --installed
adduser/stable,now 3.115 all [installed] apt/stable,now 1.4.8 amd64 [installed] apt-listchanges/stable,now 3.10 all [installed] apt-utils/stable,now 1.4.8 amd64 [installed] autoconf/stable,now 2.69-10 all [installed] automake/stable,now 1:1.15-6 all [installed] autotools-dev/stable,now 20161112.1 all [installed,automatic] base-files/stable,now 9.9+deb9u5 amd64 [installed] base-passwd/stable,now 3.5.43 amd64 [installed] bash/stable,now 4.4-5 amd64 [installed]
The command will display a list of all installed packages including information about the packages versions and architecture. The rightmost column in the output shows whether the package was automatically installed as dependency of another package.
Since the packages list is long it is a good idea to pipe the output to the less
command to make it easier to read:
sudo apt list --installed | less
To find out whether a specific package is installed use the grep command to filter the output. For example to find whether the tmux package is installed on the system you can use:
sudo apt list --installed | grep tmux
tmux/stable,now 2.3-4 amd64 [installed]
The output above shows that you have screen tmux 2.3-4 installed on your system.
List Installed Packages with dpkg-query
dpkg-query
is a command line that can be used to display information about packages listed in the dpkg database.
To get a list of all installed packages type:
sudo dpkg-query -l | less

The command will display a list of all installed packages including the packages versions, architecture and short description.
You can filter the dpkg-query -l
output using the grep
command:
sudo dpkg-query -l | grep package_name_to_search
Create a List of all Installed Packages
The following command will store the list of all installed packages on your Debian system to a file called packages_list.txt
:
sudo dpkg-query -f '${binary:Package}n' -W > packages_list.txt
Now that you have the list, you can install the same packages on your new server with:
sudo xargs -a packages_list.txt apt install
To find out how many packages are installed on your system you can use the same command as when creating a packages list but instead of redirecting the output to a file you can pipe it to the wc
command to count the lines:
sudo dpkg-query -f '${binary:Package}n' -W | wc -l
The output will show the number of the installed packages:
466
Read More
Apt-get Add Repository
Debian Apt, Debian Linux, Debian Or Ubuntu, Debian Packages, Debian Ubuntu