linux软件包管理

Posted Qiao_Zhi

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了linux软件包管理相关的知识,希望对你有一定的参考价值。

 

管理方式大致分为下面几类:

  1. 二进制软件包管理(RPM,YUM)-----redhat系列linux系列
  2. 源代码安装包
  3. 脚本安装(shell脚本或者Java脚本)
  4. Debian系列linux软件包管理

 

 linux中所有的软件与配置文件都是通过二进制包软件的形式进行安装。

 

一、RPM包管理

1.一个rpm软件包的例子

   sudo-1.7.2p1-5.el5.i386.rpm

  其中软件包(sudo),版本号为1.7.2pl,发行号为 5.el5 ,硬件平台为i386.

 

  • (1)卸载软件:

  rpm -e sudo

  注意:如果其他软件包有依赖关系,卸载时会产生提示信息,可以用 --nodeps 强行卸载。

  

   卸载的时候使用软件名,安装的时候使用软件的全名。

  • (2)查询:
[root@iz2ze46xi6pjjj69ailg9lz ~]# rpm -q zip #查看一个软件包是否安装在系统中
package zip is not installed
[root@iz2ze46xi6pjjj69ailg9lz ~]# rpm -qa |grep zip #查询所有的软件包,并根据关键字过滤
perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64
bzip2-libs-1.0.6-13.el7.x86_64
gzip-1.5-8.el7.x86_64
[root@iz2ze46xi6pjjj69ailg9lz ~]#

 

[root@VM_0_12_centos ~]# rpm -q zip
zip-3.0-10.el7.x86_64

 

    • (3)安装:  (需要有rpm安装包才可以安装,更新的时候也需要rpm包)

  rpm -ivh  sudo-1.7.2p1-5.el5.i386.rpm

 

其他安装选项:

A:常用附加选项:

--execludedocs    过滤掉操作文档

--prefix PATH    将软件包安装到指定的目录下(一般不需要指定,源码一般指定默认的安装路径)

--test: 只对安装进行测试,并不进行实际安装。

 

 --replacepkgs  覆盖安装该软件包

 

 

 

 

 

  • (4)更新rpm软件包

 

 

 

  • (5)rpm重要的查询功能

  -a   查询所有已经安装的软件包

  -f  查询一个文件所属的软件包

  -p  查询软件包信息(此包还没有安装,查看的时候加p选项,参数为完整的包名)  

  -i  查询软件包信息(已经安装的包)

  -l  显示软件包中的文件列表

  -d  显示被标注为文档的文件列表

  -c  显示被标注为配置文件的文件列表

例如:

  0.查询已经安装的软件包:

[root@VM_0_12_centos ~]# rpm -qa |grep vim  #查询与vim相关的软件包,不加过滤操作会查询所有的
vim-common-7.4.160-1.el7_3.1.x86_64      #安装包名称
vim-filesystem-7.4.160-1.el7_3.1.x86_64      #安装包名称
vim-minimal-7.4.160-1.el7_3.1.x86_64         #安装包名称
vim-enhanced-7.4.160-1.el7_3.1.x86_64      #安装包名称

 

  1.查询文件所属的软件包:   rpm -qf 

[root@VM_0_12_centos ~]# rpm -qf /bin/ls
coreutils-8.22-15.el7.x86_64
[root@VM_0_12_centos ~]# rpm -qf /etc/services
setup-2.8.71-6.el7.noarch

 

 

  2.查询软件包信息   rpm-qi

[root@VM_0_12_centos ~]# rpm -qi sudo(也可以跟安装包名称)
Name        : sudo
Version     : 1.8.19p2
Release     : 11.el7_4
Architecture: x86_64
Install Date: Thu 29 Mar 2018 02:39:37 PM CST
Group       : Applications/System
Size        : 4051627
License     : ISC
Signature   : RSA/SHA256, Thu 07 Sep 2017 08:55:02 PM CST, Key ID 24c6a8a7f4a80e
b5
Source RPM  : sudo-1.8.19p2-11.el7_4.src.rpm
Build Date  : Thu 07 Sep 2017 10:26:09 AM CST
Build Host  : c1bm.rdu2.centos.org
Relocations : (not relocatable)
Packager    : CentOS BuildSystem <http://bugs.centos.org>
Vendor      : CentOS
URL         : http://www.courtesan.com/sudo/
Summary     : Allows restricted root access for specified users
Description :
Sudo (superuser do) allows a system administrator to give certain
users (or groups of users) the ability to run some (or all) commands
as root while logging all commands and arguments. Sudo operates on a
per-command basis.  It is not a replacement for the shell.  Features
include: the ability to restrict what commands a user may run on a
per-host basis, copious logging of each command (providing a clear
audit trail of who did what), a configurable timeout of the sudo
command, and the ability to use the same configuration file (sudoers)
on many different machines.

 

  3.查询一个软件包安装了哪些文件

[root@VM_0_12_centos ~]# rpm -ql sudo
/etc/pam.d/sudo
/etc/pam.d/sudo-i
/etc/sudo-ldap.conf
/etc/sudo.conf
/etc/sudoers
/etc/sudoers.d
/usr/bin/sudo
/usr/bin/sudoedit
/usr/bin/sudoreplay
/usr/lib/tmpfiles.d/sudo.conf
/usr/libexec/sudo/group_file.so
/usr/libexec/sudo/libsudo_util.so
/usr/libexec/sudo/libsudo_util.so.0
/usr/libexec/sudo/libsudo_util.so.0.0.0
/usr/libexec/sudo/sesh
/usr/libexec/sudo/sudo_noexec.so
/usr/libexec/sudo/sudoers.so
/usr/libexec/sudo/system_group.so
/usr/sbin/visudo
/usr/share/doc/sudo-1.8.19p2
/usr/share/doc/sudo-1.8.19p2/CONTRIBUTORS
/usr/share/doc/sudo-1.8.19p2/ChangeLog
/usr/share/doc/sudo-1.8.19p2/HISTORY
/usr/share/doc/sudo-1.8.19p2/LICENSE
/usr/share/doc/sudo-1.8.19p2/NEWS
/usr/share/doc/sudo-1.8.19p2/README
/usr/share/doc/sudo-1.8.19p2/README.LDAP
/usr/share/doc/sudo-1.8.19p2/TROUBLESHOOTING
/usr/share/doc/sudo-1.8.19p2/UPGRADE
/usr/share/doc/sudo-1.8.19p2/examples
/usr/share/doc/sudo-1.8.19p2/examples/pam.conf
/usr/share/doc/sudo-1.8.19p2/examples/sudo.conf
/usr/share/doc/sudo-1.8.19p2/examples/sudoers
/usr/share/doc/sudo-1.8.19p2/examples/syslog.conf
/usr/share/doc/sudo-1.8.19p2/schema.ActiveDirectory
/usr/share/doc/sudo-1.8.19p2/schema.OpenLDAP
/usr/share/doc/sudo-1.8.19p2/schema.iPlanet
/usr/share/doc/sudo-1.8.19p2/sudoers2ldif
/usr/share/locale/ca/LC_MESSAGES/sudo.mo
/usr/share/locale/ca/LC_MESSAGES/sudoers.mo
/usr/share/locale/cs/LC_MESSAGES/sudo.mo
/usr/share/locale/cs/LC_MESSAGES/sudoers.mo
/usr/share/locale/da/LC_MESSAGES/sudo.mo
/usr/share/locale/da/LC_MESSAGES/sudoers.mo
/usr/share/locale/de/LC_MESSAGES/sudo.mo
/usr/share/locale/de/LC_MESSAGES/sudoers.mo
/usr/share/locale/el/LC_MESSAGES/sudoers.mo
/usr/share/locale/eo/LC_MESSAGES/sudo.mo
/usr/share/locale/eo/LC_MESSAGES/sudoers.mo
/usr/share/locale/es/LC_MESSAGES/sudo.mo
/usr/share/locale/eu/LC_MESSAGES/sudo.mo
/usr/share/locale/eu/LC_MESSAGES/sudoers.mo
/usr/share/locale/fi/LC_MESSAGES/sudo.mo
/usr/share/locale/fi/LC_MESSAGES/sudoers.mo
/usr/share/locale/fr/LC_MESSAGES/sudo.mo
/usr/share/locale/fr/LC_MESSAGES/sudoers.mo
/usr/share/locale/gl/LC_MESSAGES/sudo.mo
/usr/share/locale/hr/LC_MESSAGES/sudo.mo
/usr/share/locale/hr/LC_MESSAGES/sudoers.mo
/usr/share/locale/hu/LC_MESSAGES/sudo.mo
/usr/share/locale/hu/LC_MESSAGES/sudoers.mo
/usr/share/locale/it/LC_MESSAGES/sudo.mo
/usr/share/locale/it/LC_MESSAGES/sudoers.mo
/usr/share/locale/ja/LC_MESSAGES/sudo.mo
/usr/share/locale/ja/LC_MESSAGES/sudoers.mo
/usr/share/locale/ko/LC_MESSAGES/sudo.mo
/usr/share/locale/ko/LC_MESSAGES/sudoers.mo
/usr/share/locale/lt/LC_MESSAGES/sudoers.mo
/usr/share/locale/nb/LC_MESSAGES/sudo.mo
/usr/share/locale/nb/LC_MESSAGES/sudoers.mo
/usr/share/locale/nl/LC_MESSAGES/sudo.mo
/usr/share/locale/nl/LC_MESSAGES/sudoers.mo
/usr/share/locale/nn/LC_MESSAGES/sudo.mo
/usr/share/locale/pl/LC_MESSAGES/sudo.mo
/usr/share/locale/pl/LC_MESSAGES/sudoers.mo
/usr/share/locale/pt_BR/LC_MESSAGES/sudo.mo
/usr/share/locale/pt_BR/LC_MESSAGES/sudoers.mo
/usr/share/locale/ru/LC_MESSAGES/sudo.mo
/usr/share/locale/ru/LC_MESSAGES/sudoers.mo
/usr/share/locale/sk/LC_MESSAGES/sudo.mo
/usr/share/locale/sk/LC_MESSAGES/sudoers.mo
/usr/share/locale/sl/LC_MESSAGES/sudo.mo
/usr/share/locale/sl/LC_MESSAGES/sudoers.mo
/usr/share/locale/sr/LC_MESSAGES/sudo.mo
/usr/share/locale/sr/LC_MESSAGES/sudoers.mo
/usr/share/locale/sv/LC_MESSAGES/sudo.mo
/usr/share/locale/sv/LC_MESSAGES/sudoers.mo
/usr/share/locale/tr/LC_MESSAGES/sudo.mo
/usr/share/locale/tr/LC_MESSAGES/sudoers.mo
/usr/share/locale/uk/LC_MESSAGES/sudo.mo
/usr/share/locale/uk/LC_MESSAGES/sudoers.mo
/usr/share/locale/vi/LC_MESSAGES/sudo.mo
/usr/share/locale/vi/LC_MESSAGES/sudoers.mo
/usr/share/locale/zh_CN/LC_MESSAGES/sudo.mo
/usr/share/locale/zh_CN/LC_MESSAGES/sudoers.mo
/usr/share/man/man5/sudo-ldap.conf.5.gz
/usr/share/man/man5/sudo.conf.5.gz
/usr/share/man/man5/sudoers.5.gz
/usr/share/man/man5/sudoers.ldap.5.gz
/usr/share/man/man8/sudo.8.gz
/usr/share/man/man8/sudoedit.8.gz
/usr/share/man/man8/sudoreplay.8.gz
/usr/share/man/man8/visudo.8.gz
/var/db/sudo
/var/db/sudo/lectured

 

 

  4.查询一个安装包的帮助文档:

[root@VM_0_12_centos ~]# rpm -qd zip
/usr/share/doc/zip-3.0/CHANGES
/usr/share/doc/zip-3.0/LICENSE
/usr/share/doc/zip-3.0/README
/usr/share/doc/zip-3.0/README.CR
/usr/share/doc/zip-3.0/TODO
/usr/share/doc/zip-3.0/WHATSNEW
/usr/share/doc/zip-3.0/WHERE
/usr/share/doc/zip-3.0/algorith.txt
/usr/share/man/man1/zip.1.gz
/usr/share/man/man1/zipcloak.1.gz
/usr/share/man/man1/zipnote.1.gz
/usr/share/man/man1/zipsplit.1.gz

 

 

  5.查看一个安装包的配置文件:

[root@VM_0_12_centos ~]# rpm -qc sudo
/etc/pam.d/sudo
/etc/pam.d/sudo-i
/etc/sudo-ldap.conf
/etc/sudo.conf
/etc/sudoers
  •  (6)软件包校验   rpm -V  软件包名称

    5   文件的md5校验值

    S    文件大小

    L    链接文件

    T  文件的创建时间

    D    设备文件

    U    文件的用户

    G    文件的用户组

    M    文件的权限

例如:

1.查看zip的帮助文件的目录

[root@VM_0_12_centos ~]# rpm -qd zip
/usr/share/doc/zip-3.0/CHANGES
/usr/share/doc/zip-3.0/LICENSE
/usr/share/doc/zip-3.0/README
/usr/share/doc/zip-3.0/README.CR
/usr/share/doc/zip-3.0/TODO
/usr/share/doc/zip-3.0/WHATSNEW
/usr/share/doc/zip-3.0/WHERE
/usr/share/doc/zip-3.0/algorith.txt
/usr/share/man/man1/zip.1.gz
/usr/share/man/man1/zipcloak.1.gz
/usr/share/man/man1/zipnote.1.gz
/usr/share/man/man1/zipsplit.1.gz

 

 

2.添加一行注释

[root@VM_0_12_centos ~]# vim /usr/share/doc/zip-3.0/README

 

3.校验zip命令

[root@VM_0_12_centos ~]# rpm -V zip
S.5....T.  d /usr/share/doc/zip-3.0/README

 

S代表大小改变,5代表md5值改变,T代表创建时间改变

 

[root@VM_0_12_centos ~]# ls -l /usr/share/doc/zip-3.0/README
-rw-r--r-- 1 root root 12754 Mar 29 16:08 /usr/share/doc/zip-3.0/README

 

 

  • 软件包文件提取:

 

加入etc/inittab文件丢失

(1)查询inittab是所属的安装包

[root@VM_0_12_centos ~]# rpm -qf /etc/inittab
initscripts-9.49.37-1.el7.x86_64

 

(2)从二进制包中提取数据:

 rpm2cpio .........  (上面第二条指令)

 

 

 

 

 

注意:每个文件都有一个md5加密值:

 1.创建一个文件并测试其md5值

[root@VM_0_12_centos ~]# echo "this is test" > test.txt
[root@VM_0_12_centos ~]# ls
anaconda-ks.cfg  Maildir  test.txt
[root@VM_0_12_centos ~]# md5sum test.txt
01bcb1fe182a23a65c5efe8326250da8  test.txt

 

 

修改文件再次查看器md5值

[root@VM_0_12_centos ~]# echo "this is test" >> test.txt
[root@VM_0_12_centos ~]# md5sum test.txt
07fcec7339bb875d18293a369a18ddb5  test.txt

 

 

 

 

 二、yum管理:

  好处:(1)可以自动解决软件包的软件依赖

    (2)更新软件的时候方便,不用下载rpm包再更新

 命令简介:

  安装:yum install

  检测升级:   yum check-update

  升级:yum update

  软件包查询: yum list

  卸载: yum remove

  帮助:yum -help,man yum 

  

1安装软件:

[root@VM_0_12_centos ~]# yum install sudo  #安装sudo软件
Loaded plugins: fastestmirror, langpacks
epel                                                     | 4.7 kB     00:00

extras                                                   | 3.4 kB     00:00

os                                                       | 3.6 kB     00:00

updates                                                  | 3.4 kB     00:00

Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package sudo.x86_64 0:1.8.6p7-23.el7_3 will be updated
---> Package sudo.x86_64 0:1.8.19p2-11.el7_4 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================

 Package      Arch           Version                      Repository       Size
================================================================================

Updating:
 sudo         x86_64         1.8.19p2-11.el7_4            updates         1.1 M

Transaction Summary
================================================================================

Upgrade  1 Package                    #提示更新了1个包

Total download size: 1.1 M
Is this ok [y/d/N]: y
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
sudo-1.8.19p2-11.el7_4.x86 21% [===             ]  0.0 B/s | 232 kB   --:-- ETA
sudo-1.8.19p2-11.el7_4.x86 96% [=============== ] 1.0 MB/s | 1.0 MB   00:00 ETA
sudo-1.8.19p2-11.el7_4.x86_64.rpm                          | 1.1 MB   00:00

Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : sudo-1.8.19p2-11.el7_4.x86_64                                1/2

  Cleanup    : sudo-1.8.6p7-23.el7_3.x86_64                                 2/2

  Verifying  : sudo-1.8.19p2-11.el7_4.x86_64                                1/2

  Verifying  : sudo-1.8.6p7-23.el7_3.x86_64                                 2/2


Updated:                    #提示更新了软件
  sudo.x86_64 0:1.8.19p2-11.el7_4


Complete!
[root@VM_0_12_centos ~]#

 

这时候我们可以用rpm查询sudo的版本:

[root@VM_0_12_centos ~]# rpm -q sudo
sudo-1.8.19p2-11.el7_4.x86_64

 

 

利用rpm删除sudo之后重新安装:

[root@VM_0_12_centos ~]# rpm -e sudo    #删除sudo
[root@VM_0_12_centos ~]# yum install sudo  #用yum重新安装
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package sudo.x86_64 0:1.8.19p2-11.el7_4 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================

 Package      Arch           Version                      Repository       Size
================================================================================

Installing:
 sudo         x86_64         1.8.19p2-11.el7_4            updates         1.1 M

Transaction Summary
================================================================================

Install  1 Package

Total download size: 1.1 M
Installed size: 3.9 M
Is this ok [y/d/N]: y
Downloading packages:
sudo-1.8.19p2-11.el7_4.x86 27% [====            ]  0.0 B/s | 295 kB   --:-- ETA
sudo-1.8.19p2-11.el7_4.x86 91% [==============- ] 885 kB/s | 997 kB   00:00 ETA
sudo-1.8.19p2-11.el7_4.x86_64.rpm                          | 1.1 MB   00:00

Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
  Installing : sudo-1.8.19p2-11.el7_4.x86_64                                1/1

  Verifying  : sudo-1.8.19p2-11.el7_4.x86_64                                1/1


Installed:
  sudo.x86_64 0:1.8.19p2-11.el7_4


Complete!

 

 

2.更新软件。

  yum check-update command   检测升级包 (这步可以省略)

  yum update command    升级软件(如果不加命令会升级所有的软件)

(1).检查升级包:

[root@VM_0_12_centos ~]# yum check-update zip
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile

zip.x86_64                             3.0-11.el7                             os

 

(2)升级前查看zip版本:

[root@VM_0_12_centos ~]# rpm -q zip
zip-3.0-10.el7.x86_64

 

(3)开始升级:(当然上面两步也可以直接省略)

[root@VM_0_12_centos ~]# yum update zip
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package zip.x86_64 0:3.0-10.el7 will be updated
---> Package zip.x86_64 0:3.0-11.el7 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

===============================================================================

 Package         Arch               Version                Repository      Size
===============================================================================

Updating:
 zip             x86_64             3.0-11.el7             os             260 k

Transaction Summary
===============================================================================

Upgrade  1 Package

Total download size: 260 k
Is this ok [y/d/N]: y
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
zip-3.0-11.el7.x86_64.rpm                                  | 260 kB   00:00

Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : zip-3.0-11.el7.x86_64                                        1/2

  Cleanup    : zip-3.0-10.el7.x86_64                                        2/2

  Verifying  : zip-3.0-11.el7.x86_64                                        1/2

  Verifying  : zip-3.0-10.el7.x86_64                                        2/2


Updated:
  zip.x86_64 0:3.0-11.el7


Complete!

 

(4)查看升级后的软件版本:

[root@VM_0_12_centos ~]# rpm -q zip
zip-3.0-11.el7.x86_64

 

 

3.查看软件包信息:

1.yum list   查看yum源上的所有信息:

[root@VM_0_12_centos ~]# yum list | grep sudo  #查看源上的所有软件包
sudo.x86_64                             1.8.19p2-11.el7_4              @updates

libsss_sudo.x86_64                      1.15.2-50.el7_4.11             updates

lxqt-sudo.x86_64                        0.11.1-3.el7                   epel

lxqt-sudo-l10n.noarch                   0.11.2-3.el7                   epel

sudo-devel.x86_64                       1.8.19p2-11.el7_4              updates

 

 

2.yum info command   查看软件包的信息

[root@VM_0_12_centos ~]# yum info sudo
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Installed Packages
Name        : sudo
Arch        : x86_64
Version     : 1.8.19p2
Release     : 11.el7_4
Size        : 3.9 M
Repo        : installed
From repo   : updates
Summary     : Allows restricted root access for specified users
URL         : http://www.courtesan.com/sudo/
License     : ISC
Description : Sudo (superuser do) allows a system administrator to give certain
            : users (or groups of users) the ability to run some (or all)
            : commands as root while logging all commands and arguments. Sudo
            : operates on a per-command basis.  It is not a replacement for the
            : shell.  Features include: the ability to restrict what commands a
            : user may run on a per-host basis, copious logging of each command
            : (providing a clear audit trail of who did what), a configurable
            : timeout of the sudo command, and the ability to use the same
            : configuration file (sudoers) on many different machines.

 

 

4.卸载软件包:

[root@VM_0_12_centos ~]# yum remove sudo #卸载软件包
Loaded plugins: fastestmirror, langpacks
Resolving Dependencies
--> Running transaction check
---> Package sudo.x86_64 0:1.8.19p2-11.el7_4 will be erased
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================

 Package      Arch           Version                     Repository        Size
================================================================================

Removing:
 sudo         x86_64         1.8.19p2-11.el7_4           @updates         3.9 M

Transaction Summary
================================================================================

Remove  1 Package

Installed size: 3.9 M

 

 

5.查看软件包是否安装与版本信息

1.利用rpm -q查看(已经安装的会显示版本信息,未安装的会提示未安装)

[root@VM_0_12_centos ~]# rpm -q sudo
package sudo is not installed
[root@VM_0_12_centos ~]# rpm -q zip
zip-3.0-11.el7.x86_64

 

有时候安装包不一定名字起的非常标准,所以我们一般需要加上  -qa参数:

[root@VM_0_12_centos ~]# rpm -qa |grep vim
vim-common-7.4.160-1.el7_3.1.x86_64
vim-filesystem-7.4.160-1.el7_3.1.x86_64
vim-minimal-7.4.160-1.el7_3.1.x86_64
vim-enhanced-7.4.160-1.el7_3.1.x86_64
[root@VM_0_12_centos ~]#

 

 

 

2.利用yum list  根据状态判断是否安装

[root@VM_0_12_centos ~]# yum list | grep sudo

libsss_sudo.x86_64                      1.15.2-50.el7_4.11             updates

lxqt-sudo.x86_64                        0.11.1-3.el7                   epel

lxqt-sudo-l10n.noarch                   0.11.2-3.el7                   epel

sudo.x86_64                             1.8.19p2-11.el7_4              updates

sudo-devel.x86_64                       1.8.19p2-11.el7_4              updates

 

 

3.直接man 命令  也可以查看是否安装:

[root@VM_0_12_centos ~]# sudo
-bash: sudo: command not found
[root@VM_0_12_centos ~]# man sudo
No manual entry for sudo

 

三、源代码安装:

前提是安装c编译器,可以用yum在线安装gcc。  

[root@VM_0_12_centos ~]# yum install gcc
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package gcc.x86_64 0:4.8.5-16.el7_4.2 will be installed

 cc是gcc的一个链接(快捷方式),看看下面的终端输出就明白了

[root@VM_0_12_centos ~]# which gcc
/usr/bin/gcc
[root@VM_0_12_centos ~]# which cc
/usr/bin/cc
[root@VM_0_12_centos ~]# ll /usr/bin/cc
lrwxrwxrwx 1 root root 3 Mar 29 16:32 /usr/bin/cc -> gcc
[root@VM_0_12_centos ~]#

 

 

应用举例:

 

 四:脚本安装:

    webmin是一个重要的通过网页管理linux服务器的软件。安装的时候采用ssh脚本安装。

 

 

 例如:webmin的安装:

1.到网上下载webmin的安装包。

2.用sftp传到linux服务器

[root@iz2ze46xi6pjjj69ailg9lz webin]# ll
total 28240
drwxr-xr-x 133 root bin     12288 Mar 16 11:06 webmin-1.881

 

3.解压tar.gz文件

tar -zxvf webmin-1.881.tar.gz

 

 4.进入解压后的目录安装;(setup.sh是安装脚本)

[root@iz2ze46xi6pjjj69ailg9lz webmin-1.881]# ./setup.sh

 

   安装过程中只需要输入登录的密码,其他不用修改,默认的端口是10000,默认的账户名字是admin。

 5.安装完成后测试:

[root@iz2ze46xi6pjjj69ailg9lz webmin-1.881]# curl localhost:10000   #连接本地10000端口
<!DOCTYPE html>
<html data-background-style="gainsboro" class="session_login">
<head>
 <noscript> <style> html[data-background-style="gainsboro"] { background-c
#d6d6d6; } html[data-background-style="nightRider"] { background-color: #1
 } html[data-background-style="nightRider"] div[data-noscript] { color: #9
0......

 

6.开启与停止服务

webmin默认安装在/etc/webmin目录下,查看目录下有stop两个脚本,我们可以通过此脚本开启与停止webmin服务,如果有必要我们也可以自己写一个脚本启动与停止webmin

[root@VM_0_12_centos webmin]# pwd
/etc/webmin
[root@VM_0_12_centos webmin]# ls | grep st
cluster-copy
cluster-cron
cluster-passwd
cluster-shell
cluster-software
cluster-useradmin
cluster-usermin
cluster-webmin
custom
first-install
installed.cache
postfix
postgresql
restart
smart-status
start
status
stop
stunnel
system-status
uninstall.sh

 

开启与关闭webmin

[root@VM_0_12_centos webmin]# file ./start 
./start: POSIX shell script, ASCII text executable
[root@VM_0_12_centos webmin]# file ./stop
./stop: POSIX shell script, ASCII text executable
[root@VM_0_12_centos webmin]# file ./status
./status: directory
[root@VM_0_12_centos webmin]# sh ./start 
Starting Webmin server in /opt/webmin/webmin-1.881
[root@VM_0_12_centos webmin]# sh ./stop 
Stopping Webmin server in /opt/webmin/webmin-1.881

 

附一个自己写的启动的脚本

#!/bin/bash
#start webmin service
start()
{
/etc/webmin/start >/dev/null 2> /dev/null
if [ $? = \'0\' ] 
        then 
        echo "webmin is success start"
fi
}

#stop webmin service
stop()
{
/etc/webmin/stop > /dev/null 2> /dev/null
if [ $? = \'0\' ] 
        then 
        echo "webmin is success stop"
fi
}

#status webmin
status()
{
   /usr/bin/netstat -ano | /usr/bin/grep 10000 > /dev/null
   if [ $? != \'0\' ]
        then
        echo "webmin is not start"
   else
        echo "webmin is running"
    fi
}

########read input##############
str=$1
if [ ${str} = \'start\'以上是关于linux软件包管理的主要内容,如果未能解决你的问题,请参考以下文章

linux下的软件包管理与源代码方式安装软件

Linux学习:软件包管理+常用命令

Linux系统红帽软件包管理器(RPM)

linux基础入门之管理linux软件

vs code初体验

Linux用 RPM 管理软件包(rpm)