小白的python之路10/29 文件归档
一打包解包文件
[root@localhost ~]# cd /test/
[root@localhost test]# touch a.txt b.txt c.txt
[root@localhost test]# ls
a.txt b.txt c.txt
#1.打包过程
#c表示创建,v表示过程信息,f表示文件名, test.tar表示打包后的文件名,文件后缀无意义
[root@localhost test]# tar cvf test.tar a.txt b.txt c.txt
a.txt
b.txt
c.txt
[root@localhost test]# ls
a.txt b.txt c.txt test.tar
#2查看过程t表示查看,f指定哪个文件
[root@localhost test]# tar -tf test.tar
a.txt
b.txt
c.txt
[root@localhost test]# ls
a.txt b.txt c.txt test.tar
[root@localhost test]# rm -rf a.txt b.txt c.txt
[root@localhost test]# ls
test.tar
#3 x表示解包 f表示指定文件
[root@localhost test]# tar xvf test.tar
a.txt
b.txt
c.txt
[root@localhost test]# ls
a.txt b.txt c.txt test.tar
[root@localhost test]# mkdir /bak
[root@localhost test]# ls /bak
[root@localhost test]# ls
a.txt b.txt c.txt test.tar
#4 大c表示指定路径(绝对路径)
[root@localhost test]# tar xvf /test/test.tar -C /bak
a.txt
b.txt
c.txt
[root@localhost test]# ls /bak
a.txt b.txt c.txt
#二 压缩文件的压缩和解压
#vim写入信息
[root@localhost test]# vim a.txt
#查看文件信息 文件大小59
[root@localhost test]# ll a.txt
-rw-r--r-- 1 root root 10月 29 20:51 a.txt
#压缩文件gzip 文件大小39
[root@localhost test]# gzip a.txt
[root@localhost test]# ll
总用量 4
-rw-r--r-- 1 root root 10月 29 20:51 a.txt.gz
[root@localhost test]# ll a.txt.gz
-rw-r--r-- 1 root root 10月 29 20:51 a.txt.gz
#解压文件
[root@localhost test]# gunzip a.txt
[root@localhost test]# ls
a.txt
[root@localhost test]# touch b.txt c.txt d.txt
[root@localhost test]# ls
a.txt b.txt c.txt d.txt
#打包
[root@localhost test]# tar cvf test.tar a.txt b.txt c.txt d.txt
a.txt
b.txt
c.txt
d.txt
[root@localhost test]# ls
a.txt b.txt c.txt d.txt test.tar
#压缩
[root@localhost test]# gzip test.tar
[root@localhost test]# ls
a.txt b.txt c.txt d.txt test.tar.gz
#打包时压缩
[root@localhost test]# 10月 29 21:14 test1.tar.gz
[root@localhost test]# ll -l test.tar.gz
-rw-r--r-- 1 root root 10月 29 21:00 test.tar.gz
[root@localhost test]# ls
a.txt b.txt c.txt d.txt test1.tar.gz test.tar.gz
[root@localhost test]# touch e.txt
[root@localhost test]# bzip2 e.txt
[root@localhost test]# ls
a.txt b.txt c.txt d.txt e.txt.bz2 test1.tar.gz test.tar.gz
#压缩文件bz2
[root@localhost test]# tar cvjf test2.tar.bz2 a.txt b.txt c.txt
a.txt
b.txt
c.txt
#2种归档文件无论是bzip2还是gzip解压都一样
[root@localhost test]# mkdir /test1
[root@localhost test]# mkdir /test2
[root@localhost test]# tar xf test1.tar.gz -C /test1/
#解压后包中信息
[root@localhost test]# ls /test1/
a.txt b.txt c.txt d.txt
[root@localhost test]# tar xf test2.tar.bz2 -C /test2/
[root@localhost test]# ls /test2
a.txt b.txt c.txt
#bz2比gz压缩更小 但是bz2速度慢,过程久
eg:对目录/etc/下文件夹的压缩
[root@localhost test]# tar cvzf etc.tar.gz /etc/
[root@localhost test]# ls
a.txt c.txt etc.tar.gz test1.tar.gz test.tar.gz
b.txt d.txt e.txt.bz2 test2.tar.bz2
mkdir /conf_bak
打包目录,结果中有目录名存在 tar cvzf test.tar.gz /etc
cd /etc
tar cvzf test,tar,gz*
补充
>将左边输出到右面eg:cat /etc/passwd > /tmp/passswd.bak
less随意浏览文件less /tmp/passswd.bak
Ctrl+c强制中断进程 CTRL + D 保存退出
useradd 用户 -del mkdir 文件夹 rm
小白的python之路10/29 文件归档的更多相关文章
- 小白的python之路10/31&11/1文件操作系统
文件操作系统的介绍 ext4的superblock块是超级快,innode 块是专门存放文件信息的, block count将硬盘做成block块,对操作系统而言写在block块上就可了,eg:文件1 ...
- 小白的python之路10/30磁盘分区
总结:fdisk mkfs mount 1.磁盘分区 硬盘分区有三种,主磁盘分区.扩展磁盘分区.逻辑分区. 一个硬盘主分区至少有1个,最多4个,扩展分区可以没有,最多1个.且主分区+扩展分区总共 ...
- 小白的python之路10/30 vim编辑器
1.vim进入命令行之后的编辑过程
- 小白的python之路10/22 day1
一.操作系统 操作系统就是一个协调.管理和控制计算机硬件资源和软件资源的控制程序.操作系统所处的位置如下图
- 小白的Python之路 day1
Python之路,Day1 - Python基础1 本节内容 Python介绍 发展史 Python 2 or 3? 一. Python介绍 python的创始人为吉多·范罗苏姆(Guido van ...
- 小白学习Python之路---开发环境的搭建
本节内容 1.Python的介绍 2.发展史 3.安装Python 4.搭建开发环境 5.Hello World程序 一.Python的介绍 Python的创始人为荷兰人吉多·范罗苏姆(Guido v ...
- NO.3:自学python之路------集合、文件操作、函数
引言 本来计划每周完成一篇Python的自学博客,由于上一篇到这一篇遇到了过年.开学等杂事,导致托更到现在.现在又是一个新的学期,春天也越来越近了(冷到感冒).好了,闲话就说这么多.开始本周的自学Py ...
- 小白学 Python 数据分析(10):Pandas (九)数据运算
人生苦短,我用 Python 前文传送门: 小白学 Python 数据分析(1):数据分析基础 小白学 Python 数据分析(2):Pandas (一)概述 小白学 Python 数据分析(3):P ...
- 小白的Python之路 day1 变量
Python之路,Day1 - Python基础1 变量 变量用于存储在计算机程序中引用和操作的信息.它们还提供了一种用描述性名称标记数据的方法,这样我们的程序就能更清晰地被读者和我们自己理解.将变量 ...
随机推荐
- MTK-TP(电阻屏校准程序ts_lib移植)
现今的项目中已经很少有使用电阻TP,但总有些奇怪的需求.如果项目中遇到需要校准电阻屏如何保证较快且较稳的调试TP呢.这里介绍使用ts_lib库来进行调试. 当然也可以使用一些常见的校准算法,采集5点, ...
- 如何对tcp流认证并加密
一个场景:目前越来越多的业务需要远程读写Redis,而Redis 本身不提供 SSL/TLS 的支持,在需要安全访问的环境下. 这时候就需要额外的手段进行加密认证,这里有两种手段:spiped 和 n ...
- Python 运维之路
第一章:Python基础知识 1.Python 变量了解 .Python 二进制 .Python 字符编码 4.Python if条件判断 5.Python while循环 6.Python for循 ...
- C# readonly与const区别
静态常量:是指编译器在编译时候会对常量进行解析,并将常量的值替换成初始化的那个值. 动态常量的值则是在运行的那一刻才获得的,编译器编译期间将其标示为只读常量,而不用常量的值代替,这样动态常量不必在声明 ...
- ARDUINO入门按键通信试验
1.1按键实验 1.需要学习的知识: 1) Arduino 的输入口配置方法,配置函数的用法 通过pinMode()函数,可以将ADUINO的引脚配置(INPUT)输入模式 2) 搞懂什么是抖动 机械 ...
- SQL Server Management Studio 执行超大脚本文件
SQL Server Management Studio 执行超大脚本文件 启动cmd.exe , cd 到C:\Program Files (x86)\Microsoft SQL Server\11 ...
- (Code) Python implementation of phrase extraction from sentence
import os import numpy as np import pandas as pd from tqdm import tqdm import numpy as np import str ...
- vue-router使用 看着篇就够了
官网地址:https://router.vuejs.org/zh/ 先来个自我介绍吧,我就是你们口中的路由,我的作用就是告诉你们怎么到达某地,比如你想去一个地方(前提是这个地方是已经存在的)我会查询我 ...
- CAP原则和BASE定理
CAP原则和BASE定理 分布式系统 来自个人OneNote 以CAP理论为基础的三种解决方案 1.两阶段提交 所谓的两个阶段是指:第一阶段:准备阶段(投票阶段)和第二阶段:提交阶段(执行阶段). 准 ...
- wireshark基础学习—第二部分wireshark的基础操作
抓取报文: 下载和安装好Wireshark之后,启动Wireshark并且在接口列表中选择接口名,然后开始在此接口上抓包.例如,如果想要在无线网络上抓取流量,点击无线接口.点击Capture Opti ...