linux解压缩命令
linux-dash
A beautiful web dashboard for Linux
项目地址:https://gitcode.com/gh_mirrors/li/linux-dash
免费下载资源
·
按照格式进行讲解:
zip文件压缩:
格式: zip 压缩文件名 源文件
example:
topwqp:japan wangqiupeng$ ls
cangls
topwqp:japan wangqiupeng$ zip cangls.zip cangls
adding: cangls/ (stored 0%)
topwqp:japan wangqiupeng$ ls
cangls cangls.zip
cangls
topwqp:japan wangqiupeng$ zip cangls.zip cangls
adding: cangls/ (stored 0%)
topwqp:japan wangqiupeng$ ls
cangls cangls.zip
topwqp:japan wangqiupeng$
zip压缩目录:
格式: zip -r 压缩文件名 源目录
example:
topwqp:linux_training wangqiupeng$ ls
hardlk1 hardlk2 japan softlink softlk
topwqp:linux_training wangqiupeng$ touch japan/cangls
topwqp:linux_training wangqiupeng$ touch japan/longls
topwqp:linux_training wangqiupeng$ touch japan/boduols
topwqp:linux_training wangqiupeng$ zip -r japan.zip japan
adding: japan/ (stored 0%)
adding: japan/boduols (stored 0%)
adding: japan/cangls/ (stored 0%)
adding: japan/cangls.zip (stored 0%)
adding: japan/longls (stored 0%)
topwqp:linux_training wangqiupeng$ ls
hardlk1 japan softlink
hardlk2 japan.zip softlk
topwqp:linux_training wangqiupeng$
hardlk1 hardlk2 japan softlink softlk
topwqp:linux_training wangqiupeng$ touch japan/cangls
topwqp:linux_training wangqiupeng$ touch japan/longls
topwqp:linux_training wangqiupeng$ touch japan/boduols
topwqp:linux_training wangqiupeng$ zip -r japan.zip japan
adding: japan/ (stored 0%)
adding: japan/boduols (stored 0%)
adding: japan/cangls/ (stored 0%)
adding: japan/cangls.zip (stored 0%)
adding: japan/longls (stored 0%)
topwqp:linux_training wangqiupeng$ ls
hardlk1 japan softlink
hardlk2 japan.zip softlk
topwqp:linux_training wangqiupeng$
zip格式的解压缩:
很简单: unzip 压缩文件名
example:
topwqp:linux_training wangqiupeng$ unzip japan.zip
Archive: japan.zip
replace japan/boduols? [y]es, [n]o, [A]ll, [N]one, [r]ename: y
extracting: japan/boduols
replace japan/cangls.zip? [y]es, [n]o, [A]ll, [N]one, [r]ename: y
extracting: japan/cangls.zip
replace japan/longls? [y]es, [n]o, [A]ll, [N]one, [r]ename: y
extracting: japan/longls
topwqp:linux_training wangqiupeng$ ls
hardlk1 japan softlink
hardlk2 japan.zip softlk
Archive: japan.zip
replace japan/boduols? [y]es, [n]o, [A]ll, [N]one, [r]ename: y
extracting: japan/boduols
replace japan/cangls.zip? [y]es, [n]o, [A]ll, [N]one, [r]ename: y
extracting: japan/cangls.zip
replace japan/longls? [y]es, [n]o, [A]ll, [N]one, [r]ename: y
extracting: japan/longls
topwqp:linux_training wangqiupeng$ ls
hardlk1 japan softlink
hardlk2 japan.zip softlk
topwqp:linux_training wangqiupeng$
这个命令的优点 : zip文件的压缩在linux下和 windows压缩zip格式一致
2: .gz格式的压缩和解压缩
压缩命令:
gzip 源文件
这个命令执行的话 : 源文件会消失 只有压缩后的文件存在
example:
topwqp:linux_training wangqiupeng$ touch abc
topwqp:linux_training wangqiupeng$ gzip abc
topwqp:linux_training wangqiupeng$ ls
abc.gz hardlk2 softlink
hardlk1 japan softlk
topwqp:linux_training wangqiupeng$
topwqp:linux_training wangqiupeng$ gzip abc
topwqp:linux_training wangqiupeng$ ls
abc.gz hardlk2 softlink
hardlk1 japan softlk
topwqp:linux_training wangqiupeng$
如果想保留源文件: 可以这样采用输出重定向的方式:
gzip -c 源文件 > 压缩文件
topwqp:linux_training wangqiupeng$ ls
abc hardlk2 softlink
hardlk1 japan softlk
topwqp:linux_training wangqiupeng$ gzip -c abc > abc.gz
topwqp:linux_training wangqiupeng$ ls
abc hardlk1 japan softlk
abc.gz hardlk2 softlink
topwqp:linux_training wangqiupeng$
abc hardlk2 softlink
hardlk1 japan softlk
topwqp:linux_training wangqiupeng$ gzip -c abc > abc.gz
topwqp:linux_training wangqiupeng$ ls
abc hardlk1 japan softlk
abc.gz hardlk2 softlink
topwqp:linux_training wangqiupeng$
带有目录的压缩命令如下:
gzip -r 源文件
example:
topwqp:linux_training wangqiupeng$ ls
abc hardlk1 japan softlk
abc.gz hardlk2 softlink
topwqp:linux_training wangqiupeng$ cd japan
topwqp:japan wangqiupeng$ ls
boduols cangls longls
topwqp:japan wangqiupeng$ cd ..
topwqp:linux_training wangqiupeng$ gzip -r japan
topwqp:linux_training wangqiupeng$ ls
abc hardlk1 japan softlk
abc.gz hardlk2 softlink
topwqp:linux_training wangqiupeng$ cd japan
topwqp:japan wangqiupeng$ ls
boduols.gz cangls longls.gz
topwqp:japan wangqiupeng$
abc hardlk1 japan softlk
abc.gz hardlk2 softlink
topwqp:linux_training wangqiupeng$ cd japan
topwqp:japan wangqiupeng$ ls
boduols cangls longls
topwqp:japan wangqiupeng$ cd ..
topwqp:linux_training wangqiupeng$ gzip -r japan
topwqp:linux_training wangqiupeng$ ls
abc hardlk1 japan softlk
abc.gz hardlk2 softlink
topwqp:linux_training wangqiupeng$ cd japan
topwqp:japan wangqiupeng$ ls
boduols.gz cangls longls.gz
topwqp:japan wangqiupeng$
cangls没有压缩是因为 它是一个目录:
opwqp:japan wangqiupeng$ ls -l
total 16
-rw-r--r-- 1 wangqiupeng staff 28 11 27 22:32 boduols.gz
drwxr-xr-x 2 wangqiupeng staff 68 11 27 22:32 cangls
-rw-r--r-- 1 wangqiupeng staff 27 11 27 22:32 longls.gz
topwqp:japan wangqiupeng$
total 16
-rw-r--r-- 1 wangqiupeng staff 28 11 27 22:32 boduols.gz
drwxr-xr-x 2 wangqiupeng staff 68 11 27 22:32 cangls
-rw-r--r-- 1 wangqiupeng staff 27 11 27 22:32 longls.gz
topwqp:japan wangqiupeng$
解压缩命令格式:
gzip -d 压缩文件
或者 gunzip 压缩文件
如果解压的是个目录,目录中有很多压缩文件 可以这样: gunzip -r 压缩目录
3: bz2解压缩:
bz2格式压缩: bzip2 源文件 这个命令会删除掉 源文件
如果想不删除源文件可用如下命令: bzip2 -k 源文件
tips: bzip2 不能够压缩目录
解压:
bzip2 -d 压缩文件
bunzip2 压缩文件
example:
topwqp:linux_training wangqiupeng$ bzip2 abc
topwqp:linux_training wangqiupeng$ ls
abc.bz2 hardlk1 japan softlk
abc.gz hardlk2 softlink
topwqp:linux_training wangqiupeng$ bunzip2 abc.bz2
topwqp:linux_training wangqiupeng$ ls
abc hardlk1 japan softlk
abc.gz hardlk2 softlink
topwqp:linux_training wangqiupeng$
topwqp:linux_training wangqiupeng$ ls
abc.bz2 hardlk1 japan softlk
abc.gz hardlk2 softlink
topwqp:linux_training wangqiupeng$ bunzip2 abc.bz2
topwqp:linux_training wangqiupeng$ ls
abc hardlk1 japan softlk
abc.gz hardlk2 softlink
topwqp:linux_training wangqiupeng$
还有两种压缩格式没有讲 明天继续:
tar.gz格式解压缩:
tar -cvf 打包文件名 源文件
选项: -c 打包 -v显示过程 -f指定打包后的文件名
topwqp:linux_training wangqiupeng$ ls
abc hardlk1 japan softlk
abc.gz hardlk2 softlink
topwqp:linux_training wangqiupeng$ tar -cvf japan.tar japan
a japan
a japan/boduols.gz
a japan/cangls
a japan/longls.gz
topwqp:linux_training wangqiupeng$ ls
abc hardlk1 japan softlink
abc.gz hardlk2 japan.tar softlk
abc hardlk1 japan softlk
abc.gz hardlk2 softlink
topwqp:linux_training wangqiupeng$ tar -cvf japan.tar japan
a japan
a japan/boduols.gz
a japan/cangls
a japan/longls.gz
topwqp:linux_training wangqiupeng$ ls
abc hardlk1 japan softlink
abc.gz hardlk2 japan.tar softlk
topwqp:linux_training wangqiupeng$
再压缩即可:
topwqp:linux_training wangqiupeng$ gzip japan.tar
topwqp:linux_training wangqiupeng$ ls
abc hardlk1 japan softlink
abc.gz hardlk2 japan.tar.gz softlk
topwqp:linux_training wangqiupeng$
topwqp:linux_training wangqiupeng$ ls
abc hardlk1 japan softlink
abc.gz hardlk2 japan.tar.gz softlk
topwqp:linux_training wangqiupeng$
解压缩: tar -xvf 文件名
其中 x 代表 解压缩
example:
opwqp:linux_training wangqiupeng$ ls
abc hardlk1 japan.tar softlk
abc.gz hardlk2 softlink
topwqp:linux_training wangqiupeng$ tar -xvf japan.tar
x japan/
x japan/boduols.gz
x japan/cangls/
x japan/longls.gz
topwqp:linux_training wangqiupeng$ ls
abc hardlk1 japan softlink
abc hardlk1 japan.tar softlk
abc.gz hardlk2 softlink
topwqp:linux_training wangqiupeng$ tar -xvf japan.tar
x japan/
x japan/boduols.gz
x japan/cangls/
x japan/longls.gz
topwqp:linux_training wangqiupeng$ ls
abc hardlk1 japan softlink
abc.gz hardlk2 japan.tar softlk
以上是先打包再压缩: 以下命令可以直接打包后压缩
命令如下:
tar -zcvf 压缩包名.tar.gz 源文件
选项:
-z : 压缩为.tar.gz格式
topwqp:linux_training wangqiupeng$ tar -zcvf japan.tar.gz japan
a japan
a japan/boduols.gz
a japan/cangls
a japan/longls.gz
topwqp:linux_training wangqiupeng$ ls
abc hardlk1 japan softlink
a japan
a japan/boduols.gz
a japan/cangls
a japan/longls.gz
topwqp:linux_training wangqiupeng$ ls
abc hardlk1 japan softlink
abc.gz hardlk2 japan.tar.gz softlk
解压缩命令如下:
tar -zxvf 压缩包名.tar.gz
选项:
-x : 解压缩.tar.gz格式 其中 -C 文件位置,代表解压缩到指定位置
topwqp:linux_training wangqiupeng$ tar -zxvf japan.tar.gz -C ./tmp
x japan/
x japan/boduols.gz
x japan/cangls/
x japan/longls.gz
topwqp:linux_training wangqiupeng$ ls
abc hardlk1 japan softlink tmp
abc.gz hardlk2 japan.tar.gz softlk
topwqp:linux_training wangqiupeng$ cd tmp
topwqp:tmp wangqiupeng$ ls
japan
topwqp:tmp wangqiupeng$
x japan/
x japan/boduols.gz
x japan/cangls/
x japan/longls.gz
topwqp:linux_training wangqiupeng$ ls
abc hardlk1 japan softlink tmp
abc.gz hardlk2 japan.tar.gz softlk
topwqp:linux_training wangqiupeng$ cd tmp
topwqp:tmp wangqiupeng$ ls
japan
topwqp:tmp wangqiupeng$
.tar.bz2压缩格式:
如果是 tar -jcvf 压缩包名.tar.bz2 源文件
解压到指定位置 命令为:
解压缩:
tar -jxvf 压缩包名.tar.bz2
-x:解压缩.tar.bz2格式
解压缩到指定目录下命令如下:
tar -jxvf 压缩文件名.tar.bz2 -C /目录
tar -ztvf 压缩文件名.tar.gz
-z代表不解压,只显示压缩文件中的内容。
topwqp:linux_training wangqiupeng$ tar -ztvf japan.tar.gz
drwxr-xr-x 0 wangqiupeng staff 0 11 27 22:50 japan/
-rw-r--r-- 0 wangqiupeng staff 28 11 27 22:32 japan/boduols.gz
drwxr-xr-x 0 wangqiupeng staff 0 11 27 22:32 japan/cangls/
-rw-r--r-- 0 wangqiupeng staff 27 11 27 22:32 japan/longls.gz
topwqp:linux_training wangqiupeng$
drwxr-xr-x 0 wangqiupeng staff 0 11 27 22:50 japan/
-rw-r--r-- 0 wangqiupeng staff 28 11 27 22:32 japan/boduols.gz
drwxr-xr-x 0 wangqiupeng staff 0 11 27 22:32 japan/cangls/
-rw-r--r-- 0 wangqiupeng staff 27 11 27 22:32 japan/longls.gz
topwqp:linux_training wangqiupeng$
如果想同时压缩多个文件;多个文件名用空格隔开即可:
topwqp:linux_training wangqiupeng$ tar -zcvf japan_abc.tar.gz japan abc
a japan
a japan/boduols.gz
a japan/cangls
a japan/longls.gz
a abc
topwqp:linux_training wangqiupeng$ ls
abc japan softlk
abc.gz japan.tar.gz tmp
hardlk1 japan_abc.tar.gz
hardlk2 softlink
topwqp:linux_training wangqiupeng$ tar -ztvf japan_abc.tar.gz
drwxr-xr-x 0 wangqiupeng staff 0 11 27 22:50 japan/
-rw-r--r-- 0 wangqiupeng staff 28 11 27 22:32 japan/boduols.gz
drwxr-xr-x 0 wangqiupeng staff 0 11 27 22:32 japan/cangls/
-rw-r--r-- 0 wangqiupeng staff 27 11 27 22:32 japan/longls.gz
-rw-r--r-- 0 wangqiupeng staff 0 11 27 22:45 abc
topwqp:linux_training wangqiupeng$
a japan
a japan/boduols.gz
a japan/cangls
a japan/longls.gz
a abc
topwqp:linux_training wangqiupeng$ ls
abc japan softlk
abc.gz japan.tar.gz tmp
hardlk1 japan_abc.tar.gz
hardlk2 softlink
topwqp:linux_training wangqiupeng$ tar -ztvf japan_abc.tar.gz
drwxr-xr-x 0 wangqiupeng staff 0 11 27 22:50 japan/
-rw-r--r-- 0 wangqiupeng staff 28 11 27 22:32 japan/boduols.gz
drwxr-xr-x 0 wangqiupeng staff 0 11 27 22:32 japan/cangls/
-rw-r--r-- 0 wangqiupeng staff 27 11 27 22:32 japan/longls.gz
-rw-r--r-- 0 wangqiupeng staff 0 11 27 22:45 abc
topwqp:linux_training wangqiupeng$
GitHub 加速计划 / li / linux-dash
6
1
下载
A beautiful web dashboard for Linux
最近提交(Master分支:3 个月前 )
186a802e
added ecosystem file for PM2 4 年前
5def40a3
Add host customization support for the NodeJS version 4 年前
更多推荐
已为社区贡献2条内容
所有评论(0)