Linux重要指令梳理
Linux重要指令梳理1.pwd2.clear3.whoami4.ls5.mkdir6.cd7.touch8.问题9.ls1.ls-l2.ls -l -a10.cd11.tree12.touch13.mkdir14.file15.rmdir16.rm17.man指令18.echo19.cat20.用户21.知识点22,文件的拷贝23. MV指令24. cat25.tac26.less27.head指令28.管道29.date30.cal指令31.find32.自己创建一个指令33.which34.file35.whereis36.alias37.grep指令38.打包和压缩指令zip/unzip39.rzsz40.tar1.pwd功能查看当前用户所在工作目录Windows系统里面标识文件唯一性的是通过路径标识的无论是Linux还是Windows我们登录成功都会默认处在一个默认路径下面2.clear功能对当前屏幕清屏3.whoami功能查看当前是谁在访问Linux系统这里的是root账号4.ls功能罗列当前目录下面的文件名文件夹目录rootVM-0-4-ubuntu:~# ls1_2 lesson1 md snap5.mkdir功能在当前目录下面新建一个文件夹/目录rootVM-0-4-ubuntu:~# ls1_2 lesson1 md snap rootVM-0-4-ubuntu:~# mkdir test1rootVM-0-4-ubuntu:~# ls1_2 lesson1 md snap test1上面就新建了test16.cd功能更改路径rootVM-0-4-ubuntu:~# pwd /root rootVM-0-4-ubuntu:~# ls 1_2 lesson1 md snap test1 rootVM-0-4-ubuntu:~# cd md rootVM-0-4-ubuntu:~/md# pwd /root/md上面就是从root目录进入md目录7.touch功能新建一个普通文件文本文件rootVM-0-4-ubuntu:~/md# touch code.c rootVM-0-4-ubuntu:~/md# ls code.c8.问题如果我在Windows新建一个空的文件这个文件要不要占据磁盘空间文件的属性是不是数据答文件文件内容 文件 文件的内容文件属性 文件的内容是文件编写的内容属性则是文件大小命名等等。下面是对一些指令的细化使用以及这些指令的一些细节9.ls1.ls-l更加详细的显示文件属性rootVM-0-4-ubuntu:~/md# ls -ltotal0-rw-r--r--1root root0Jul2413:10 code.c0 Jul 24 13:10 属性这里面的0代表文件大小后面的则是文件创建时间其他属性具体是什么后面会慢慢接触到2.ls -l -a这个指令则会把隐藏的文件也显示出来rootVM-0-4-ubuntu:~/md# ls -l -atotal8drwxr-xr-x2root root4096Jul2413:10.drwx------10root root4096Jul2413:02..-rw-r--r--1root root0Jul2413:10 code.c其中drwxr-xr-x2root root4096Jul2413:10.drwx------10root root4096Jul2413:02..这两行后面有.和… 代表是隐藏文件像ls -la,ls -al这两个指令和ls -l -a 的作用是一样的10.cdcd~的使用:对于root账号这个指令可以直接跳到root文件夹下面rootVM-0-4-ubuntu:~/md/a# pwd/root/md/a rootVM-0-4-ubuntu:~/md/a# cd ~rootVM-0-4-ubuntu:~# pwd/rootcd - 的使用回退到上次所处的路径rootVM-0-4-ubuntu:~/md/a# pwd/root/md/a rootVM-0-4-ubuntu:~/md/a# cd ~rootVM-0-4-ubuntu:~# pwd/root rootVM-0-4-ubuntu:~# cd -/root/md/a在Linux中 . 代表当前文件而 … 代表上级目录所以可以使用cd…返回上级目录而一直使用cd…则会退到根目录rootVM-0-4-ubuntu:~/md# pwd/root/md rootVM-0-4-ubuntu:~/md# cd ..rootVM-0-4-ubuntu:~# pwd/root目录的本质是树形结构的结论1这颗多叉树叶子节点一定是普通文件或者空的文件夹节点2非叶子节点的本质是文件夹或者目录在Linux里面任何一个目录都会包含 . 和 … 两个文件但它们是隐藏的而根目录的 … 是指向自己11.tree功能查看上级目录的树状结果rootVM-0-4-ubuntu:~# tree.├── 1_2 ├── lesson1 │?? └── code.c ├── md │?? └── code.c ├── snap │?? └── lxd │?? ├──38800│?? ├──40115│?? ├── common │?? └── current -40115└── test110directories,2files注意如果第一次使用需要自己安装tree这个指令安装指令centos:yuminstall-ytree ubuntu:aptinstall-ytree12.touchrootVM-0-4-ubuntu:~/md/a# touch hellow.txtrootVM-0-4-ubuntu:~/md/a# ls -ltotal0-rw-r--r--1root root0Jul2422:30 hellow.txt rootVM-0-4-ubuntu:~/md/a# stat hellow.txtFile: hellow.txt Size:0Blocks:0IO Block:4096regular emptyfileDevice: fc02h/64514d Inode:657248Links:1Access:(0644/-rw-r--r--)Uid:(0/ root)Gid:(0/ root)Access:2026-07-2422:30:33.994008266 0800 Modify:2026-07-2422:30:33.994008266 0800 Change:2026-07-2422:30:33.994008266 0800 Birth:2026-07-2422:30:33.994008266 0800这里创建了hellow.txt文本并且注意AccessModifyChange 这三个时间rootVM-0-4-ubuntu:~/md/a# touch hellow.txtrootVM-0-4-ubuntu:~/md/a# stat hellow.txtFile: hellow.txt Size:0Blocks:0IO Block:4096regular emptyfileDevice: fc02h/64514d Inode:657248Links:1Access:(0644/-rw-r--r--)Uid:(0/ root)Gid:(0/ root)Access:2026-07-2422:34:04.863318660 0800 Modify:2026-07-2422:34:04.863318660 0800 Change:2026-07-2422:34:04.863318660 0800 Birth:2026-07-2422:30:33.994008266 0800再次使用touch文本的时间属性就会更新13.mkdirmkdir -p x:创建一串目录rootVM-0-4-ubuntu:~/md/a# mkdir -p a/b/c/drootVM-0-4-ubuntu:~/md/a# tree.├── a │ └── b │ └── c │ └── d └── hellow.txt4directories,1filerootVM-0-4-ubuntu:~/md/a# lsa hellow.txt要注意在Linux里面文件的后缀不决定文件的类型比如test.c只是一个文本文件不一定里面就是代码框住的这一列就代表文件的类型其中d代表目录文件而‘-’代表普通文件普通文件包括文本二进制可执行程序图片音视频等等。14.file功能查看文件类型rootVM-0-4-ubuntu:~/md/a# file aa: directory15.rmdir功能用于删除空目录rootVM-0-4-ubuntu:~/md/a# tree.├── a │ └── b │ └── c │ └── d ├── b ├── c ├── d └── hellow.txt5directories,3files rootVM-0-4-ubuntu:~/md/a# rmdir armdir: failed to removea:Directory not empty rootVM-0-4-ubuntu:~/md/a# rmdir drootVM-0-4-ubuntu:~/md/a# tree.├── a │ └── b │ └── c │ └── d ├── b ├── c └── hellow.txt4directories,3files rootVM-0-4-ubuntu:~/md/a# rmdir brmdir: failed to removeb:Not a directory从上面可以看出删除a失败就是因为a目录不是空的而删除b失败是因为b是文件不是目录16.rm功能可用于删除有内容的文件在Linux里面使用rm删除的东西不可以恢复但是它在删除的时候会询问是否要删除。rm -f代表强制删除这个不会询问是否要删除但是这个依旧删除不了有内容的目录如果要删除有文件的内容且内容文件里面还有文件的就要使用递归删除 rm -r arootVM-0-4-ubuntu:~/md# tree.└── a ├── a │ └── b │ └── c │ └── d ├── b ├── c └── hellow.txt5directories,3files rootVM-0-4-ubuntu:~/md# rm -r arootVM-0-4-ubuntu:~/md# tree.0directories,0files17.man指令用来看一个指令是干什么的rootVM-0-4-ubuntu:~/test1# man tree18.echo功能默认往显示器上打印东西在Linux系统下面一切皆文件1.向显示器打印–就是向显示器文件进行写入2.从键盘scanf读取数据–从键盘文件读取数据rootVM-0-4-ubuntu:~/test1# echo hellowhellow下面使用‘’echo本来是要将内容写入到显示器文件的而‘就是将echo输出的内容写到hellow.txt,进行了重定向而如果这个文件本来不存在的话就会新建。注意每次写入都会将原始数据清除再写入rootVM-0-4-ubuntu:~/test1# ls -al total 12 drwxr-xr-x 3 root root 4096 Aug 4 22:57 . drwx------ 6 root root 4096 Aug 4 22:45 .. drwxr-xr-x 2 root root 4096 Aug 4 22:32 a -rw-r--r-- 1 root root 0 Aug 4 22:36 code.c rootVM-0-4-ubuntu:~/test1# echo hello world hellow.txt rootVM-0-4-ubuntu:~/test1# la -al total 16 drwxr-xr-x 3 root root 4096 Aug 4 22:58 . drwx------ 6 root root 4096 Aug 4 22:45 .. drwxr-xr-x 2 root root 4096 Aug 4 22:32 a -rw-r--r-- 1 root root 0 Aug 4 22:36 code.c -rw-r--r-- 1 root root 12 Aug 4 22:58 hellow.txt如果使用hellow.txt这是清空指定文件清空其中的内容下面这个是写入后不删除之前的内容 ‘’ 追加重定向rootVM-0-4-ubuntu:~/test1# cat code.crootVM-0-4-ubuntu:~/test1# echo aaaaaaacccc code.crootVM-0-4-ubuntu:~/test1# echo aaaaaaacccc code.crootVM-0-4-ubuntu:~/test1# echo aaaaaaacccc code.crootVM-0-4-ubuntu:~/test1# echo aaaaaaacccc code.crootVM-0-4-ubuntu:~/test1# echo aaaaaaacccc code.crootVM-0-4-ubuntu:~/test1# cat code.c //使用cat查看文件内容aaaaaaacccc aaaaaaacccc aaaaaaacccc aaaaaaacccc aaaaaaacccc注意还有一个输出重定向 ’从文件中获取数据19.cat功能获取文件内容rootVM-0-4-ubuntu:~/test1# cat hellow.txthello world 获取hellow.txt 文本文件的内容下面这个加上 -n 可以给每一行内容加上数据rootVM-0-4-ubuntu:~/test1# cat test.chello world hello world1 rootVM-0-4-ubuntu:~/test1# cat -n test.c1hello world 打印的时候加上了序号2hello world120.用户新建用户sudo adduser 用户名切换用户su用户名下面可以使用指令看到创建的用户 la /dev/pts -lwyj1VM-0-4-ubuntu:/root/test1$ la /dev/pts-ltotal0crw-------1roottty136,0Aug518:030crw-------1roottty136,1Aug518:341c---------1root root5,2Jun2521:29 ptmx3,4两行的0,1代表两个终端下面展示往其他终端写入东西的指令wyj1VM-0-4-ubuntu:/root/test1$echohellow/dev/pts/0 //往终端0这个用户写入内容21.知识点在Linux里面一切皆文件是不是也代表xshell终端也是文件呢–对的22,文件的拷贝使用 cp x y 将x的内容拷贝给yrootVM-0-4-ubuntu:~/test1# lsa code.c test.c rootVM-0-4-ubuntu:~/test1# cat code.chello world hello world1 rootVM-0-4-ubuntu:~/test1# cat test.crootVM-0-4-ubuntu:~/test1# cp code.c test.crootVM-0-4-ubuntu:~/test1# cat test.chello world hello world1当使用cp进行拷贝的时候如果y文件原来是没有的那么就会自己创建这个文件然后将内容拷贝进去rootVM-0-4-ubuntu:~/test1# lsa code.c test.c rootVM-0-4-ubuntu:~/test1# cp code.c test1.c 由于test1.c原本是没有的所以会先创建再拷贝rootVM-0-4-ubuntu:~/test1# lsa code.c test1.c test.c rootVM-0-4-ubuntu:~/test1# cat test1.chello world hello world1也可以将文件拷贝到上级目录rootVM-0-4-ubuntu:~/test1# tree ../ 查看上个路径的数结构其中 ../ 代表上个路径../ └── test1 ├── a ├── code.c ├── test1.c └── test.c2directories,4files rootVM-0-4-ubuntu:~/test1# cp code.c ../ 将code.c这个文件拷贝到上个路径rootVM-0-4-ubuntu:~/test1# tree ../../ ├── code.c └── test1 ├── a ├── code.c ├── test1.c └── test.c2directories,5files拷贝目录文件使用上面的cp x y 这是不可以的因为目录里面可能还有目录所有要使用到递归“cp -rf x y” 将目录x拷贝到y里面rootVM-0-4-ubuntu:~# tree 当前说有目录结果.├── test1 │ ├── a │ ├── code.c │ ├── test1.c │ └── test.c └── test2 ├── q └── w └── e6directories,3files rootVM-0-4-ubuntu:~# cp -rf test2 test2-1#将test2拷贝复制到test2-1由于test2-1原本不存在所以首先会创建test2-1再拷贝rootVM-0-4-ubuntu:~# tree.├── test1 │ ├── a │ ├── code.c │ ├── test1.c │ └── test.c ├── test2 │ ├── q │ └── w │ └── e └── test2-1 ├── q └── w └── e10directories,3files23. MV指令功能转移指令rootVM-0-4-ubuntu:~/test1# tree .. 最初当前文件树状结构..├── test1 │ ├── a │ ├── test1.c │ ├── test2 │ └── test.c ├── test2 │ ├── q │ └── w │ └── e └── test2-1 ├── q └── w └── e10directories,3files rootVM-0-4-ubuntu:~/test1# mv test.c .. 将test.c文件转移到上级目录rootVM-0-4-ubuntu:~/test1# tree ....├── test1 │ ├── a │ ├── test1.c │ └── test2 ├── test2 │ ├── q │ └── w │ └── e ├── test2-1 │ ├── q │ └── w │ └── e └── test.c 从这里可以看到test.c这个文件转移到了这里10directories,3files上面转移的是文本文件而目录文件是不可以使用mv指令进行转移的24. cat对于mv指令还可以用来进行重命名rootVM-0-4-ubuntu:~/test1# tree ....├── test1 │?? ├── a │?? ├── test1.c │?? └── test2 └── test2 ├── q └── w └── e6directories,2files rootVM-0-4-ubuntu:~/test1# mv test1.c test.c 将test1.c这个文件重命名为test,crootVM-0-4-ubuntu:~/test1# tree.├── a ├── test2 └── test.c1directory,2files这个重命名是对原本的文件剪拷贝在重新生成完成重命名25.tac功能和cat相似只不过是倒序打印rootVM-0-4-ubuntu:~/test1# cat test.chello world hello world1 rootVM-0-4-ubuntu:~/test1# tac test.chello world1 hello world26.less功能这个指令也和cat差不多可以显示文件内容但是文件过多的时候不会像cat那样刷屏可以使用回车上下键进行上下移动查看像cat打印文件内容查看小文件当内容过多就会导致一直刷屏而less和more这两个指令可以上下查找搜索关键字而less又比more更加常用但是less一般要搭配其他指令使用才可以发挥重要作用。27.head指令head和tail用来显示开头或结尾某个数量的文字区块head用来显示档案的开头至标准输出中而tail就是看档案的结尾head默认用来显示文档的开头10行rootVM-0-4-ubuntu:~/test1# cat test.c 查看了所有内容hello1hello2hello3hello4echohello5hello5hello6hello7hello8hello9hello10hello11hello12rootVM-0-4-ubuntu:~/test1# head test.c head test.c默认查看前十行数据hello1hello2hello3hello4echohello5hello5hello6hello7hello8hello9hello10rootVM-0-4-ubuntu:~/test1#rootVM-0-4-ubuntu:~/test1# head -3 test.c 加上 -3 可以使得只打印指点的行数hello1hello2hello3rootVM-0-4-ubuntu:~/test1#rootVM-0-4-ubuntu:~/test1# tail test.c 查看后10行数据hello3hello4echohello5hello5hello6hello7hello8hello9hello10hello11hello1228.管道rootVM-0-4-ubuntu:~/test1# for i in {13..1000}; do echo hello $i test.c; done这个指令是创建1000个hello i这样的内容其中i代表数字这就是执行前面那个指令得来的结果而这些知识结果的最后一部分 hello981hello982hello983hello984hello985hello986hello987hello988hello989hello990hello991hello992hello993hello994hello995hello996hello997hello998hello999hello1000这里来说明管道的一些作用例如用来得到文本中间的内容rootVM-0-4-ubuntu:~/test1# head -100 test.c | tail -20 //head -100 test.c 代表取头部100行数据hello93//|这个竖杠代表管道tail -20代表取刚刚取 hello94//100行数据的后20行数据 hello95//整条指令代表的意思是取100条数据放到管道里面管道用来传输资源再取出管道后20行数据 hello96hello97hello98hello99hello100hello101hello102hello103hello104hello105hello106hello107hello108hello109hello110hello111hello112Linux里面一切皆文件而管道也是文件29.date功能用来打印当前时间rootVM-0-4-ubuntu:~/test1# dateThu Aug1309:48:59 PM CST2026rootVM-0-4-ubuntu:~/test1# date %Y-%m-%d %H:%M:%S //%Y-%m-%d %H:%M:%S 这些对格式进行规范2026-08-1321:57:5530.cal指令用来显示公历日历-但是要注意这个指令需要自己下载rootVM-0-4-ubuntu:~/test1# calAugust2026Su Mo Tu We Th Fr Sa1234567891011121314151617181920212223242526272829303131.find功能用于在文件树中查找文件并做出相应的处理(可能访问磁盘)rootVM-0-4-ubuntu:~/test1# find ~/ -name q 在家目录找所有文件q的路径/root/test2/q下面是find结合通配符的使用rootVM-0-4-ubuntu:~/test2# find ~/ -name *.c 找到所有后缀为.c的文件 *就是通配符后面可以是任何字符/root/test1/code.c /root/test1/test1.c /root/test1/test.c用find查找指令rootVM-0-4-ubuntu:~/test2# find / -name ls/usr/bin/ls /usr/lib/klibc/bin/ls /usr/local/qcloud/YunJing/bin/ls /snap/core22/2411/usr/bin/ls /snap/core20/2669/usr/bin/ls /snap/core20/2866/usr/bin/ls从这里也可以发现指令也是文件本质就是可执行文件32.自己创建一个指令首先要船舰一个程序我这里首先使用touch创建一个code.c的文本文件再使用nano指令往code.c文本里面写入代码这里我简单写的一个打印hello world 的指令intmain(){printf(hello world);return0;}//这是指令的代码使用gcc code.c对这个代码进行编译可以得到一个a.out文件再使用指令 mv a.out mycmd 将 a.out改名为mycmd后面mycmd就是一个自己创建的指令了。但是到这一步mycmd还不可以直接作为指令运行因为这个命令还没有放到存放指令专门的路径下面再使用cp mycmd /usr/bin/ 将mycmd这个指令拷贝到/usr/bin/ 这个路径下面使其成为真正的指令下面是使用指令的执行结果rootVM-0-4-ubuntu:~/test1# mycmdhello worldrootVM-0-4-ubuntu:~/test1# //打印了hello world上面就是自己创建一个指令的过程33.which功能展示指定命令的全部路径hello worldrootVM-0-4-ubuntu:~/test1# which ls/usr/bin/ls rootVM-0-4-ubuntu:~/test1# which tree/usr/bin/tree34.file功能查看指令类型rootVM-0-4-ubuntu:~/test1# file code.ccode.c: C source, ASCII text //一个C语言程序35.whereis功能whereis命令用于在Linux系统中查找可执行文件二进制文件及手册页搜索范围限定在系统预设路径不包含用户自设路径。与find命令相比whereis搜索路径固定且有限主要针对系统核心目录进行快速定位。rootVM-0-4-ubuntu:~/test1# whereis lsls: /usr/bin/ls /usr/share/man/man1/ls.1.gz36.alias功能创建别名rootVM-0-4-ubuntu:~/test1# alias ls1ls -a -l //将ls -a -l 这个指令重命名为ls1rootVM-0-4-ubuntu:~/test1# ls1total48drwxr-xr-x3root root4096Aug1410:44.drwx------8root root4096Aug1409:56..drwxr-xr-x2root root4096Aug422:32 a -rw-r--r--1root root69Aug1410:40 code.c -rwxr-xr-x1root root15960Aug1410:41 mycmd -rw-r--r--1root root0Aug1409:35 test1.c -rw-r--r--1root root25Aug1308:49 test2 -rw-r--r--1root root9843Aug1410:01 test.c取消设置的别名就只需要将别名设置为空就可以了rootVM-0-4-ubuntu:~/test1# alias ls1 要注意起的别名是内存级的并不在文件中真实存在就是在操作系统内部一旦退出也就没有了。当换一个终端也一样别名也不起作用了。37.grep指令功能在文件中搜索字符串将找到的行打印出来rootVM-0-4-ubuntu:~/test1# grep 99 test.c //将test.c里面的所有含有99的行筛选出来hello99hello199hello299hello399hello499hello599hello699hello799hello899hello990hello991hello992hello993hello994hello995hello996hello997hello998hello999这里还可以结合管道进行数据的筛选可以给要筛选得到数据加上更多的约束rootVM-0-4-ubuntu:~/test1# cat test.c | head -210 | tail -100 | grep 8hello128//读取 test.c 前210行数据 取最后100个数据 里面的含8的数据 hello138hello148hello158hello168hello178hello180hello181hello182hello183hello184hello185hello186hello187hello188hello189hello198hello208hello218rootVM-0-4-ubuntu:~/test1# cat test.c | head -210 | tail -100 | grep -n 86:hello128//在grep后面加上-n这里相比于上面给每一行数据都加上了序号16:hello13826:hello14836:hello15846:hello16856:hello17858:hello18059:hello18160:hello18261:hello18362:hello18463:hello18564:hello18665:hello18766:hello18867:hello18976:hello19886:hello20896:hello218rootVM-0-4-ubuntu:~/test1# grep -v hello code.c 将code.c这个文本里面除了含有hello的所有行都打印#includestdio.hintmain(){return0;}小结-n 顺便输出行号-i 忽略大小写不同将大小写视为相同-v :反向选择。即显示出没有‘ 搜索字符串’内容的那一行38.打包和压缩指令zip/unziprootVM-0-4-ubuntu:~# zip test1.zip test1 //将test1压缩为哦test1.zipadding: test1/(stored0%)rootVM-0-4-ubuntu:~# lstest1 test1.zip test2 rootVM-0-4-ubuntu:~# mkdir test3 //新建一个文件夹rootVM-0-4-ubuntu:~# mv test1.zip test3 //将被压缩的文件放到test3里面rootVM-0-4-ubuntu:~# lstest1 test2 test3 rootVM-0-4-ubuntu:~# cd test3rootVM-0-4-ubuntu:~/test3# ls //查看发现压缩包以及放到test3里面了test1.zip 接下来进行解压缩 rootVM-0-4-ubuntu:~/test3# unzip test1.zip //解压缩Archive: test1.zip creating: test1/ rootVM-0-4-ubuntu:~/test3# cd test1rootVM-0-4-ubuntu:~/test3/test1# ll //这里会发现test1里面并没有内容这是什么问题呢total8drwxr-xr-x2root root4096Aug1410:44 ./ drwxr-xr-x3root root4096Aug1416:33../之所以出现上面压缩包打开以后test1里面上面都没有是因为test1的结果是树状结果打包压缩也要递归打包才可以将上面压缩的指令改成下面的就可以了rootVM-0-4-ubuntu:~# zip -r test1.zip test1//-r 代表递归解压缩的时候无需递归rootVM-0-4-ubuntu:~/test3# tree.└── test1.zip0directories,1filerootVM-0-4-ubuntu:~/test3# unzip test1.zip //解压缩Archive: test1.zip creating: test1/ extracting: test1/code.c creating: test1/a/ extracting: test1/test1.c inflating: test1/test.c inflating: test1/mycmd inflating: test1/test2 rootVM-0-4-ubuntu:~/test3# tree //解压缩后的结果├── test1 │ ├── a │ ├── code.c │ ├── mycmd │ ├── test1.c │ ├── test2 │ └── test.c └── test1.zip2directories,6files39.rzsz功能用于window机器与远端的Linxu机器通过xshell传输文件安装完毕以后可以通过拖拽的方法将文件上传上去40.tar功能打包/解压不打开它直接看内容-c建立一个压缩文件的参数指令 (create 的意思)-x解开一个压缩文件的参数指令-t查看 tarfile 里面的文件-z是否同时具有 gzip 的属性亦即是否需要用 gzip 压缩-j是否同时具有 bzip2 的属性亦即是否需要用 bzip2 压缩-v压缩的过程中显示文件这个常用但不建议用在背景执行过程-f使用档名请留意在 f 之后要立即接档名喔不要再加参数-C解压到指定目录rootVM-0-4-ubuntu:~# tar czf test1.zip test1 //压缩过程rootVM-0-4-ubuntu:~# lstest1 test1.zip test2 解压缩 rootVM-0-4-ubuntu:~/test3# tar xzf test1.ziprootVM-0-4-ubuntu:~/test3# tree.├── test1 │ ├── a │ ├── code.c │ ├── mycmd │ ├── test1.c │ ├── test2 │ └── test.c └── test1.zip2directories,6files