linux包管理器总结


一般来说著名的 Linux 系统基本上分两大类:

RedHat 系列

Redhat、Centos、Fedora 等

rmp

一种用于互联网下载包的打包及安装工具,它包含在RedHat 系列分发版中。它生成具有.RPM 扩展名的文件。相当于点击windows中的setup.exe

查询包是否安装

rpm –qa|grep 包名

安装

rpm -ivh RPM 包全路径名称

  1. i=install 安装
  2. v=verbose 提示
  3. h=hash 进度条

卸载

rpm -e 包的名称
卸载成功不会有任何提示
注意
如果其它软件包依赖于您要卸载的软件包,卸载时则会产生错误信息
rpm -e foo
会提示

removing these packages would break dependencies:foo is needed by bar-1.0-1

如果我们就是要删除 foo 这个 rpm 包,可以增加参数 --nodeps (强制删除),就可以强制删除,但是一般 不推荐这样做,因为依赖于该软件包的程序可能无法运行
rpm -e --nodeps foo

yum

Yum 是一个 Shell 前端软件包管理器。在RedHat 系列分发版中。基于 RPM 包管理,能够从指定的yum服务器自动下载 RPM 包 并且安装,可以自动处理依赖性关系,并且一次安装所有依赖的软件包。使用 yum 的前提是可以联网.

相当于应用商店,但是这个应用

更新商店
yum update

查询
查询服务器是否有安装包

yum list|grep xx

安装
yum install xxx

移除软件包
yum -remove

yum换源

1.备份默认yum源

mkdir /opt/centos-yum.bak 
mv /etc/yum.repos.d/* /opt/centos-yum.bak/

2.下载国内源

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
或者
wget http://mirrors.163.com/.help/CentOS6-Base-163.repo

3.更新缓存

yum clean all 
yum makecache

wget

wget不是安装方式 他是一种下载软件类似与迅雷 如果要下载一个软件 我们可以直接 wget +网址

总结:使用wget下载一个 rpm包, 然后用 rpm -ivh xxx.rpm 安装这个软件,嫌麻烦的话,就
可以直接用 yum install sqoop 来自动下载和安装依赖的rpm软件。

Debian 系列

Debian、Ubuntu 等

dpkg

与npm类似。但是用于debian系列

apt和apt-get

与yum类似

更新商店

apt upgrade

查询
查询服务器是否有安装包

apt list –installed

安装

apt-get install xxx

移除软件包

apt remove package


ubuntu换源

1.备份原始源文件source.list
打开终端,执行命令:sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak

2.修改源文件sources.list
(1)终端执行命令:sudo chmod 777 /etc/apt/sources.list 更改文件权限使其可编辑;

(2)执行命令: sudo gedit /etc/apt/sources.list 打开文件进行编辑;

(3)删除原来的文件内容,根据系统版本复制下面的任意一个到其中并保存(常用的是阿里源和清华源,推荐阿里源);

unbuntu 18

deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
 
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
 
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
 
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
 
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

ubuntu20

deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
 
deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
 
deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
 
deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
 
deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse

3.更新源
终端执行命令:

sudo apt update
sudo apt upgrade
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值