Gestione Pacchetti Software
Package Installation
Suppose you have heard about a command called figlet
which prints enlarged text on the terminal and you want to try it. However, you get the following message after executing the command figlet
:
$ figlet -bash: figlet: command not found
That probably means the package is not installed on your system. If your distribution works with DEB packages, you can search its repositories using apt-cache search package_name
or apt search package_name
. The apt-cache
command is used to search for packages and to list information about available packages. The following command looks for any occurrences of the term “figlet” in the package’s names and descriptions:
$ apt-cache search figlet figlet - Make large character ASCII banners out of ordinary text
The search identified a package called figlet that corresponds to the missing command. The installation and removal of a package require special permissions granted only to the system’s administrator: the user named root
. On desktop systems, ordinary users can install or remove packages prepending the command sudo
to the installation/removal commands. That will require you to type your password to proceed. For DEB packages, the installation is performed with the command apt-get install package_name
or apt install package_name
:
$ sudo apt-get install figlet Reading package lists... Done Building dependency tree Reading state information... Done The following NEW packages will be installed: figlet 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
At this point the package will be downloaded and installed on the system. Any dependencies that the package eventually needs will also be downloaded and installed:
Need to get 184 kB of archives. After this operation, 741 kB of additional disk space will be used. Get:1 http://archive.raspbian.org/raspbian stretch/main armhf figlet armhf 2.2.5-2 [184 kB] Fetched 184 kB in 0s (213 kB/s) Selecting previously unselected package figlet. (Reading database ... 115701 files and directories currently installed.) Preparing to unpack .../figlet_2.2.5-2_armhf.deb ... Unpacking figlet (2.2.5-2) ... Setting up figlet (2.2.5-2) ... update-alternatives: using /usr/bin/figlet-figlet to provide /usr/bin/figlet (figlet) in auto mode Processing triggers for man-db (2.7.6.1-2) ...
After the download is finished, all files are copied to the proper locations, any additional configuration will be performed and the command will become available:
$ figlet Awesome! _ _ / \__ _____ ___ ___ _ __ ___ ___| | / _ \ \ /\ / / _ \/ __|/ _ \| '_ ` _ \ / _ \ | / ___ \ V V / __/\__ \ (_) | | | | | | __/_| /_/ \_\_/\_/ \___||___/\___/|_| |_| |_|\___(_)
In distributions based on RPM packages, searches are performed using yum search package_name
or dnf search package_name
. Let’s say you want to display some text in a more irreverent way, followed by a cartoonish cow, but you are not sure about the package that can perform that task. As with the DEB packages, the RPM search commands accept descriptive terms:
$ yum search speaking cow Last metadata expiration check: 1:30:49 ago on Tue 23 Apr 2019 11:02:33 PM -03. ==================== Name & Summary Matched: speaking, cow ==================== cowsay.noarch : Configurable speaking/thinking cow
After finding a suitable package at the repository, it can be installed with yum install package_name
or dnf install package_name
:
$ sudo yum install cowsay Last metadata expiration check: 2:41:02 ago on Tue 23 Apr 2019 11:02:33 PM -03. Dependencies resolved. ============================================================================== Package Arch Version Repository Size ============================================================================== Installing: cowsay noarch 3.04-10.fc28 fedora 46 k Transaction Summary ============================================================================== Install 1 Package Total download size: 46 k Installed size: 76 k Is this ok [y/N]: y
Once again, the desired package and all its possible dependencies will be downloaded and installed:
Downloading Packages: cowsay-3.04-10.fc28.noarch.rpm 490 kB/s | 46 kB 00:00 ============================================================================== Total 53 kB/s | 46 kB 00:00 Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Installing : cowsay-3.04-10.fc28.noarch 1/1 Running scriptlet: cowsay-3.04-10.fc28.noarch 1/1 Verifying : cowsay-3.04-10.fc28.noarch 1/1 Installed: cowsay.noarch 3.04-10.fc28 Complete!
The command cowsay
does exactly what its name implies:
$ cowsay "Brought to you by yum" _______________________ < Brought to you by yum > ----------------------- \ ^__^ \ (oo)\_______ (__)\ )\/\ ||----w | || ||
Although they may seem useless, commands figlet
and cowsay
provide a way to draw the attention of other users to relevant information.
Package Removal
The same commands used to install packages are used to remove them. All the commands accept the remove
keyword to uninstall an installed package: apt-get remove package_name
or apt remove package_name
for DEB packages and yum remove package_name
or dnf remove package_name
for RPM packages. The sudo
commando is also needed to perform the removal. For example, to remove the previously installed package figlet from a DEB-based distribution:
$ sudo apt-get remove figlet Reading package lists... Done Building dependency tree Reading state information... Done The following packages will be REMOVED: figlet 0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded. After this operation, 741 kB disk space will be freed. Do you want to continue? [Y/n] Y
After confirming the operation, the package is erased from the system:
(Reading database ... 115775 files and directories currently installed.) Removing figlet (2.2.5-2) ... Processing triggers for man-db (2.7.6.1-2) ...
A similar procedure is performed on an RPM-based system. For example, to remove the previously installed package cowsay from an RPM-based distribution:
$ sudo yum remove cowsay Dependencies resolved. ================================================================================== Package Arch Version Repository Size ================================================================================== Removing: cowsay noarch 3.04-10.fc28 @fedora 76 k Transaction Summary ================================================================================== Remove 1 Package Freed space: 76 k Is this ok [y/N]: y
Likewise, a confirmation is requested and the package is erased from the system:
Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Erasing : cowsay-3.04-10.fc28.noarch 1/1 Running scriptlet: cowsay-3.04-10.fc28.noarch 1/1 Verifying : cowsay-3.04-10.fc28.noarch 1/1 Removed: cowsay.noarch 3.04-10.fc28 Complete!
The configuration files of the removed packages are kept on the system, so they can be used again if the package is reinstalled in the future.