Linux上的軟件安裝可以分為三種方式:
1. yum安裝
yum基于RPM包管理,一次性安裝所有依賴包,提供了查找、安裝、刪除一個、一組
至全部軟件包的命令,配置文件在/etc/yum.repos.d/下
主要命令:
yum install gcc g++
yum remove wget
yum list installed //顯示已經安裝過的軟件
yum list //顯示所有可以安裝的包
.
[wyb@localhost ~]$ wget -h //驗證有沒有安裝wget
-bash: /usr/bin/wget: No such file or directory
[wyb@localhost ~]$ sudo yum search wget //通過yum查找wget,看有沒有這個軟件包
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: mirrors.yun-idc.com
* extras: mirrors.pubyun.com
* updates: mirrors.yun-idc.com
============================== N/S Matched: wget ===============================
wget.x86_64 : A utility for retrieving files using the HTTP or FTP protocols
Name and summary matches only, use "search all" for everything.
[wyb@localhost ~]$ sudo yum deplist wget //列出安裝包的依賴項
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: mirrors.yun-idc.com
* extras: mirrors.pubyun.com
* updates: mirrors.yun-idc.com
Finding dependencies:
package: wget.x86_64 1.12-5.el6_6.1
dependency: libssl.so.10()(64bit)
provider: openssl.x86_64 1.0.1e-42.el6
provider: openssl.x86_64 1.0.1e-42.el6_7.1
provider: openssl.x86_64 1.0.1e-42.el6_7.2
provider: openssl.x86_64 1.0.1e-42.el6_7.4
[wyb@localhost ~]$ sudo yum install wget //安裝一個或兩個軟件包
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: mirrors.yun-idc.com
* extras: mirrors.pubyun.com
* updates: mirrors.yun-idc.com
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package wget.x86_64 0:1.12-5.el6_6.1 will be installed
--> Finished Dependency Resolution
[wyb@localhost ~]$ sudo yum remove wget //移除wget
[sudo] password for wyb:
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Remove Process
Resolving Dependencies
--> Running transaction check
---> Package wget.x86_64 0:1.12-5.el6_6.1 will be erased
--> Finished Dependency Resolution
2. rpm安裝
分為:二進制包和源代碼包
二進制包可直接安裝,源碼包會由rpm自動編譯、安裝,安裝包常以src、rpm做為后綴
主要參數:
-ivh *.rpm 安裝并顯示安裝進度
-Uvh *.rpm 升級軟件包
-qpl *.rpm 查看rpm軟件包內的包含的文件,顯示安裝后文件釋放的絕對路徑
-qpi *.rpm 列出rpm軟件包的描述信息
-qa 查找所有通過rpm安裝的軟件
-qf /etc/httpd/conf/httpd.conf 查找文件屬于那個安裝包
-va 檢驗軟件包有沒有丟失信息
-e 軟件名 移除軟件包
用rpm安裝軟件:
[wyb@localhost ~]$ wget http://192.168.1.7/wget-1.12-5.el6_6.1.x86_64.rpm //使用wget下載軟件
--2016-04-18 04:31:27-- http://192.168.1.7/wget-1.12-5.el6_6.1.x86_64.rpm
Connecting to 192.168.1.7:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 494884 (483K) [application/x-rpm]
Saving to: 鈝get-1.12-5.el6_6.1.x86_64.rpm?
100%[======================================>] 494,884 1006K/s in 0.5s
2016-04-18 04:31:27 (1006 KB/s) - 鈝get-1.12-5.el6_6.1.x86_64.rpm鈙aved [494884/494884]
先yum remove wget卸載wget,然后用rpm安裝軟件
[wyb@localhost ~]$ ls
wget-1.12-5.el6_6.1.x86_64.rpm
[wyb@localhost ~]$ sudo rpm -ivh wget-1.12-5.el6_6.1.x86_64.rpm //安裝wget
Preparing... ########################################### [100%]
1:wget ########################################### [100%]
[wyb@localhost ~]$ sudo rpm -qpl wget-1.12-5.el6_6.1.x86_64.rpm //查看軟件包內的內容
/etc/wgetrc
/usr/bin/wget
/usr/share/doc/wget-1.12
/usr/share/doc/wget-1.12/AUTHORS
/usr/share/doc/wget-1.12/COPYING
/usr/share/doc/wget-1.12/MAILING-LIST
/usr/share/doc/wget-1.12/NEWS
/usr/share/doc/wget-1.12/README
/usr/share/doc/wget-1.12/sample.wgetrc
/usr/share/info/wget.info.gz
/usr/share/locale/be/LC_MESSAGES/wget.mo
/usr/share/locale/bg/LC_MESSAGES/wget.mo
[wyb@localhost ~]$ sudo rpm -qpi wget-1.12-5.el6_6.1.x86_64.rpm //列出包的描述信息
Name : wget Relocations: (not relocatable)
Version : 1.12 Vendor: CentOS
Release : 5.el6_6.1 Build Date: Thu 30 Oct 2014 10:22:02 AM PDT
Install Date: (not installed) Build Host: c6b8.bsys.dev.centos.org
Group : Applications/Internet Source RPM: wget-1.12-5.el6_6.1.src.
[wyb@localhost ~]$ rpm -qa |grep wget //-qa查看所有安裝的軟件,用grep篩選出來,看有沒有安裝wget
wget-1.12-5.el6_6.1.x86_64
[wyb@localhost ~]$ which wget
/usr/bin/wget
[wyb@localhost ~]$ sudo rpm -qf /usr/bin/wget //查看wget這個文件屬于那個軟件
wget-1.12-5.el6_6.1.x86_64
[wyb@localhost ~]$ sudo rpm -e wget //寫在軟件wget
[wyb@localhost ~]$ wget -h
-bash: /usr/bin/wget: No such file or directory
3. 源碼安裝
sudo yum groupinstall "Development tools" //如果你源碼安裝軟件就需要安裝這個
.
源代碼安裝軟件:
1、./configure,對系統進行檢測然后生成makefile,為下一步的編譯做準備
./configure -prefix=/usr軟件將安裝在/usr下面,可執行文件則會安裝在/usr/bin,默認安裝在/usr/local/bin
2、make,這一步就是編譯,大多數的源碼包都經過這一步進行編譯,這時軟件已經可以用了,不過要通過全路徑來執行
實際上它不是編譯工具,其實是一個構建工具
3、make install 進行安裝,一般你要擁有root權限,因為要向系統寫入東西,相當與配環境變量、將二進制文件拷貝到/usr/local/bin下面
4、make clean將由make產生的過程文件清除
.
PS:
curl -o wget.rpm url可以訪問網頁,它同時還保存了文件,文件名為wget.rpm
wget url也能下載,文件名為全名
Linux下的env可查看環境變量