文件管理
Linux 系统的单根⽬录结构
linux与windows的⽬录结构对⽐

⽂件的时间
1 2 3 4 5 6 7 8
| ls -l ⽂件名 仅看的是⽂件的修改时间 Linux⽂件有三种时间,⽤stat查看 例如:stat anaconda-ks.cfg 访问时间:atime,查看内容,⽤cat检测 修改时间:mtime,修改内容 改变时间:ctime,修改内容,修改权限等属性,凡是有改动都会变
|
文件类型概念说明
1、文件详细信息详解
1 2 3 4
| [root@localhost ~] 总用量 8K 134319695 -rw-------. 1 root root 1.7K Dec 8 12:08 anaconda-ks.cfg 134319707 -rw-r--r-- 1 root root 12 Dec 13 11:48 index
|
文件属性信息详述图

2、inode编号
- Linux系统中文件的唯一编号,就相当于身份证号。
1 2 3 4 5 6 7 8 9 10
| Linux系统内部不使用文件名,而使用inode编号来识别文件 对于系统来说,文件名只是inode编号便于识别的别称或者绰号,表面上用户通过文件名打开文件 实际上系统内部这个过程分成立三步: 首先:系统找到这个文件名对应的inode编号 其次:通过ionde编号获取inode信息 最后:根据ionde信息找到文件数据所在的block,读出数据 使用ls -i命令可以看到文件对应额inode编号 [root@localhost data] 16781387 test
|
硬链接和软链接
1、什么是硬链接
- 硬链接:不具有完整的文件结构,它的文件名直接指向文件节点,它和源文件节点一致。
2、什么是软链接
- 软链接:具有完整的文件结构,最后指向的是目标文件名,它和源文件节点不一致。
- 相当于Windows中的快捷方式,主要用来指向(保存)对应文件的路径。
3、创建命令
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| [root@localhost test] [root@localhost test] 16781390 1.txt [root@localhost test] [root@localhost test] 16781390 1.txt [root@localhost test] 16781390 2.txt
[root@localhost haha] [root@localhost haha] 33712451 a.txt [root@localhost haha] [root@localhost haha] 33712451 a.txt [root@localhost haha] 33712452 b.txt
1、删除的是硬链接 2、判断该文件硬链接数是否为0 3、如果为0,则在磁盘中将其删除 4、如果不为0,则只删除一个硬链接
查看软链接文件,查看的文件不存在。和windows一样,删除源文件,快捷方式也用不了。但是删除源文件,为什么硬链接文件还可以查看呢? 这里要简单说下i节点了。i节点是文件和目录的唯一标识,每个文件和目录必有i节点,不然操作系统就无法识别该文件或系统,就像没有上户口的黑户。linux操作系统是不识别些字母的。
通俗理解: 硬链接文件相当于文件硬链接数+1,在windows里没这个概念,删除文件删除的是硬链接数,硬链接数为0时,数据就没了 软连接就是指向文件的路径,文件删除了,路径就不存在了,所以软连接找不到了
|
文件类型
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
| Linux⽂件没有扩展名!!!
ls -l ⽂件名 - [root@localhost ~] -rw-r--r-- 1 root root 0 12月 14 19:11 1
d [root@localhost home] drwx------ 2 test test 63 12月 14 19:13 test
b [root@localhost dev] brw-rw---- 1 root disk 8, 0 12月 16 19:39 sda
c [root@localhost dev] crw-rw-rw- 1 root tty 5, 0 12月 16 19:39 tty
s [root@localhost mysql] srwxrwxrwx 1 mysql mysql 0 12月 16 21:52 mysql.sock
p [root@localhost initctl] prw------- 1 root root 0 12月 16 19:39 fifo
l [root@localhost bin] lrwxrwxrwx. 1 root root 6 12月 13 11:40 apropos -> whatis ps:通过颜⾊判断⽂件的类型是错误的!!!
[root@localhost run] [root@localhost run]
[root@xxx ~] /etc/krb5.conf: ASCII text
.conf .log .sh .py
|