Installing and Removing Software: Working with Package Managers
In the Linux world, software is usually distributed as packages stored in repositories. Special tools called package managers are used to manage these packages.
On Debian and Ubuntu systems, you can use the apt-get and apt-cache tools. Basic operations such as installing, updating and removing are performed with apt-get (many of them require superuser privileges), while apt-cache works with the local cache and is used to search for packages and get information about them. Newer versions of these operating systems also provide the apt tool, which combines the functions of both. The command syntax stays the same, and you can use apt instead of apt-get or apt-cache in all the examples below.
On CentOS and Bitrix, packages are managed with yum.
Updating the package database
Before doing anything with apt-get or yum, it is recommended to update the local package cache to match the current state of the repository:
Debian / Ubuntu
sudo apt-get update
CentOS / Bitrix
yum check-update
Searching for packages
If you are not sure of the exact package name, you can search the repository by keyword. The search covers both package names and descriptions.
Debian / Ubuntu
apt-cache search search_term
CentOS / Bitrix
yum search search_term
Getting package information
If you want to learn more details before installing, such as the program version, package size and dependency information, you can view information about the package:
Debian / Ubuntu
apt-cache show package_name
CentOS / Bitrix
yum info package_name
Installing packages
To install a package, just run one simple command:
Debian / Ubuntu
sudo apt-get install package_name
CentOS / Bitrix
sudo yum install package_name
You can also install several packages at once by listing them separated by spaces:
Debian / Ubuntu
sudo apt-get install package_name1 package_name2 package_name3
CentOS / Bitrix
sudo yum install package_name1 package_name2 package_name3
If you need to install a specific version of a package, specify the version after the package name:
Debian / Ubuntu
sudo apt-get install package_name=version
CentOS / Bitrix
sudo yum install package_name-version
To automatically confirm all system prompts during installation, add the -y flag:
Debian / Ubuntu
sudo apt-get install -y package_name
CentOS / Bitrix
sudo yum install -y package_name
Updating installed packages
To update installed packages to their latest versions, run the following command:
Debian / Ubuntu
sudo apt-get upgrade
CentOS / Bitrix
sudo yum update
Removing packages
To remove an installed application, use the following commands:
Debian / Ubuntu
sudo apt-get remove package_name
CentOS / Bitrix
sudo yum remove package_name
On Debian / Ubuntu systems, you can also automatically remove packages that are no longer needed to free up space. The system identifies them as packages that were installed as dependencies of other packages that have since been removed.
sudo apt-get autoremove