YUM command management
1, YUM common commands
- yum list software name lists rpm -q for each package (both installed and uninstalled)
- View all warehouses using yum repolist
- info query software information rpm -qi
- Reinstall reinstall rpm -ivh
- remove uninstall rpm -e
- provides search
- clean all clear cache
- makecache create cache
1.1 installation package instructions
To install the software, you only need to give the software name
[root@ltt ~]$yum install traceroute
After analyzing dependencies during installation, you can install directly without interaction
[root@ltt ~]$yum install php -y
Install the local rpm package. If there are dependencies, it will automatically download the required dependencies from the software warehouse (not from the software warehouse defined by repo)
[root@ltt ~]$yum localinstall /mnt/Packages/bind-9.11.4-26.P2.el7.x86_64.rpm
Install rpm package on Network
[root@ltt ~]$yum install Add online installation path
1.2 update package instructions
Compare the installed linux software with the software in the yum warehouse. What needs to be upgraded
[root@ltt ~]$yum check-update
Update software
[root@ltt ~]$yum update acl -y
1.3 delete package instruction
Install a samba software first
[root@ltt ~]$yum install -y samba
Deleting the software will not delete the dependency, but we should not use the delete software operation as far as possible.
[root@ltt ~]$yum remove samba -y
1.4 warehouse instructions
Lists the warehouses available from the yum source
[root@ltt ~]$yum repolist View all warehouses
Query which package this file or command belongs to
[root@ltt ~]$yum provides docker // Provides docker is a package that needs to be installed [root@ltt ~]$yum provides /etc/my.cnf [root@ltt ~]$yum provides cd
1.5 cache related commands
Cache yum source software warehouse, xml metadata file
[root@ltt ~]$yum makecache
Cache the package and modify the yum global configuration file
[main] cachedir=/var/cache/yum/$basearch/$releasever keepcache=1 // Start cache
View cached xml files
[root@ltt ~]$ls /var/cache/yum/x86_64/7/
Another way to cache rpm packets
1. Install the plug-in. Only download the software package but not install it
[root@ltt ~]$yum install -y yum-plugin-downloadonly
2. Download the software to the specified directory
[root@ltt ~]$yum install -y yum-plugin-downloadonly --downloaddir=/tmp
Clear all yum caches
[root@ltt ~]$yum clean all
Clear cached packages only
[root@ltt ~]$yum clean packages
1.6 package group management instruction
Lists all installed and available software groups
[root@ltt ~]$yum group list
Install an entire set of software
[root@ltt ~]$yum groups install Development tools \Compatibility libraries\
Delete group using yum or up2date
[root@ltt ~]$ yum groups remove -y Base
1.7 history command
View history execute yum command
[root@ltt ~]$yum history
Query history execution yum named ID details
[root@ltt ~]$yum history info N
Undo historically executed yum commands
[root@ltt ~]$yum history undo N
1.8 global configuration file
[root@ltt ~]$vim /etc/yum.conf [main] cachedir=/var/cache/yum/$basearch/$releasever keepcache=1 //When the cache is enabled, the download package will be cached for each installation, and yum clean will be cleared. debuglevel=2 logfile=/var/log/yum.log exactarch=1 obsoletes=1 gpgcheck=1 plugins=1 installonly_limit=5 bugtracker_url=http://bugs.centos.org/set_project.php?project_id=23&ref=http://bugs.centos.org/bug_report_page.php?category=yum distroverpkg=centos-release
2, Build enterprise intranet online update
1. Configure the server:
1. The server builds the corresponding yum database directly
Alibaba cloud Network Library
base Library:
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
epel Library:
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
ngxin Library
// Create nginx file [root@ltt yum.repos.d]$vim /etc/yum.repos.d/nginx.repo // Configure nginx.repo [nginx] name=nginx repo baseurl=http://nginx.org/packages/centos/7/$basearch/ gpgcheck=0 enabled=1
Set up ftp
1. Install vsftp
yum install -y vsftpd
2. Close selinux
Temporarily Closed
setenforce 0
Permanent shutdown
vim /etc/selinux/config
3. Turn off the firewall
Temporarily Closed
systemctl stop firewalld
Permanent shutdown
systemctl disable firewalld
4. Start ftp service
systemctl start vsftpd systemctl enable vsftpd
5. Create the directory corresponding to the yum warehouse
mkdir /var/ftp/{base,update,nginx}
2. Build base, update and nginx library resources respectively
1.base Library
rpm Package from CD mount /dev/cdrom /mnt cp -rf /mnt/* /var/ftp/base
2.update library
rpm Package source: alicloud yum update -y --downloadonly find /var/cache/yum/x86_64/7 -name "*.rpm" -exec cp {} /var/ftp/update \; createrepo /var/ftp/update
3.ngxin Library:
The rpm package comes from the official website of ngxin
yum clean all yum install nginx -y --downloadonly find /var/cache/yum/x86_64/7 -name "*.rpm" -exec cp {} /var/ftp/nginx \;
Install createrpo and create reopdat createrepo / var / ftp / nginx
3. Install createrepo and create reopdata
Installation:
yum -y install createrepo
Generate warehouse information
createrepo /var/ftp/update
Successfully created view information:
[root@ltt ftp]$createrepo /var/ftp/update Spawning worker 0 with 107 pkgs Workers Finished Saving Primary metadata Saving file lists metadata Saving other metadata Generating sqlite DBs Sqlite DBs complete
One more directory: repodata
Entering the directory, there will be a repomd.xml file
4. Client configuration:
1. Close selinux and firewall and configure the same as the server
2. Configure yum library file
rm -f /etc/yum.repo.d/*.repo base library cat > /etc/yum.repos.d/base.repo<<EOF [base] name=base repo baseurl=ftp://10.0.0.200/base gpgcheck=0 enabled=1 EOF
update library:
cat > /etc/yum.repos.d/update.repo<<EOF [update] name=base repo baseurl=ftp://10.0.0.200/update gpgcheck=0 enabled=1 EOF
nginx Library:
cat > /etc/yum.repos.d/nginx.repo<<EOF [nginx] name=base repo baseurl=ftp://10.0.0.200/nginx gpgcheck=0 enabled=1 EOF
3, Source installation package management
1. Basic overview of source package
The compiler in linux system is used to compile the source package. Usually, the source package is developed in C language, which is also because C language is the most standard program language on linux
The C language compiler on Linux is called gcc, which can be used to turn C language into executable binary files
If gcc is not installed on your machine, there is no way to compile the source code. You can use yum install -y gcc to complete the installation
2. How to obtain the source code package
nginx official website downloads are generally tar packages
[root@ltt ~]$wget https://nginx.org/download/nginx-1.21.3.tar.gz
How to install the source package
Compilation environment gcc, make
Dependent environment pcre, openssl
Prepare the corresponding software, such as nginx-1.21.3.tar.gz
3. Decompression
tar xf nginx-1.21.3.tar.gz
4. Configure. / configure
1. Installation path
2. Function module: detect dependencies
3. Generate makefile cd nginx-1.21.3
4. Compile make
Compile the source code into binary according to the contents on the makefile
5. Install make install
. / configure --prefix=/sort/nginx-1.21.3 dependent packages during compilation are generally:
- yum -y install gcc
- yum -y install make
- yum -y install pcre-devel
- yum -y install zlib-devel
installation is complete
echo $?
A return of 0 indicates that the installation was successful
When executing make, as long as there is no error when executing the script above, there will be no error here
Finally, execute make install to complete the installation
Check whether the installation is successful: cd /sort/nginx-1.21.3
If the four directories conf html logs sbin appear, the installation is successful