From the beginning to accumulate centos7 system uses
Daniel blog:
https://blog.51cto.com/yangrong/p5
https://blog.oldboyedu.com/
File permissions
rw-r--r-- 1 root root aduser.txt
r:read 读 4
w:write 写 2
x: execute execute 1
-: no authority 0
When selinux open files and folders is to create a bit, is not closed.
[root@python01 ~]# ls -lhi
total 24K
100663363 -rw-------. 1 root root 1.6K May 24 23:28 anaconda-ks.cfg
101300544 -rw-r--r--. 1 root root 15K Oct 3 2017 epel-release-latest-7.noarch.rpm
100663373 crw-r--r-- 1 root root 5, 1 Aug 12 16:49 erictse
100663393 brw-r--r-- 1 root root 5, 1 Aug 12 16:50 erictseb
420853 drwxr-xr-x 2 root root 37 Aug 12 11:43 honortone
690709 drwxr-xr-x 7 root root 171 Jul 11 11:23 oldboy
33575402 drwxr-xr-x 26 root root 4.0K Jun 18 10:50 test
[Root @ python01 ~] # ls -lhi / etc /
The concept of links:
In linux system, the link can be divided into two: one is a hard link (Hard Link), other soft or symbolic links (Symbolic Link or Soft link).
ln this command is to create a link to the file, in case of default without parameters, perform the link ln command to create a hard link is.
If you create a link was soft link using ln -s, in front of the file type as l (the letter L) is a soft link.
Practice is demonstrating understanding.
Hard link: ln source destination file
Soft link: ln -s source file target file (target file can not pre-existing)
1.1 hard link
A hard link is to be linked by the inode (Inode). In the linux file system, save the file in the disk partition
No matter what type will assign it a number, this number is called the inode number (Index Inode) referred Inode,
That file number in the system.
[root@python01 oldboy]# echo 1 >a
[root@python01 oldboy]# ls -l a
-rw-r--r-- 1 root root 2 Aug 13 11:17 a
[root@python01 oldboy]# ln a b
[root@python01 oldboy]# ls -l a
-rw-r--r-- 2 root root 2 Aug 13 11:17 a
[root@python01 oldboy]# cat a
1
[root@python01 oldboy]# cat b
[root@python01 oldboy]# ls -hil a b
690706 -rw-r--r-- 2 root root 2 Aug 13 11:17 a
690706 -rw-r--r-- 2 root root 2 Aug 13 11:17 b
硬链接是文件的入口:当一个文件被删了后源文件还是存在的并且可以查看文件内容
[root@python01 oldboy]# \rm a
[root@python01 oldboy]# ls -hil a b
ls: cannot access a: No such file or directory
690706 -rw-r--r-- 1 root root 2 Aug 13 11:17 b
[root@python01 oldboy]# cat b
1
文件名与源文件是引用指向的关系,当两个文件名都被删了,那么源文件就只有等待被系统回收的命运,
类似开发的引用数据类型,
文件删除原理:
在linux系统中,删除静态文件(没有进程调用)(目录也是文件)的条件是与之相关的所有硬链接文件均被删除。
1.2软链接:
软链接(Soft Link)也称为符号链接(Symbolic Link)。linux里的软链接文件就类似windows系统中的快捷方式。
linux里面的软链接实际上是一个特殊的文件,文件类型是l。软链接文件实际上可以理解为一个文本文件,
这个文件中包含有软链接指向另一源文件的位置消息内容,因此,通过访问这个快捷方式就可以迅速定位到软链接所指向的源文件实体。
[root@python01 oldboy]# echo 1 >file
[root@python01 oldboy]# ln -s file file_soft
[root@python01 oldboy]# ls -li file file_soft
690706 -rw-r--r-- 1 root root 2 Aug 13 15:44 file
690728 lrwxrwxrwx 1 root root 4 Aug 13 15:44 file_soft -> file
区别:inode不一样,文件类型不一样,文件权限也不一样,指向源文件
面试题:给用户唯一的入口
ln -s /application/apache2.2.17 /application/apache
[root@python01 /]# ls -ld /application/apache
lrwxrwxrwx 1 root root 25 Jul 12 09:12 /application/apache -> /application/apache2.2.17
[root@python01 /]# \rm -f /application/apache
[root@python01 /]# ls -ld /application/apache
ls: cannot access /application/apache: No such file or directory
[root@python01 /]# mkdir -p /application/apache2.4.2
[root@python01 /]# ls /application/
apache2.2.17 apache2.4.2
[root@python01 /]# ln -s /application/apache2.4.2 /application/apache
[root@python01 /]# ls -ld /application/apache
lrwxrwxrwx 1 root root 24 Aug 13 16:15 /application/apache -> /application/apache2.4.2