Common linux commands — package management
RPM
Rpm is the abbreviation of RedHat package manager. It is used as an Internet packaging and installation tool to generate File with RPM extension.
query
Show installed
rpm -qa
Query whether to install
RPM - QA | grep package name
perhapsRPM - Q package name
For example:rpm -qa | grep firefox
orrpm -q firefox
return:firefox-60.2.2-1.el7.centos.x86_64
This passage means:
Firefox: the name of the package
60.2. 2-1: version number
el7. centos. x86_ 64: using operating systemEL7 is red hat 7 x,CentOS 7. X and cloudlinux 7 Download of X. Others, such as El6, el8, etc.
x86_ 64: 64 bit system
If so
- I386 / i686 represents a 32-bit system (i686 is a subset of i386 and only corresponds to CPUs of P6 and above, while i386 is widely applicable to CPUs of 80386 and above)
- Noarch means generic
Query package information
RPM -qi package name
, such as:rpm -qi firefox
Query package files
RPM - QL package name
, such as:rpm -ql firefox
Query the package to which the file belongs
RPM - QF path
, such as:rpm -qf /etc/passwd
install
Path to rpm -ivh package
(-i
Installation;-v
Tips;-h
Progress bar)
uninstall
RPM - e package name
If you are prompted that there is a dependency, it is recommended not to uninstall. Of course, you can also bring it with you--nodeps
Force uninstall.
YUM
Yum is an RPM based shell front-end software manager. You can download and install RPM packages from the specified server. You no longer need to download packages locally in advance like an RPM, and Yum can automatically handle dependencies.
query
Yum list | grep package name
Query whether the server has software to be installed, such as:yum list | grep firefox
Yum list installed | grep package name
Query whether the local has been installed, such as:yum list installed | grep firefox
Install, update
Yum install package name
Install the specified Yum package, such as:yum install firefox
yum update
Update all
yum check-update
Check updatable programs
Yum update package name
Update the specified software, such asyum updata firefox
uninstall
Yum remove package name
Delete the specified RPM package; For example:yum remove firefox
Clear cache
yum clean packages
Clear the package in the cache directory
yum clean headers
Clear headers in cache directory
yum clean oldheaders
Clear old headers in cache directory
APT
Apt is the abbreviation of apt advanced packaging tool. It is the apt package management tool in Debian Linux distribution. All Debian based distributions use this package management system. Deb package can package the files of an application together, which is roughly like the installation files on windows.
install
Note: it is usually necessary to run before installing the softwaresudo apt update
Get the latest package list to ensure that your package list is up-to-date
Sudo apt install package name
uninstall
Sudo apt remove package name
other
Sudo apt serch package name
Search application
sudo apt show package
Get package information
sudo apt source package
Download the source code of the package to the current directory
sudo apt install package --reinstall
Reinstall package
sudo apt upgrade
Upgrade all upgradeable packages
sudo apt full-upgrade
Automatically handle dependencies when upgrading packages
sudo apt dist-upgrade
Update packages, add packages and delete packages according to changes in dependencies
sudo apt purge
Delete packages, including configuration files, etc
sudo apt build-dep package
Install the relevant compilation environment, such as:sudo apt build-dep apache2
sudo apt autoremove
Automatically delete unwanted packages
sudo apt depends package
Understand the dependent packages that use this package
Modify source
The apt source of some Linux distributions (such as Ubuntu) is usually foreign, so it is very slow to install or update software. Usually, we need to modify the image source address.
Some common image sources,Click to view
Steps:
- Backup source address
cp /etc/apt/sources.list /etc/apt/sources.list.bak
- Modify file
/etc/apt/sources.list
- Get the latest package list
sudo apt update