标签:链接 dir 链接文件 特定 hang rgba 符号 系统目录结构 文件操作命令
目录功能
/mnt :临时文件挂载点
/media :便携式移动设备挂载点
/run:正在运行中的信息。(临时生成的文件或者进程文件)
应用程序组成部分:
文件的类型:
绝对路径相对路径
显示当前目录
pwd--显示当前工作目录的绝对路径
[root@localhost /]# ls -al bin
lrwxrwxrwx. 1 root root 7 Nov 12 19:26 bin -> usr/bin //链接文件
[root@localhost /]# cd bin
[root@localhost bin]# pwd -P
/usr/bin
查看文件状态
stat
文件相关信息:metadata(元数据) data (数据)
改变访问时间例子:
[root@localhost home]# stat test File: ‘test’ Size: 6 Blocks: 8 IO Block: 4096 regular file Device: 803h/2051d Inode: 68 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root) Context: unconfined_u:object_r:home_root_t:s0 Access: 2020-11-21 03:09:29.002143699 -0500 //注意时间 Modify: 2020-11-21 03:09:29.002143699 -0500 Change: 2020-11-21 03:09:29.002143699 -0500 Birth: - [root@localhost home]# cat test //查看内容 hello [root@localhost home]# stat test File: ‘test’ Size: 6 Blocks: 8 IO Block: 4096 regular file Device: 803h/2051d Inode: 68 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root) Context: unconfined_u:object_r:home_root_t:s0 Access: 2020-11-21 03:23:44.831997330 -0500 //时间变化 Modify: 2020-11-21 03:09:29.002143699 -0500 Change: 2020-11-21 03:09:29.002143699 -0500 Birth: -
注意:centos 6修改了时间的记录形式,不会每次cat都会改变访问时间。
修改文件内容第一次cat,会修改access时间。
修改时间例子:
[root@localhost home]# stat test File: ‘test’ Size: 6 Blocks: 8 IO Block: 4096 regular file Device: 803h/2051d Inode: 68 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root) Context: unconfined_u:object_r:home_root_t:s0 Access: 2020-11-21 03:23:44.831997330 -0500 Modify: 2020-11-21 03:09:29.002143699 -0500 //注意时间 Change: 2020-11-21 03:09:29.002143699 -0500 Birth: - [root@localhost home]# vi test [root@localhost home]# cat test hello man [root@localhost home]# stat test File: ‘test’ Size: 11 Blocks: 8 IO Block: 4096 regular file Device: 803h/2051d Inode: 69 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root) Context: unconfined_u:object_r:home_root_t:s0 Access: 2020-11-21 03:28:51.039156019 -0500 Modify: 2020-11-21 03:28:43.679200274 -0500 //内容改变,时间变化。 Change: 2020-11-21 03:28:43.679200274 -0500 Birth: -
改变时间例子
[root@localhost home]# stat test File: ‘test’ Size: 11 Blocks: 8 IO Block: 4096 regular file Device: 803h/2051d Inode: 69 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root) Context: unconfined_u:object_r:home_root_t:s0 Access: 2020-11-21 03:28:51.039156019 -0500 Modify: 2020-11-21 03:28:43.679200274 -0500 Change: 2020-11-21 03:28:43.679200274 -0500 //注意时间 Birth: - [root@localhost home]# chmod 777 test [root@localhost home]# stat test File: ‘test’ Size: 11 Blocks: 8 IO Block: 4096 regular file Device: 803h/2051d Inode: 69 Links: 1 Access: (0777/-rwxrwxrwx) Uid: ( 0/ root) Gid: ( 0/ root) Context: unconfined_u:object_r:home_root_t:s0 Access: 2020-11-21 03:28:51.039156019 -0500 Modify: 2020-11-21 03:28:43.679200274 -0500 Change: 2020-11-21 03:32:05.895984288 -0500 //权限改变, Birth: -
注意:
ls 命令查看文件,显示的是Modify时间
对比 符号 [ ] { }
[root@localhost home]# ls [a-h].txt a.txt A.txt b.txt B.txt c.txt C.txt d.txt D.txt e.txt E.txt f.txt F.txt g.txt h.txt //小大小大有顺序得排序 [root@localhost home]# ls {a..h}.txt a.txt b.txt c.txt d.txt e.txt f.txt g.txt h.txt //与[a.b.c.d.e.f.g].txt等价
[root@localhost home]# ls [1-6].txt
1.txt 2.txt 3.txt 4.txt 5.txt
[root@localhost home]# ls {1..6}.txt
ls: cannot access 6.txt: No such file or directory
1.txt 2.txt 3.txt 4.txt 5.txt
使用中发现,{ }多用于进行批量次按照特定格式的去创建文件,例如:touch {a..z}.txt,使用中带 { x.. x }; 而[ ]多用于相同格式的匹配,使用 [ x-x ]。
预定义字符类例子,比较[:digit:]和[[:digit:]]用法。
[root@localhost home]# touch file{a..b}{3..4} [root@localhost home]# ls 1.txt 3.txt 5.txt A.txt B.txt C.txt D.txt E.txt filea4 fileb4 F.txt h.txt 2.txt 4.txt a.txt b.txt c.txt d.txt e.txt filea3 fileb3 f.txt g.txt [root@localhost home]# ls file[[:lower:]][[:digit:]] //外面加[ ]会识别一个整体。 filea3 filea4 fileb3 fileb4 [root@localhost home]# ls file[:lower:][:digit:] ls: cannot access file[:lower:][:digit:]: No such file or directory
作业:
2020-11-27 0:27 (得屌丝者得天下)
标签:链接 dir 链接文件 特定 hang rgba 符号 系统目录结构 文件操作命令
原文地址:https://www.cnblogs.com/lovelitao/p/14045580.html