File properties and file types in Linux

Myrica rubra 2020-11-11 22:15:14
file properties file types linux


File types and properties

File attribute The meaning of each column

​ [[email protected] ~]# ll -i
​ 33575029 -rw-r--r--. 1 root root 337 Nov 2 10:26 hosts

​ Split the above file properties as follows :

33575029 - rw- r-- r-- . 1 root root 337 Nov 2 10:26 hosts

inode Number file type The authority of the owner Group authority Visitor rights selinux It can be eliminated after closing . 1 For the number of hard links Belong to Generic group Storage size File time File name

inode Number

inode Number index node Document indexing , Storage points to blok The pointer to , Each file takes up one inode
block Where to store the contents of the document , Each file takes up more than one block 4k size The smallest unit of storage
block Big good It's better to be small ?
It depends on the business : Many small files are generated It's still big files The big file business is also the small file business in the company
Small files block Smaller is better Save disk space
Generate 1 Small file Less than 1K ... When generating the second small file Will take up a new one block 4K
block 4k There is one 10K The file of
Occupy 3 individual block

 A large file 10M ---> block Numerous
Read a block At 1 second
10M The amount of block Events for 10M/4K Time for


​ The above two One of them is full of Unable to write data to disk

​ The process of reading the contents of a file :
​ 1. First find the file name ( From the superior directory block The file name is stored in the superior directory )
​ 2. Find the filename You can find the corresponding inode
​ 3. adopt inode To find the corresponding block

file type

Linux Type of file
- Ordinary documents
All three kinds of ordinary documents are based on - To express
1. Ordinary documents Ordinary documents cat vim echo > less( Page by page looking at the contents of the file )
-rw-r--r--. 1 root root 84485563 Nov 5 10:43 hosts

 2. Binary Executable command ls pwd touch It's all binary files
-rwxr-xr-x. 1 root root 62568 Oct 31 2018 /usr/bin/touch
3. Data files Compressed package .rpm package
-rw-rw-r-- 1 root root 84280 Aug 23 2019 zziplib-0.13.62-11.el7.x86_64.rpm
-rw-r--r-- 1 root root 550 Nov 5 10:47 all.tar.gz
d Presentation directory
drwxr-xr-x 2 root root 6 Nov 5 10:48 dir

​ l Soft link file softlink similar windows Shortcut to There is a pointer to the source file It will take up a inode
​ Characteristics of soft link :
​ Link to the file Holding the pointer
​ rwxrwxrwx The highest authority Look at the highest authority Actually, it depends on the permissions of the source file
​ Soft links are at the front The source file is in > Back
​ b Block device Hardware device
​ brw-rw---- 1 root disk 8, 0 Nov 5 10:27 /dev/sda
​ brw-rw---- 1 root disk 8, 1 Nov 5 10:27 /dev/sda1

​ c Byte device Can automatically generate some strings It can be similar to a black hole Absorb a lot of content
​ [[email protected] ~]# ll /dev/urandom Vomit
​ crw-rw-rw- 1 root root 1, 9 Nov 5 10:27 /dev/urandom
​ [[email protected] ~]# ll /dev/zero Vomiting
​ crw-rw-rw- 1 root root 1, 5 Nov 5 10:27 /dev/zero
​ Often generate some large test files For example, generate 1G The file of configure swap Swap partition Expand
​ dd if=/dev/zero of=./1g.txt bs=1M count=1000
​ command
​ if input file
​ of output file
​ bs How much data is received each time
​ count How many times in total
​ [[email protected] ~]# ll /dev/null What you eat
​ crw-rw-rw- 1 root root 1, 3 Nov 5 10:27 /dev/null

 > perhaps 1> Standard correct output redirection
>> Standard correctly appends output redirection
Standard correct output :
The order is correct Successful results
such as ls cat ping The result of success
[[email protected] ~]# ls 1g.txt
1g.txt
[[email protected] ~]# ls 1g.txt > ok.txt
[[email protected] ~]# cat ok.txt
1g.txt
[[email protected] ~]# ls 1g.txt >> ok.txt
[[email protected] ~]# cat ok.txt
1g.txt
1g.txt
[[email protected] ~]# ls 1g.txt 2>> ok.txt
1g.txt
[[email protected] ~]# cat ok.txt
1g.txt
1g.txt
2> Standard error output redirection
2>> Standard error append output redirection
Standard error output :
Wrong command The execution result is not correct
[[email protected] ~]# ls 1ggg.txt 2> ok.txt
[[email protected] ~]# cat ok.txt
ls: cannot access 1ggg.txt: No such file or directory
[[email protected] ~]# ls 1g.txt 2> ok.txt
1g.txt
[[email protected] ~]# cat ok.txt
To receive correct and incorrect
[[email protected] ~]# ls 1g.txt 2> ok.txt
1g.txt
[[email protected] ~]# cat ok.txt
[[email protected] ~]# ls 1g.txt >> ok.txt 2>> ok.txt
[[email protected] ~]# cat ok.txt
1g.txt
[[email protected] ~]#
[[email protected] ~]# ls 1gggg.txt >> ok.txt 2>> ok.txt
[[email protected] ~]# cat ok.txt
1g.txt
ls: cannot access 1gggg.txt: No such file or directory
[[email protected] ~]# ls 1gggg.txt >>ok.txt 2>&1
[[email protected] ~]# ls 1g.txt >>ok.txt 2>&1
[[email protected] ~]# cat ok.txt
1g.txt
ls: cannot access 1gggg.txt: No such file or directory
ls: cannot access 1gggg.txt: No such file or directory
1g.txt
[[email protected] ~]# ls 1g.txt &>ok.txt
[[email protected] ~]# ls 1gggg.txt &>ok.txt
[[email protected] ~]# cat ok.txt
ls: cannot access 1gggg.txt: No such file or directory
[[email protected] ~]# ls 1gggg.txt &>>ok.txt
[[email protected] ~]# ls 1g.txt &>>ok.txt
[[email protected] ~]# cat ok.txt
ls: cannot access 1gggg.txt: No such file or directory
ls: cannot access 1gggg.txt: No such file or directory
1g.txt
$? ? Variable holds the result of the last command executed 0 For success Not 0 Failure
[[email protected] ~]# ping -c2 -W1 www.baidu.com &>/dev/null
[[email protected] ~]# echo $?
0
[[email protected] ~]# ping -c2 -W1 www.baiduaaaaaaaaaaaaaa.com &>/dev/null
[[email protected] ~]# echo $?
2

Belongs to the master file permission

The file group belongs to file group

Visitor rights

File permissions : rw-r--r--
r read Read the file less cat
w write write in Can edit echo vim
x excute Executable

 - The representative has no authority
Linux The highest permissions of files in the system are rw What do we do with it as a normal file ?
x Permissions can execute permissions shell Script rwx

 rw-r--r-- # Three in a group
Top three The owner of the document Belong to ( Which user created this file Like our own notebooks It belongs to us ) Have authority rw Can be read Can write
Middle three Group of documents jurisdiction ( Which group does this file belong to For example, our notebooks belong to families ) Have permission to read
Last three Other users A stranger ( For example, notebooks correspond to It's not family It's not the master ) Have permission to read

selinux It can be eliminated after closing .

Open the selinux Generated

 Selinux Security policy services developed by the national security agency Generally, it is not enabled
Need to be closed selinux
1. How to view the current selinux Open or not
[[email protected] ~]# getenforce
Enforcing
2. Temporarily Closed selinux
[[email protected] ~]# setenforce
usage: setenforce [ Enforcing | Permissive | 1 | 0 ]
3. Permanent ban selinux
vim /etc/selinux/config
SELINUX=disabled
Restart the operating system

1 Number of hard links to 1 Files open multiple entries It's like a supermarket with multiple doors open
effect : Improve file security
characteristic : File default 1 Number of hard links
Catalog Default 2 Hard links

Belong to

root Belong to The owner of the document Which user is used to create Which user is the default owner root The user can modify the specified file to belong to the primary group

Generic group

root Generic group Which group does the file belong to Which user is used to create Which user is the default owner

Storage size

File size ll -h

File time

Nov 2 10:26 There are three kinds of document time Access Access time cat Modify Content modification time Change Property modification time

Command view : stat File name

File name

The last item is the file name

版权声明
本文为[Myrica rubra]所创,转载请带上原文链接,感谢

  1. 【计算机网络 12(1),尚学堂马士兵Java视频教程
  2. 【程序猿历程,史上最全的Java面试题集锦在这里
  3. 【程序猿历程(1),Javaweb视频教程百度云
  4. Notes on MySQL 45 lectures (1-7)
  5. [computer network 12 (1), Shang Xuetang Ma soldier java video tutorial
  6. The most complete collection of Java interview questions in history is here
  7. [process of program ape (1), JavaWeb video tutorial, baidu cloud
  8. Notes on MySQL 45 lectures (1-7)
  9. 精进 Spring Boot 03:Spring Boot 的配置文件和配置管理,以及用三种方式读取配置文件
  10. Refined spring boot 03: spring boot configuration files and configuration management, and reading configuration files in three ways
  11. 精进 Spring Boot 03:Spring Boot 的配置文件和配置管理,以及用三种方式读取配置文件
  12. Refined spring boot 03: spring boot configuration files and configuration management, and reading configuration files in three ways
  13. 【递归,Java传智播客笔记
  14. [recursion, Java intelligence podcast notes
  15. [adhere to painting for 386 days] the beginning of spring of 24 solar terms
  16. K8S系列第八篇(Service、EndPoints以及高可用kubeadm部署)
  17. K8s Series Part 8 (service, endpoints and high availability kubeadm deployment)
  18. 【重识 HTML (3),350道Java面试真题分享
  19. 【重识 HTML (2),Java并发编程必会的多线程你竟然还不会
  20. 【重识 HTML (1),二本Java小菜鸟4面字节跳动被秒成渣渣
  21. [re recognize HTML (3) and share 350 real Java interview questions
  22. [re recognize HTML (2). Multithreading is a must for Java Concurrent Programming. How dare you not
  23. [re recognize HTML (1), two Java rookies' 4-sided bytes beat and become slag in seconds
  24. 造轮子系列之RPC 1:如何从零开始开发RPC框架
  25. RPC 1: how to develop RPC framework from scratch
  26. 造轮子系列之RPC 1:如何从零开始开发RPC框架
  27. RPC 1: how to develop RPC framework from scratch
  28. 一次性捋清楚吧,对乱糟糟的,Spring事务扩展机制
  29. 一文彻底弄懂如何选择抽象类还是接口,连续四年百度Java岗必问面试题
  30. Redis常用命令
  31. 一双拖鞋引发的血案,狂神说Java系列笔记
  32. 一、mysql基础安装
  33. 一位程序员的独白:尽管我一生坎坷,Java框架面试基础
  34. Clear it all at once. For the messy, spring transaction extension mechanism
  35. A thorough understanding of how to choose abstract classes or interfaces, baidu Java post must ask interview questions for four consecutive years
  36. Redis common commands
  37. A pair of slippers triggered the murder, crazy God said java series notes
  38. 1、 MySQL basic installation
  39. Monologue of a programmer: despite my ups and downs in my life, Java framework is the foundation of interview
  40. 【大厂面试】三面三问Spring循环依赖,请一定要把这篇看完(建议收藏)
  41. 一线互联网企业中,springboot入门项目
  42. 一篇文带你入门SSM框架Spring开发,帮你快速拿Offer
  43. 【面试资料】Java全集、微服务、大数据、数据结构与算法、机器学习知识最全总结,283页pdf
  44. 【leetcode刷题】24.数组中重复的数字——Java版
  45. 【leetcode刷题】23.对称二叉树——Java版
  46. 【leetcode刷题】22.二叉树的中序遍历——Java版
  47. 【leetcode刷题】21.三数之和——Java版
  48. 【leetcode刷题】20.最长回文子串——Java版
  49. 【leetcode刷题】19.回文链表——Java版
  50. 【leetcode刷题】18.反转链表——Java版
  51. 【leetcode刷题】17.相交链表——Java&python版
  52. 【leetcode刷题】16.环形链表——Java版
  53. 【leetcode刷题】15.汉明距离——Java版
  54. 【leetcode刷题】14.找到所有数组中消失的数字——Java版
  55. 【leetcode刷题】13.比特位计数——Java版
  56. oracle控制用户权限命令
  57. 三年Java开发,继阿里,鲁班二期Java架构师
  58. Oracle必须要启动的服务
  59. 万字长文!深入剖析HashMap,Java基础笔试题大全带答案
  60. 一问Kafka就心慌?我却凭着这份,图灵学院vip课程百度云