6.Linux file attributes and soft and hard links

1. File Properties

  • For more information see ll -h use, each column is doing
    image.png
    第一列第一个字符 表示文件类型--->
    rw-r--r-- 文件权限
    1 这个文件被链接次数
    root 文件的拥有者(用户)
    root 文件的拥有组(用户组 ==>家族)
    672 文件大小
    Jul 31 17:30 文件的日期,以及创建的文件的时间
    1.txt 文件名称

    2. File Types

    image.png

    - file (normal file compressed image)
    L shortcut link file similar to windows of
    a communication system between the local process and s socket Process
    d directory similar to the windows folder directory
    c character input device for providing user output
    b file block device (hard disk partition disc)

  • For some files can not accurately distinguish between type, you can use the file command to view

    (1) can not accurately determine this in the end is what type of file

[root@yinwucheng ~]# ll /bin/ls access.log oldboy1 1.txt 
-rw-r--r--. 1 root root      672 Jul 31 17:30 1.txt
-rw-r--r--. 1 root root 58112885 Jul 30 15:31 access.log
-rwxr-xr-x. 1 root root   117680 Oct 31  2018 /bin/ls
-rw-r--r--. 1 root root        0 Jul 31 17:29 oldboy1

(2) the use of a file can accurately see what type of file

image.png

Because Linux does not distinguish suffix, suffix usually used to represent, in order to facilitate the recognition of our own good

3. Link file

  1. Soft links (shortcuts like WIndows's)
    soft links usage scenarios (rarely make soft link file)
  • Software Upgrade Software rollback
[root@yinwucheng ~]# mkdir QQ_V1.1
[root@yinwucheng ~]# ln -s /root/QQ_V1.1/ /root/QQ
升级
[root@yinwucheng ~]# mkdir QQ_V1.2
[root@yinwucheng ~]# rm -f /root/QQ && ln -s /root/QQ_V1.2 /root/QQ
回退
[root@yinwucheng ~]# rm -rf /root/QQ && ln -s /root/QQ_V1.1 /root/QQ
  • Code upgrades-second fallback

    1. Convenient mobile directory
      hard link ln / root / file / root / file_hard

    4. The difference between a hard link and soft link

  1. ln command to create a hard link, ln -s command to create a soft link
  2. The directory can not create hard links, and hard links can not span partitions system.
  3. Directory especially popular soft links, soft links and support across partitions system.
  4. The same inode hard-linked files and source files, different soft link file with the source file inode.
  5. Delete soft link file, without any impact on the source files and hard linked files.
  6. Deleted files hard-linked files, without any impact on the source file and linked files.
  7. Delete the source files linked files, no effect on the hard links, soft links will lead to failure.
  8. Delete files and hard links to the file, the entire file is really deleted.

    Difference summary

  9. Soft link is a shortcut, delete soft connection does not affect the source file.
  10. Hard links, similar to a copy of the file, delete hard links without affecting the original files, only to delete all the hard links and source file, which is considered to be completely deleted.

    The command execution process [spreading understood]

    The first step: see command is not executed by way of the absolute path of
    the second step: to see if there is a command aliases
    third step: judge or external command built-in command
    Step Four: If built, it can be executed directly if external then see if there is a cache
    step Five: Find command $ PATH variable, if any, will complain if there is no executable command not found

image.png

Guess you like

Origin www.cnblogs.com/yinwu/p/11486241.html