Learn GNU/Linux Commands (8): Package Manager - apt, yum/dnf
Most GNU/Linux distributions build every program, every component into a package for users to install on their system. So package management is what makes a distribution different.
We introduce the modern package management tool "apt" for Debian/Ubuntu and "yum/dnf" for Fedora/CentOS/RHEL. These distros are the most popular and their package management tools can be used on distros derived from them.
Fortunately, for "apt" and "yum/dnf", most of their syntax is the same. So we introduce their commands together. The syntax of "yum" and "dnf" is the same, "dnf" is the future.
Note
- Package management tools should be run with administration privileges.
- Package names may not be the same for different distros.
Update List of Available Packages
Debian/Ubuntu
apt update
This command should be run before installing up-to-date packages or upgrading installed packages.
Fedora/CentOS/RHEL
The list of available packages is automatically updated every time "yum/dnf" is called. "yum/dnf update" has the same effect as "yum/dnf upgrade".
For Fedora, the list is also scheduled to auto-update. To disable that, run the following commands.
[root@Fedora ~]# systemctl disable dnf-makecache.service
[root@Fedora ~]# systemctl disable dnf-makecache.timer
Search Package(s)
apt/yum/dnf search STRING
Search STRING in package descriptions.
apt/yum/dnf list STRING
Search STRING in package names.
Install Package(s)
apt/yum/dnf install PACKAGE...
Install the PACKAGE(S). For example, The following commands install Python 2, and header files and static libraries for Python 2 development.
Debian/Ubuntu
[root@Debian ~]# apt install python python-dev
Fedora/CentOS/RHEL
[root@Fedora ~]# dnf install python2 python2-devel
Upgrade Package(s)
apt/yum/dnf Upgrade [PACKAGE]...
Upgrade the PACKAGE(S). If PACKAGE is omitted, upgrade every package installed if a newer version is available.
Remove Package(s)
apt/yum/dnf remove PACKAGE...
Remove the PACKAGE(S).
apt/yum/dnf autoremove
Remove all unneeded packages that were originally installed as dependencies.
Comments
Post a Comment