编程知识 cdmana.com

File properties and file types in Linux

File types and properties

File attribute The meaning of each column

​ [root@oldboyedu ~]# 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
​ [root@oldboyedu ~]# ll /dev/urandom Vomit
​ crw-rw-rw- 1 root root 1, 9 Nov 5 10:27 /dev/urandom
​ [root@oldboyedu ~]# 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
​ [root@oldboyedu ~]# 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 
					[root@oldboyedu ~]# ls 1g.txt 
					1g.txt
					[root@oldboyedu ~]# ls 1g.txt > ok.txt
					[root@oldboyedu ~]# cat ok.txt 
					1g.txt
					[root@oldboyedu ~]# ls 1g.txt >> ok.txt
					[root@oldboyedu ~]# cat ok.txt
					1g.txt
					1g.txt
					[root@oldboyedu ~]# ls 1g.txt 2>> ok.txt
					1g.txt
					[root@oldboyedu ~]# 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 

					[root@oldboyedu ~]# ls 1ggg.txt 2> ok.txt
					[root@oldboyedu ~]# cat ok.txt 
					ls: cannot access 1ggg.txt: No such file or directory

					[root@oldboyedu ~]# ls 1g.txt 2> ok.txt 
					1g.txt
					[root@oldboyedu ~]# cat ok.txt 

				   To receive correct and incorrect 
				  [root@oldboyedu ~]# ls 1g.txt 2> ok.txt 
					1g.txt
					[root@oldboyedu ~]# cat ok.txt 
					[root@oldboyedu ~]# ls 1g.txt >> ok.txt 2>> ok.txt
					[root@oldboyedu ~]# cat ok.txt 
					1g.txt
					[root@oldboyedu ~]# 
					[root@oldboyedu ~]# ls 1gggg.txt >> ok.txt 2>> ok.txt
					[root@oldboyedu ~]# cat ok.txt 
					1g.txt
					ls: cannot access 1gggg.txt: No such file or directory



					[root@oldboyedu ~]# ls 1gggg.txt >>ok.txt 2>&1
					[root@oldboyedu ~]# ls 1g.txt >>ok.txt 2>&1
					[root@oldboyedu ~]# 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

					[root@oldboyedu ~]# ls 1g.txt &>ok.txt
					[root@oldboyedu ~]# ls 1gggg.txt &>ok.txt
					[root@oldboyedu ~]# cat ok.txt
					ls: cannot access 1gggg.txt: No such file or directory
					[root@oldboyedu ~]# ls 1gggg.txt &>>ok.txt
					[root@oldboyedu ~]# ls 1g.txt &>>ok.txt
					[root@oldboyedu ~]# 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 
				
				[root@oldboyedu ~]# ping -c2 -W1 www.baidu.com &>/dev/null
				[root@oldboyedu ~]# echo $?
				0
				[root@oldboyedu ~]# ping -c2 -W1 www.baiduaaaaaaaaaaaaaa.com &>/dev/null
				[root@oldboyedu ~]# 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 
		[root@oldboyedu ~]# getenforce 
		 Enforcing
	2. Temporarily Closed selinux


		[root@oldboyedu ~]# 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]所创,转载请带上原文链接,感谢

Scroll to Top