day013 系统管理系列之软件包管理 yum与ubuntu软件包管理
yum是红帽系列系统中默认的软件包管理器,替我们下载指定的rpm包,替我们安装,并下载安装所有的依赖。
yum软件包管理
yum安装软件的全流程
1、运行yum install -y tree
命令;
2、解析下tree软件包是否有依赖;
3、yum根据本地配置的yum源的地址进行请求;
4、如果yum源中存在软件,则会通知yum进行下载,rpm包被下载到yum缓存目录;
5、软件包和依赖都自动下载好后,开始安装;
6、安装完成后默认会删除刚刚下载的软件包。
yum源配置
为何要换yum源
为了下载的更快更新,所以要配置yum源,换成国内的源。
一般只给虚拟机/物理机换源,云服务器一般都是装好的。
# 查看当前系统的yun源 yum repolist #repo就是源的意思
|
# 安装 tree 和 sl 两个软件包 yum install -y tree sl # 加-y是为了以后弹出任何选项都输入y
|
换源
# Ubuntu系统/Debian系统 # 备份老的源 cp /etc/apt/sources.list /etc/apt/sources.list_backup # 用vim打开源文件 vim /etc/qpt/sources.list # 把默认的源注释掉 # 复制下面的源路径进去 # 清华源 deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster main contrib non-free deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ buster main contrib non-free deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-updates main contrib non-free deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-updates main contrib non-free deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-backports main contrib non-free deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-backports main contrib non-free deb https://mirrors.tuna.tsinghua.edu.cn/debian-security buster/updates main contrib non-free deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security buster/updates main contrib non-free # 保存退出 # 更新生效 apt-get update
|
# CentOS换源 # 备份老的源 mv /etc/yum.repos.d/CentOS-Base.repo etc/yum.repos.d/CentOS-Base.repo_backup # 下载阿里源配置文件到该目录 wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo # 更新生效 yum makecache
|
yum源配置文件详解
红帽系统存放在/etc/yum.repos.d/
目录下,且都以.repo结尾,只能识别以.repo结尾的文件。
yum命令配置文件
未来在正式环境中很少修改,一般只在测试环境中修改。
或者我们想把yum安装过的软件包保存的时候(自建yum仓库),修改/etc/yum.conf
配置,找到keepcache
,改为1。
/etc/yum.conf yum命令配置文件 |
|
|
keepcache |
0表示关闭缓存,软件下载之后自动删除安装包; 1表示开启,在自建yum源时使用。 |
|
cachedir |
yum下载软件包的缓存目录 |
|
logfile |
yum命令的记录,你装了什么软件 |
|
yum命令详解
增加
# yum安装 yum install -y tree python # 重新安装 yum reinstall -y python
|
查询
# 查询某个命令或依赖属于哪个软件包 yum provides ifconfig # 还有一种结果很多的方法,但是需要经验 yum search all ifconfig
|
# 显示yum仓库中所有的软件 yum list # 查找某个记不清名字的软件包 yum list |grep tree
|
删除
尽量不要用yum来删除软件,可能会把依赖删除掉。
# yum删除某软件 yum remove python # 不推荐用yum删除,因为会把依赖也删掉,推荐使用rpm -e # rpm -e删除软件包,最多只删一个 rpm -r tree
|
# 删除Linux本地yum缓存,用在自建yum仓库之前 yum clear all
|
改(升级)
yum命令在安装的时候自带更新。
也有纯粹的更新。
# 更新软件包 yum update python yum upgrade python
|
ubuntu软件包管理
day014 课程阶段复盘
大纲列出来逐步完善。
day015 系统管理系列之进程管理-进程及管理命令
进程概述和进程的分类
名字 |
含义 |
程序 |
安装包,程序代码,app;程序存放在磁盘上 |
进程 |
运行起来的命令、服务、程序;进程运行在内存中 |
守护进程 |
一直运行的进程,也可以叫服务 |
# 以树形结构显示进程关系 pstree # 以树形结构显示进程关系并显示进程号 pstree -p
|
僵尸进程
查找僵尸进程的两个命令:
# top命令的第二行可显示zombie进程的数量 top
|
# 利用ps aux和grep过滤出含有大Z的进程 ps aux |grep Z
|
解决方法:
方法1-找出僵尸进程上级进程,结束。
方法2-如果上级进程是主进程(pid为1)则需要重启Linux。