Common linux commands — package management

Time:2021-12-31

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 firefoxorrpm -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 system

EL7 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

  1. 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)
  2. 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(-iInstallation;-vTips;-hProgress 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--nodepsForce 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 nameQuery whether the server has software to be installed, such as:yum list | grep firefox
Yum list installed | grep package nameQuery whether the local has been installed, such as:yum list installed | grep firefox

Install, update

Yum install package nameInstall the specified Yum package, such as:yum install firefox
yum updateUpdate all
yum check-updateCheck updatable programs
Yum update package nameUpdate the specified software, such asyum updata firefox

uninstall

Yum remove package nameDelete the specified RPM package; For example:yum remove firefox

Clear cache

yum clean packagesClear the package in the cache directory
yum clean headersClear headers in cache directory
yum clean oldheadersClear 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 updateGet 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 nameSearch application
sudo apt show packageGet package information
sudo apt source packageDownload the source code of the package to the current directory
sudo apt install package --reinstallReinstall package
sudo apt upgradeUpgrade all upgradeable packages
sudo apt full-upgradeAutomatically handle dependencies when upgrading packages
sudo apt dist-upgradeUpdate packages, add packages and delete packages according to changes in dependencies
sudo apt purgeDelete packages, including configuration files, etc
sudo apt build-dep packageInstall the relevant compilation environment, such as:sudo apt build-dep apache2
sudo apt autoremoveAutomatically delete unwanted packages
sudo apt depends packageUnderstand 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:

  1. Backup source addresscp /etc/apt/sources.list /etc/apt/sources.list.bak
  2. Modify file/etc/apt/sources.list
  3. Get the latest package listsudo apt update

My GitHub
My blog
My notes