linux 学习笔记Linux学习笔记请切换web视图查看,表格比较大,方法:视图》》web板式视图
博客园不能粘贴图片吗
http://wenku.baidu.com/view/bda1c3067fd5360cba1adb7d
目录
Linux学习笔记... 1
请切换web视图查看,表格比较大,方法:视图》》web板式视图... 1
1. 常用命令... 3
1.1文件处理命令... 3
1.2权限管理命令... 8
1.3文件搜索命令... 12
1.4帮助命令... 19
1.5压缩解压命令... 20
1.6网络通信指令... 23
1.7 Shell应用技巧... 25
2. Vim/Vi 28
3. 引导... 34
4软件包的安装... 39
4.1挂载光盘... 39
5.用户管理... 40
5.1组管理... 41
5.2批量添加用户... 41
6. 进程管理... 44
6.2计划任务... 45
7. shell编程... 46
7.1 hello world. 46
7.2标准输入和输出... 46
7.2变量,位置变量$! $$ $# $@ $* $?,环境变量,运算符... 47
7.3if…else. 52
7.4for. 53
7.5awk. 54
7.6一个显示用户信息的脚本... 54
7.7一个杀死登陆用户的脚本... 56
结果如下... 56
脚本内容... 56
7.8select case. 57
select. 57
select+case. 57
case. 58
7.9while. 59
7.10批量添加用户... 59
7.11批量删除用户... 60
7.12break .. continue. 60
7.13 shift,参数累加求和... 61
效果: 参数左移... 61
7.14用户执行脚本的权限... 62
sh script. 62
1. 对脚本有r权限... 62
2. 脚本所在目录要有r-x权限... 62
脚本直接执行... 62
1. 对脚本有rx权限... 62
2. 脚本所在目录有rx权限... 62
7.15正则表达式... 62
7.16截取字符串awk,cut,set. 65
awk 列操作... 66
第一行不执行,第一行先读取的... 66
所以加BEGIN.. 67
行操作... 67
选取某一行... 68
去掉某一行... 68
追加某一行或几行... 68
替换... 69
7.17定时任务... 69
8. 安装jdk. 71
[root@dc-01 java]# rpm -qa | grep jdk. 71
java-1.6.0-openjdk-1.6.0.0-1.45.1.11.1.el6.i686. 71
卸载之:... 71
[root@dc-01 java]# yum -y remove java-1.6.0-openjdk-1.6.0.0-1.45.1.11.1.el6.i686. 71
查看系统位数... 71
下载对应的安装包... 71
http://pan.baidu.com/s/1qWnzJCK. 71
1.修改权限为可执行... 71
2.rpm –ivh 安装包... 71
3.vi /etc/PRofile 尾部添加环境变量... 72
79 JAVA_HOME=/usr/java/jdk1.7.0_67. 72
80 PATH=$JAVA_HOME/bin:$PATH.. 72
81 CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar. 72
82 export JAVA_HOME. 72
83 export PATH.. 72
84 export CLASSPATH.. 72
4. 执行source /etc/profile命令让修改生效。... 72
5.查看安装结果... 72
至此,安装jdk成功... 73
9. 安装Tomcat. 73
1.下载安装包,千万选好安装源,因为安装包的问题,硬是让我调试了一天,真是傻逼,重新官网下载安装之后立马可以用了... 73
http://tomcat.apache.org/download-70.cgi 73
2.解压到/usr/local 下,并重命名为tomcat. 73
#tar zxvf apache-tomcat-7.0.35.tar.gz /解压... 73
#mv apache-tomcat-7.0.35 apache-tomcat /更名... 73
#cd /apache-tomcat/bin/ /打开此目录... 74
#chmod 777 *.sh /加777权限... 74
#bash catalina.sh start /启动... 74
1. 常用命令命令存放,哪些命令可以执行?
root:
/sbin
/usr/sbin
all users:
/bin
/usr/bin
bin--binary 二进制文件
Linux所有都是文件,都是二进制文件
usr—user
sbin—super binary
1.1文件处理命令
文件处理命令
1
ls
英文原意是list 功能:显示目录文件 属性可以连着写,比如ls -ld
Eg
含义
-a all
显示所有文件,包括隐藏文件
ls -a /
-l long
-I 显示i节点
详细信息显示
[root@localhost ~]# ls -l
total 68
-rw------- 1 root root 1211 Feb 14 04:02 anaconda-ks.cfg
drwxr-xr-x 3 root root 4096 Feb 14 11:20 Desktop
-rw-r--r-- 1 root root 31736 Feb 14 04:02 install.log
-rw-r--r-- 1 root root 0 Feb 14 03:16 install.log.syslog
drwxr-xr-x 2 root root 4096 Feb 14 17:36 test
drwxr-xr-x 2 root root 4096 Feb 14 11:20
每三个表示权限 表示硬连接数 所有者 所属组 文件大小 创建时间
数据块 block 512字节
第一个字符表示如下:
d 目录directory
- 二进制文件
l 软链接文件
每三个分配如下:
r—read 读 w—write写 x—execute执行
rwx r-x r-x
所有者u 所属组g 其他人o
user group others
-d
查看目录属性
[root@localhost ~]# ls -ld /test
drwxr-xr-x 3 root root 4096 Feb 14 17:42 /test
2
cd
切换目录
Cd /
进入根目录
Cd [目录]
Cd ..
返回父级目录
3
pwd
英文:print working directory
查看当前目录
[root@localhost ~]# pwd
/root
4
touch
创建空文件
[root@localhost test]# touch testfile
[root@localhost test]# ls -l testfile
-rw-r--r-- 1 root root 0 Feb 14 18:51 testfile
5
mkdir
英文:make directories
创建空目录
[root@localhost ~]# mkdir test
6
cp
英文:copy
复制文件
-R 复制目录
copy [源文件,可多个] [目的目录]
[root@localhost test]# cp /etc/inittab /etc/services /test
[root@localhost test]# ls /test
abc.txt inittab lost+found samlee services testfile
将etc拷贝到test下
[root@localhost test]# cp -R /etc /test
/etc 主要是配置文件,很重要,记得备份
命令停止快捷键:Ctrl+c
7.
mv
英文:move
移动文件,改名
[root@localhost test]# ls /test
abc.txt etc inittab lost+found samlee services testfile
改名:
[root@localhost test]# mv services service
[root@localhost test]# ls /test
abc.txt etc inittab lost+found samlee service testfile
移动:
[root@localhost test]# mv /test/inittab /tmp/
[root@localhost test]# ls /test
abc.txt etc lost+found samlee service testfile
改名+移动:
[root@localhost test]# mv /test/testfile /tmp/file.test
[root@localhost test]# ls /tmp
file.test scim-panel-socket:0-root
gconfd-root scim-socket-frontend-root
inittab ssh-yoUWCY4180
keyring-z1fmdW virtual-root.IYU2ep
mapping-root vmware-config0
orbit-root VMwareDnD
scim-bridge-0.3.0.lockfile-0@localhost:0.0 vmware-root
scim-bridge-0.3.0.socket-0@localhost:0.0 vmware-root-592157060
scim-helper-manager-socket-root
8
rm
remove
删除
[root@localhost test]# ls /test
abc.txt etc lost+found samlee service
删除service
[root@localhost test]# rm service
rm: remove regular file `service'? y
[root@localhost test]# ls /test
abc.txt etc lost+found samlee
删除不询问:
[root@localhost test]# touch testfile
[root@localhost test]# ls
abc.txt etc lost+found samlee testfile
[root@localhost test]# rm -f testfile
[root@localhost test]# ls
abc.txt etc lost+found samlee
rm –f 目录名称 不提示,强制删除,在写脚本的时候用,因为没有yes交互
r表示删除,f表示强制
9
cat
concatenate and display files
查看
[root@localhost test]# cat /etc/issue
CentOS release 5.5 (Final)
Kernel \r on an \m
适合查看文件小,因为多的话会把前面的覆盖,不能翻页。
比如cat /etc/services
10
more
(空格)或f 显示下一页
(enter)显示下一行
q或Q 退出
分页查看
[root@localhost test]# more /etc/services
11
head
-num 文件名
查看文件前num行
[root@localhost test]# head -5 /etc/services
# /etc/services:
# $Id: services,v 1.42 2006/02/23 13:09:23 pknirsch Exp $
#
# Network services, Internet style
#
12
tail
-num 文件名
-f 文件名
查看文件尾num行
动态查看文件尾部信息
[root@localhost test]# tail -5 /etc/services
com-bardac-dw 48556/tcp # com-bardac-dw
com-bardac-dw 48556/udp # com-bardac-dw
iqobject 48619/tcp # iqobject
iqobject 48619/udp # iqobject
# Local services
[root@localhost test]# tail -f /etc/services
tail –f 为了监视日志文件,默认显示10行
13
ln
英文:link
ln 文件名 目的目录
ln –s 文件名 目的目录
-s soft软连接
创建硬链接
创建软链接
[root@localhost test]# ln -s /etc/issue /issue.soft
[root@localhost test]# ls -l /etc/issue /issue.soft
-rw-r--r-- 1 root root 47 Apr 26 2010 /etc/issue
lrwxrwxrwx 1 root root 10 Feb 14 16:51 /issue.soft -> /etc/issue
硬链接:
[root@localhost test]# ln /etc/issue /issue.hard
[root@localhost test]# ls -l /etc/issue /issue.hard
-rw-r--r-- 2 root root 47 Apr 26 2010 /etc/issue
-rw-r--r-- 2 root root 47 Apr 26 2010 /issue.hard
拷贝:
[root@localhost test]# cp /etc/issue /test/issue
[root@localhost test]# ls -l /etc/issue /test/issue
-rw-r--r-- 2 root root 47 Apr 26 2010 /etc/issue
-rw-r--r-- 1 root root 47 Feb 14 20:31 /test/issue
拷贝并且不改变时间,比如某些备份
[root@localhost test]# cp -p /etc/issue /test/issue
cp: overwrite `/test/issue'? y
[root@localhost test]# ls -l /etc/issue /test/issue
-rw-r--r-- 2 root root 47 Apr 26 2010 /etc/issue
-rw-r--r-- 1 root root 47 Apr 26 2010 /test/issue
软连接文件类型是l
软连接所有人都有权限,但能不能访问取决于源文件
软连接时间值 是创建软连接的时间
相当于快捷方式
类似于copy,文件大小相同
不同于copy的是,它是同步更新的。
还有一个不同的是,拷贝的时间是不同,时间是创建的时间
一个i节点可以映射到多个文件,所以硬链接可以同步更新。
1.2权限管理命令权限管理命令
14
chmod
change the permissions mode of a file
chmod[{ugo0}{+-=}[文件或目录][mode=421][文件或目录]
功能:
改变文件或目录权限
用数字表示
r--4
w--2
x—1
rwxr-xr-- 754
rw-r-x—x 651
文件:
r-car,more,head,tail
w-echo,vi 可以修改内容
x-命令,脚本
目录:
r-ls
w-touch,mkdir,rm 对目录有这些权限
x-cd 对目录可以进去
所以,所有的目录都有rx权限,表示可以读取可以进去
[root@localhost test]# ls -l a
-rwxr-x--- 1 root root 0 Feb 19 15:45 a
[root@localhost test]# chmod o+rwx a
[root@localhost test]# ls -l a
-rwxr-xrwx 1 root root 0 Feb 19 15:45 a
[root@localhost test]# chmod o-rw a
[root@localhost test]# ls -l a
-rwxr-x--x 1 root root 0 Feb 19 15:45 a
[root@localhost test]# chmod g=r a
[root@localhost test]# ls -l a
-rwxr----x 1 root root 0 Feb 19 15:45 a
[root@localhost test]# chmod g=rx a
[root@localhost test]# ls -l a
-rwxr-x--x 1 root root 0 Feb 19 15:45 a
[root@localhost test]# chmod 641 a
[root@localhost test]# ls -l a
-rw-r----x 1 root root 0 Feb 19 15:45 a
chmod u+权限 文件或目录-------给所属者增加权限
chmod u+权限 文件或目录-------给所属者减少权限
chmod g=权限 文件或目录-------给所属组赋予权限
chmod o -----------------------------------同u,为加减权限
用数字表示权限,直接赋值就可以 chmod 641 a
15
chown
change file ownership
改变所有者
[root@localhost test]# ls -l a
-rw-r----x 1 root root 0 Feb 19 15:45 a
[root@localhost test]# chown helen a
[root@localhost test]# ls -l a
-rw-r----x 1 helen root 0 Feb 19 15:45 a
[root@localhost test]# chown nobody a
[root@localhost test]# ls -l a
-rw-r----x 1 nobody root 0 Feb 19 15:45 a
16
chgrp
change file group ownership
改变所属组
[root@localhost test]# ls -l a
-rw-r----x 1 nobody root 0 Feb 19 15:45 a
[root@localhost test]# chgrp adm a
[root@localhost test]# ls -l a
-rw-r----x 1 nobody adm 0 Feb 19 15:45 a
17
umask
查看创建文件的默认权限
改变默认权限 umask 权限掩码值
[root@localhost test]# mkdir newdir
[root@localhost test]# ls -ld newdir
drwxr-xr-x 2 root root 4096 Feb 20 10:40 newdir
[root@localhost test]# umask
0022
[root@localhost test]# umask -S
u=rwx,g=rx,o=rx
*
0022
特殊权限位
022-用户权限位,权限掩码值
777
022
755
022 就是表示755
SetUID 4
SetGID 2
chmod u+s
4755
2755 组id
6755同时SetUID和SetGID
*
Linux权限规则
缺省创建的文件不能授予可执行x权限
[root@localhost test]# touch testfile
[root@localhost test]# ls -l testfile
-rw-r--r-- 1 root root 0 Feb 20 10:50 testfile
虽然创建文件的默认权限是022,但创建的空文件testfile没有x权限
*
添加用户
[root@localhost test]# useradd miao
[root@localhost test]# passwd miao
Changing passWord for user miao.
New UNIX password:
BAD PASSWORD: it is too short
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
添加用户信息
设置密码
设置密码
*
su -
切换用户
1.3文件搜索命令Linux中所有都是文件,命令也是文件
文件搜索命令
18
which
查询命令所在的绝对路径
[root@localhost ~]# which chmod
/bin/chmod
[root@localhost ~]# whereis ls
ls: /bin/ls /usr/share/man/man1p/ls.1p.gz /usr/share/man/man1/ls.1.gz
命令也是文件
whereis除了绝对路径,还包括帮助文档
19
find
查找文件或目录
find [搜索路径][搜索关键字]
-name 文件名
*匹配任意字符 init*
?匹配单个字符 init???
-size 文件大小 block数据块 512字节=0.5kb
大于+
小于-
等于 find / -size 204800
-user 文件所有者
时间
天 ctime atime mtime分钟 cmin amin mminc—change改变,表示文件的属性被修改过,所有者、所属组、权限
a—access访问
m—modify修改,表示文件的内容被修改过
-之内,+超过
find /etc –mmin -120 一分钟内被修改过
-type 文件类型 f 二进制文件
l 软连接文件
d 目录
连接符 -a and 逻辑与 -o or 逻辑或
2. 连接符 find …. –exec 命令{}\;
{}find查询的结果
\转义符,符号命令使用本身的含义
;结果
-ok提示
[root@localhost ~]# find /etc -name init
/etc/sysconfig/init
试验通配符和占位符
[root@localhost ~]# find /etc -name init*
/etc/selinux/targeted/contexts/initrc_context
/etc/sysconfig/init
/etc/sysconfig/network-scripts/init.ipv6-global
/etc/init.d
/etc/mail/spamassassin/init.pre
/etc/inittab
/etc/initlog.conf
/etc/rc.d/init.d
[root@localhost ~]# find /etc -name init???
/etc/inittab
[root@localhost ~]# find /etc -name init?
[root@localhost ~]# find /etc -name init??
/etc/init.d
/etc/rc.d/init.d
查找用户
[root@localhost ~]# find /home -user helen
/home/helen
/home/helen/.bash_logout
/home/helen/.kde
/home/helen/.kde/Autostart
/home/helen/.kde/Autostart/.directory
/home/helen/.mozilla
/home/helen/.mozilla/extensions
/home/helen/.mozilla/plugins
/home/helen/.bash_profile
/home/helen/.bashrc
/home/helen/.bash_history
测试转义字符
[root@localhost ~]# which rm
alias rm='rm -i'
/bin/rm
[root@localhost ~]# rm abc.txt
rm: remove regular empty file `abc.txt'?
[root@localhost ~]# \rm abc.txt
查找二进制文件
[root@host141 ~]# find /etc -name init* -a -type f
/etc/inittab
/etc/initlog.conf
/etc/sysconfig/network-scripts/init.ipv6-global
/etc/sysconfig/init
/etc/selinux/targeted/contexts/initrc_context
测试连接符-exec
[root@localhost ~]# find /etc -name inittab
/etc/inittab
[root@localhost ~]# find /etc -name inittab -exec ls -l {} \;
-rw-r--r-- 1 root root 1666 Feb 14 04:02 /etc/inittab
[root@localhost ~]# cd /test
[root@localhost test]# pwd
/test
[root@localhost test]# ls
a a.hard a.soft etc issue lost+found
[root@localhost test]# find /test -name a.soft
/test/a.soft
[root@localhost test]# find /test -name a.soft -exec rm {} \;
[root@localhost test]# ls
a a.hard etc issue lost+found
测试连接符-ok
[root@localhost test]# find /etc -name inittab -exec ls -l {} \;
-rw-r--r-- 1 root root 1666 Feb 14 04:02 /etc/inittab
[root@localhost test]# find /etc -name inittab -ok ls -l {} \;
< ls ... /etc/inittab > ? y
-rw-r--r-- 1 root root 1666 Feb 14 04:02 /etc/inittab
[root@localhost test]# ls
a a.hard etc issue lost+found
[root@localhost test]# find /test -name a.hard -ok rm {} \;
< rm ... /test/a.hard > ? y
[root@localhost test]# ls
a etc issue lost+found
[root@localhost test]# find /etc -name init* -a -type f -exec ls -l {} \;
-rw-r--r-- 1 root root 28 Apr 10 2010 /etc/selinux/targeted/contexts/initrc_context
-rw-r--r-- 1 root root 1068 Jul 4 2009 /etc/sysconfig/init
-rwxr-xr-x 1 root root 5433 Jul 4 2009 /etc/sysconfig/network-scripts/init.ipv6-global
-rw-r--r-- 1 root root 1299 Jan 21 2009 /etc/mail/spamassassin/init.pre
-rw-r--r-- 1 root root 1666 Feb 14 04:02 /etc/inittab
-rw-r--r-- 1 root root 658 Sep 29 2009 /etc/initlog.conf
测试根据i节点删除文件
[root@localhost test]# touch "a b";
[root@localhost test]# ls
a a b
[root@localhost test]# touch -- -abc
[root@localhost test]# ls
a a b -abc
[root@localhost test]# rm -abc
rm: invalid option -- a
Try `rm ./-abc' to remove the file `-abc'.
Try `rm --help' for more information.
[root@localhost test]# rm a b
rm: remove regular empty file `a'? a
rm: cannot lstat `b': No such file or directory
[root@localhost test]# rm a b
rm: remove regular empty file `a'? y
rm: cannot lstat `b': No such file or directory
[root@localhost test]# rm -- -abc "a b"
rm: remove regular empty file `-abc'? y
rm: remove regular empty file `a b'? y
[root@localhost test]# ls
[root@localhost test]#
[root@localhost test]# ls -i
1653280 a b 1653352 -abc
[root@localhost test]# find . -inum 1653280
./a b
[root@localhost test]# find . -inum 1653280 -exec rm {} \;
[root@localhost test]# ls
-abc
*通配符
大范围查找只在晚上2点左右进行,因为访问人数少,只占用一部分资源
?匹配单个字符,相当于占位
通常用>或者<
rm的别名是 rm-i
所以要提示,那么要使用本身的含义,加转义字符\
查找二进制文件
查找inittab
查找并显示详细信息
进入test
显示当前目录
显示当前目录下的文件
查找a.soft文件
查找a.soft文件并删除
a.soft已删除
查找inittab并查看详细信息
提示的查看(为了试验,真正用在rm)
查找init开头,文件类型是二进制文件的详细信息
一些奇葩的创建文件
这时候想要删除文件就会出问题
我们知道创建过程的时候可以这样删除,如果不知道呢?
查找i节点
.表示当前目录,即/test
根据i节点删除,万能
20
locate
list files in databases
locate [搜索关键字]
locate file
可以查找所有跟file相关的文件,速度快
locate指令是根据数据库查找的,如果数据库中文件没有更新,那么就会找不到。
定期updatedb,则可以直接locate找到
21
updatedb
update the slocate database
建立整个系统目录文件的数据库
22
grep
grep [指定字串][源文件]
在文件中搜寻字串匹配的行,并输出
[root@localhost test]# grep tftp /etc/services
tftp 69/tcp
tftp 69/udp
tftp-mcast 1758/tcp
tftp-mcast 1758/udp
mtftp 1759/udp
subntbcst_tftp 247/tcp # SUBNTBCST_TFTP
subntbcst_tftp 247/udp # SUBNTBCST_TFTP
etftp 1818/tcp # Enhanced Trivial File Transfer Protocol
etftp 1818/udp # Enhanced Trivial File Transfer Protocol
tftps 3713/tcp # TFTP over TLS
tftps 3713/udp # TFTP over TLS
查找和tftp相关的行
1.4帮助命令帮助命令
23
man
manual
man [命令或配置文件]
获得帮助信息
命令和配置文件相同时优先查看命令的帮助
帮助分很多种,其中第一种是命令,第五种是配置文件,当名字相同时通过
man 5来查看配置文件
man ls 使用more查看,空格翻页,enter下一行
[root@localhost test]# man 5 passwd
passwd可以修改用户密码,
和一个配置文件同名
24
info
information
info [任何关键字]
获取帮助信息
25
whatis
whatis apropos[任何关键字]
获得索引的简短说明信息
[root@localhost test]# whatis whereis
whereis (1) - locate the binary, source, and manual page files for a command
26
help
命令 –help
help 内置命令
[root@localhost test]# ls --help
1.5压缩解压命令windows可解压Linux所有,但相反不可
共同:zip 但压缩比不高,如果小文件建议使用
gzip 和 bzip2只能压缩文件且不保留源文件,但后者-k可以保留
27
gzip
GNU zip
gzip 选项[文件]
压缩后文件格式: .gz
只能压缩文件,不能压缩目录
不保留源文件
解压缩:
gunzip 压缩文件
gzip –d 压缩文件
[root@localhost test]# ls
etc issue lost+found newfile
[root@localhost test]# gzip newfile
[root@localhost test]# ls
etc issue lost+found newfile.gz
不能压缩目录
[root@localhost test]# mkdir newdir
[root@localhost test]# ls
etc issue lost+found newdir newfile.gz
[root@localhost test]# gzip newdir
gzip: newdir is a directory – ignored
解压缩
[root@localhost test]# gzip -d newfile.gz
[root@localhost test]# ls
etc issue lost+found newdir newfile
[root@localhost test]# gzip newfile
[root@localhost test]# ls
etc issue lost+found newdir newfile.gz
[root@localhost test]# gunzip newfile.gz
[root@localhost test]# ls
etc issue lost+found newdir newfile
28
tar
打包目录
tar 选项[cvf][目录]
-c 产生.tar打包文件
-v 显示详细信息
-f 指定压缩后的文件名
-z 打包同时压缩
压缩后文件格式: .tar.gz
解压缩
-x 解包.tar文件
-v 显示详细信息
-f 指定解压文件
-z 解压缩
[root@localhost test]# ls
etc issue lost+found newdir newfile
[root@localhost test]# tar -zcf newdir.tar.gz newdir
[root@localhost test]# ls
etc issue lost+found newdir newdir.tar.gz newfile
当没有后缀,或者不知道文件类型
[root@localhost test]# tar -zcf new newdir
[root@localhost test]# ls -l new
-rw-r--r-- 1 root root 113 Feb 26 14:56 new
[root@localhost test]# file new
new: gzip compressed data, from Unix, last modified: Thu Feb 26 14:56:08 2015
先打包再压缩
[root@localhost test]# tar -cf newdir2.tar newdir
[root@localhost test]# gzip newdir2.tar
[root@localhost test]# ls
etc issue lost+found new newdir newdir2.tar.gz newdir.tar.gz newfile
解压缩
[root@localhost test]# ls
etc issue lost+found new newdir newdir2.tar.gz newdir.tar.gz newfile
[root@localhost test]# tar -zxf newdir.tar.gz
[root@localhost test]# ls
etc issue lost+found new newdir newdir2.tar.gz newdir.tar.gz newfile
[root@localhost test]# tar -zxf newdir2.tar.gz
[root@localhost test]# ls
etc issue lost+found new newdir newdir2.tar.gz newdir.tar.gz newfile
[root@localhost test]# rm -rf newdir
[root@localhost test]# ls
etc issue lost+found new newdir2.tar.gz newdir.tar.gz newfile
[root@localhost test]# tar -zxf new
[root@localhost test]# ls
etc issue lost+found new newdir newdir2.tar.gz newdir.tar.gz newfile
tar –zcf 打包后的名字 要打包的文件名
注:打包后的文件名可以没有后缀,但是为了辨识方便,养成良好习惯
看起来像是文本文件,但这种使用cat是无法查看的
使用file查看文件了性
29
zip
zip 选项[-r][压缩后文件名称][文件或