Linux压缩&解压缩&包管理

1、压缩&解压缩

在这里插入图片描述

(2)gzip,gunzip

gzip 被压缩的文件名,压缩后,原文件不保留

gzip -c > test.txt test.txt.gz 压缩,保留源文件

gzip -r 目录 压缩了目录下的所有内容

gunzip test.txt.gz

gunzip -c test.txt.gz > /root/test.txt 解压缩到特定目录,并且保留源文件

gunzip ===gzip -d

不解压查看

zcat test5.txt.gz

zless test5.txt.gz

(3)bzip2,bunzip2

bzip2 被压缩的文件名,压缩后,原文件不保留

bzip2 -c test.txt>test.txt.bz2 压缩,保留源文件

bunzip2 test.txt.bz2

bunzip2 ===bzip2 -d

不解压查看

bzcat

(4)xz,unxz

xz 被压缩的文件名,压缩后,源文件不保留

xzcat test.txt.xz 查看压缩后的文件内容

xz dir/*

unxz test.txt.xz

xz -d test.txt.xz

xz -d dir/*
在这里插入图片描述

2、tar:

(1)[root@localhost tar]# tar -cf etc.tar /etc/

-c 创建一个新的归档文件

-f 只想一个归档文件

/etc/ 被归档的文件

(2)[root@localhost tar]# tar -czf boot.tar.gz /boot/

-z 以gzip形式将打包的文件压缩

(3)[root@localhost tar]# tar -cjf boot.tar.bz2 /tmp/

-j bizp2的形式将打包的文件压缩

(4)[root@localhost tar]# tar -tf etc.tar

-t 查看归档文件内容

(5)[root@localhost tar]# tar --delete /etc/hosts -f etc.tar

–delete 删除etc.tar下的/etc/hosts

(6)[root@localhost tar]# tar -f etc.tar -r /root/anaconda-ks.cfg.bak

-r 向打包文件中追加新内容 -r 要新加的内容

(7)[root@localhost tar]# tar -tf etc.tar |grep hosts

-v 查看详细信息

(8)[root@localhost tar]# tar xzf boot.tar.gz

-x 解压

-xz 解压gzip压缩的归档文件

(9)[root@localhost tar]# tar xjf boot.tar.bz2

-xj 解压bzip2的归档文件

(10)[root@localhost tar]# tar xjf boot.tar.bz2 -C test/

-C 指定解压路径

(11)[root@localhost ~]# tar -czvf test.tar.gz file* --remove-files

–remove-files 打包的同时删除源文件

(12)[root@localhost ~]# tar xzvf file.tar.gz && rm -rf file.txt.gz

&& 两步 ,前一步解压文件,后一步把原文件删除

3、cpio:

-t:看归档内容

-F:指定归档内容

-o:copy-out模式

-A:追加

-i:copy-in模式;提取

-d:需要时自动创建目录

-v:显示详细信息

-p:copy-pass模式

(1)find ./ -depth |cpio -ov -F tree1.cpio

把当前的文件归档到了tree1.cpio ,tree.cpio里面有本身

(2)find ./ -depth |cpio -ov -F /tmp/tree.cpio

把当前的文件归档到/tmp/目录下

(3)find ./ -depth -print0 |cpio --null -ov -F /tmp/tree2.cpio

– null 解释空字符

(4)cpio -t -F tree.cpio 或者 cpio -t <tree.cpio

查看tree.cpio下的归档内容

(5)cpio -t -F /tmp/home1.cpio /root/*

查看home1.cpio归档文件里的 /root/下的内容(没有隐藏文件)

(6)cpio -t -F /tmp/home1.cpio /root/.*

查看home1.cpio归档文件里的 /root/下的内容(全是隐藏文件)

(7)cpio -t -F /tmp/home1.cpio /root/{.*,**}

查看home1.cpio归档文件里的 /root/下的内容(查看所有文件)

(8)ls /root/test.txt |cpio -oA -F /tmp/home1.cpio 向归档文件中追加文件

(9)find /boot -depth -print0 |cpio -oA -F /tmp/home1.cpio 添加新目录

(10)cpio -idv -F /tmp/home1.cpio 提取文件

(11)find ~ -depth -print0 |cpio --null -pvd /tmp/abc 复制~下文件到/tmp/abc/root

yum

(参考文档)

yum list 列出源里面的所有包,@表示的已经安装的,没有@表示没有安装

yum list |grep vim

4、rmp

1、安装

i:安装

rmp -ivh zip-3.0-11.e17.x86_64.rpm 安装

2、卸载

e:卸载

–nodeps 不检查依赖

3、升级

-U 升级||安装

-F 升级

rpm -U libestr-0.1.9-2.e17.x86_64.rpm

4、查询

rpm -qa 查询所有已经安装的包

rpm -qf sync 查询当前文件属于哪个包

rpm -qi zip查看详细描述

rpm -ql zip 查看安装详细信息

rpm -qR zip 查看有哪些依赖cd

源码包的安装:

自己制定化安装

“代码” ----------> 机器码 (0,1)编译器

yum gcc gcc-c++

检查系统环境

编译

安装

(1)下载软件包,并解压

wget+网址 tar xjf http.,.tar.bz2

(2)安装编译器

yum install gcc gcc-c++

(3)建立安装环境

./confinger --prefix=/data/httpd

error:APR-until not found 类似于这样,缺少依赖。安装依赖

yum install apr-devel 提示缺少apr,但是实际是安装好的;经验告诉我们 -devel;

echo $? 编译完检查编译结果,echo $? 结果为0,表示成功,反之,失败

(4)编译

make :

echo $?

(5)安装

make install

echo $?

(6)启动

data/httpd/bin/apachectl start “安装目录下的路径”

查看进程

ps -ef |grep httpd

源码安装:三部曲

1、建立检查安装环境

./confinger --prefix=/data/heepd

2、编译

3、安装

源码安装:
前置条件:编译工具
configure
检查编译环境
指定安装路径
指定依赖关系的安装目录:解决依赖关系
禁用和启用功能模块
makefile
make
将源码编译成机器码,如果有禁用和启用功能模块,在这个阶段编译
make install
根据makefile文件中的指定路径进行安装

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值