rpm
1.挂载镜像
将镜像挂载在/mnt文件下
[root@localhost ~]# mount -t iso9660 /dev/cdrom /mnt
注:有些文件夹不可以挂载,如config、bin等,挂载后会将文件覆盖,出现混乱
-t 文件系统类型
/dev/cdrom 挂载设备
/mnt 挂载点
2.卸载
[root@localhost ~]# umount /mnt/ 或者 [root@localhost ~]# umount /dev/cdrom
强制卸载
[root@localhost ~]# umount -l /mnt/
2.安装软件
[root@localhost ~]# cd /mnt/Packages/ [root@localhost Packages]# rmp -ivh tree-1.6.0-10.el7.x86_64.rpm
-i install
-v 显示安装过程
-h 显示安装百分比
-q 查询 query
-l 路径 load
-i 信息 information
-a 所有 all
-c 配置文件 config
-d 文档 document
-f 软件包 file
-e 卸载
[root@localhost ~]# rpm -q tree #查询 [root@localhost ~]# rpm -ql tree #显示安装路径 l -load [root@localhost ~]# rpm -qi tree #显示包信息 i - information [root@localhost ~]# rpm -qa tree #显示系统中所有的已安装软件 a - all [root@localhost ~]# rpm -qa |grep vim 查询系统已安装的所有rpm包,从中过滤出名称中包含"vim"字符串的rpm包,即vim相关的rpm软件包。 通过它可以知道系统当前安装了哪些vim或与vim相关的包。常用来检查vim是否完整安装,或是否有需要升级的包。 [root@localhost ~]# rpm -qc tree #显示配置文件 c-config [root@localhost ~]# rpm -qd tree #显示文档 d - document [root@localhost ~]# rpm -qf /sbin/useradd #通过文件查询对应的软件包 f - file [root@localhost ~]# rpm -e tree #卸载
[root@localhost Packages]# rpm -ivh -- root=/tmp /mnt/Packages/tree-1.6.0-10.el7.x86_64.rpm --force -- nodeps
-- root= 指定安装路径
-- force 强制
-- nodeps 不管依赖关系
软件可以下载安装,但是不能使用。
为了解决依赖管理,使用yum源
yum
1.本地yum
[root@localhost ~]# mkdir /etc/yum.repos.d/old #创建本地域名备份文件目录 [root@localhost ~]# mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/old/ #将/etc/yum.repos.d文件下的文件类型为repo的文件剪切至/etc/yum.repos.d/old文件下 [root@localhost ~]# touch /etc/yum.repos.d/local.repo #创建本地yum文件 [root@localhost ~]# vim /etc/yum.repos.d/local.repo #编辑yum文件 内容如下:[local_iso] # 库名 name=from local iso #描述 baseurl=file:///iso #挂载点 enable=1 #开启库 0 关闭库 gpgcheck=0 #不校验 1 是校验
2.在线yum
华为镜像站: https://mirrors.huaweicloud.com/home
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.huaweicloud.com/repository/conf/CentOS-7-anon.repo
阿里云:阿里巴巴开源镜像站-OPSX镜像站-阿里云开发者社区
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
3.常用指令
[root@localhost ~]# yum makecache #建立缓存 [root@localhost ~]# yum install httpd #安装 [root@localhost ~]# yum remove apr #移除 [root@localhost ~]# yum repolist #查询包数量 [root@localhost ~]# yum list #列出所有软件 [root@localhost ~]# yum search vim 查询软件包包含vim的 [root@localhost ~]# yum provides /etc/vsftpd/vsftpd.conf 通过文件查软件包 [root@localhost ~]# yum clean all 清除缓存 [root@localhost ~]# yum info tree 查看软件包信息 [root@localhost ~]# yum history 查看历史 [root@localhost ~]# yum reinstall tree 重装 [root@localhost ~]# yum update tree 更新软件 [root@localhost ~]# yum upgrade 更新系统
4.自建yum库(将所有软件包放到同一个目录下,使用createrepo建库)
[root@localhost ~]# cp /iso/Packages/* /myrepo/ [root@localhost ~]# wget [ftp://10.11.0.254/robin/2024-07-05-](ftp://10.11.0.254/robin/2024-07-05-)云计算/mysql-5.7.39-1.el7.x86_64.rpm-bundle.tar [root@localhost ~]# tar -xvf mysql-5.7.39-1.el7.x86_64.rpm-bundle.tar [root@localhost ~]# mv /root/mysql-community-* /myrepo/ [root@localhost ~]# createrepo /myrepo/ 建立依赖关系(createrepo-0.9.9-28.el7.noarch.rpm) [root@localhost yum.repos.d]# vim local.repo
压缩与打包
1.创建大文件
创建一个500MB的文件
[root@localhost ~]# dd if=/dev/zero of=/root/data bs=10M count=50
/dev/zero 零发生器
bs 大小 size blocksize
count 计数
gzip:
gzip data //压缩data
gunzip data.gz //解压缩
bzip2:
bzip data //压缩data
bunzip data.bz2 //解压缩
tar(打包文件,方便传输、归纳、备份)
tar -cvf /tmp/boot.tar /boot //创建一个名为boot.tar的归档文件,包含/boot目录的内容
c 创建新的归档文件
v 详细模式,显示处理的文件
f 指定归档文件名
du -sh /tmp/boot.tar //显示文件大小
s 显示总计大小
h 以可读的格式显示大小
tar -tvf /tmp/boot.tar //列出文件中的内容
t 列出归档文件的内容
v 详细模式
f 指定要查看的归档文件
tar -rvf /tmp/boot.tar /root/anaconda-ks.cfg //将anaconda-ks.cfg文件追加到已存在的boot.tar文件中
r 向已有的归档文件追加文件
v 详细模式
f 指定归档文件
tar -xvf /tmp/boot.tar -C /tmp/ // 将boot.tar解压到tmp目录下
x 行归档文件中提取文件
C 改变到指定的目录
tar -zcvf /tmp/boot.tar.gz /boot //创建一个gzip压缩的tar文件
z 使用gzip压缩
tar -zxvf /tmp/boot.tar.gz /tmp //解压boot.tar.gz到/tmp文件夹下
x 解压缩
源码包
[root@localhost tmp]# wget https://nginx.org/download/nginx-1.26.1.tar.gz //从Nginx官方网站下载Nginx源码包 [root@localhost tmp]# tar -xvf nginx-1.26.1.tar.gz -C /usr/local/src/ //解压下载的包 -x 解压 -v 显示详细信息 -f 指定要处理的文件 -C 制定解压的目标目录 [root@localhost nginx-1.26.1]# cd /usr/local/src/ //切换目录 [root@localhost nginx-1.26.1]# ./configure --prefix=/usr/local/nginx #编译前配置以及检测 //运行configure脚本,为编译做准备 [root@localhost nginx-1.26.1]# make //编译源代码 [root@localhost nginx-1.26.1]# make install //将编译好的文件复制到之前的文件夹(/usr/local/nginx)