top 指令
top
:相当于 windows 中的任务管理器
zip 和 unzip 指令
语法: zip 压缩文件.zip 目录或文件
功能: 将目录或文件压缩成zip格式
常用选项:
- -r 递归处理,将指定目录下的所有文件和子目录一并处理
zip -r 压缩文件.zip 目录或文件名
:压缩一个文件
[root@VM-4-3-centos lesson3]# zip -r testcp1.zip testcp1 adding: testcp1/ (stored 0%) adding: testcp1/newnew.txt (stored 0%) adding: testcp1/a/ (stored 0%) adding: testcp1/a/b/ (stored 0%) adding: testcp1/a/b/c/ (stored 0%) adding: testcp1/a/b/c/d/ (stored 0%) adding: testcp1/a/test.txt (stored 0%) [root@VM-4-3-centos lesson3]# ll total 44 drwxr-xr-x 2 root root 4096 Nov 19 16:34 mydir drwxr-xr-x 2 root root 4096 Nov 19 02:03 mydirdir -rw-r--r-- 1 root root 9901 Nov 19 14:06 mylog.txt -rw-r--r-- 1 root root 74 Nov 19 15:41 test.c drwxr-xr-x 3 root root 4096 Nov 19 02:57 testcp1 -rw-r--r-- 1 root root 1110 Nov 19 17:16 testcp1.zip //打包成功 drwxr-xr-x 4 root root 4096 Nov 19 16:06 testcp2 -rw-r--r-- 1 root root 5090 Nov 19 14:54 tmp.txt
unzip 压缩文件
:解包到当前路径
[root@VM-4-3-centos lesson3]# cp testcp1.zip /root // 拷贝文件到上一路径 [root@VM-4-3-centos lesson3]# ll .. total 16 drwxr-xr-x 2 root root 4096 Nov 17 15:13 dir drwxr-xr-x 2 root root 4096 Nov 17 15:47 lesson2 drwxr-xr-x 6 root root 4096 Nov 19 17:17 lesson3 -rw-r--r-- 1 root root 1110 Nov 19 17:18 testcp1.zip [root@VM-4-3-centos lesson3]# cd .. [root@VM-4-3-centos ~]# unzip testcp1.zip // 解包 Archive: testcp1.zip creating: testcp1/ extracting: testcp1/newnew.txt creating: testcp1/a/ creating: testcp1/a/b/ creating: testcp1/a/b/c/ creating: testcp1/a/b/c/d/ extracting: testcp1/a/test.txt [root@VM-4-3-centos ~]# tree testcp1 // 解包成功 testcp1 |-- a | |-- b | | `-- c | | `-- d | `-- test.txt `-- newnew.txt 4 directories, 2 files
打包压缩的意义:防止数据丢失并节省空间。