Cainiao basics of Linux: file security and permissions

Source: Internet
Author: User
Tags touch command
Article Title: cainiao basics of Linux: file security and permissions. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
When creating a file, the system saves all information about the file, including:
• File location.
• File type.
• File length.
• Which User owns the file and which user can access the file.
• I node.
• File modification time.
• File Permission bit.
  
Let's use the touch command to create a file:
  
   Code:
$ Touch temp
  
After creating an empty file, run the ls-l command to view the attributes of the file in the directory (I will use the Chinese version here ):
As follows:
  
   Code:
[Root @ Linux_chenwy temp] # ls-l
Total usage 36
-Rw-r -- 1 root 34890 October 19 20:17 httpd. conf
-Rw-r -- 1 root 0 October 19 20:16 temp
  
   Code:
Total usage 36: the number of bytes occupied by the ls entries (in K ).
1. Number of hard links to the file.
Root file owner.
The default group (also called r o t) of the root file owner ).
34890 indicates the length of the file in bytes. Remember, it is not K Bytes!
The time when the file was updated At 20:17, January 1, October 19.
Temp or httd. conf file name.
  
   Sunsroad writes:
BTW: run the following command to check the space occupied by all files in the directory: du.
For example, the above 36 is how to calculate:
First, we need to first understand the size of the I/o block (a cluster in Chinese) of your file system. The size of the I/O BLOCK in this file system is 4096 Bytes.
  
It is the smallest read/write and allocation unit of the file system. You cannot be smaller than this size for each read/write operation. Even if your file has only one byte. In addition, the storage of files on the hard disk is also in this unit. That is to say, if the file size is smaller than this value, the space occupied by the file on the disk is 4096 bytes.
  
The specific algorithm for space occupation is: (1 (file size/4096) × 4096. Based on this, you can calculate the space usage of the file in the example you listed: 34890 divided by 4096, which is about 8.5, and 9 is obtained in the next method, that is to say, a file occupies nine blocks on the disk, each of which is 4 K, so the space occupied by these two files is 36 K.
  
This rule is also suitable for directories, but there will be no directories with 0, even empty directories.
  
-Rw-r --: The permission bit of the file.
  
The first horizontal bar: Specifies the file type, indicating that the file is a common file. (Most of the created files are normal files or symbolic link files ).
  
Aside from the Front horizontal bar, there are a total of 9 characters, which correspond to 9 permission bits. With these permission bits, you can set the user's access permissions to files. The exact interpretation of these two files is:
  
   Code:
Rw-: the first three digits. The file owner can read and write data.
R --: the middle three digits, which are readable to the same group of users
R --: the last three digits. Other users are only readable.
  
Temp does not grant the execution permission to the owner during file creation. When a user creates a file, the system does not automatically set the execution permission limit. This is to enhance system security.
  
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.