Linux File Basic Properties

Source: Internet
Author: User
Tags readable

Linux system is a typical multi-user system, different users in different positions, with different permissions. In order to protect the security of the system, the Linux system has different requirements for different users to access the same file (including directory files).

in Linux we can use the LL or LS–L command to display the properties of a file and the users and groups to which the file belongs, such as:

<span style= "FONT-SIZE:14PX;" >[email protected]:~$ ls-l Total dosage 56drwxrwxr-x 6 Deng Deng 4096  June  9 17:56 dumpdrwxrwxr-x 3 Deng Deng 4096  February  erh-mongo-munin-08e7aeb-rw-r--r--1 Deng Deng 8445  June  6 09:21 examples.desktopdrwxrwxr-x 3 Deng Deng 4096  June 08:35 tech163drwxr-xr-x 2 Deng Deng 4096  June  6 11:19 public drwxr-xr-x 2 Deng Deng 4096  June  6 11 : 19 Template Drwxr-xr-x 2 Deng Deng 4096  June  6 11:19 video Drwxr-xr-x 2 Deng Deng 4096  June  6 11:19 picture Drwxr-xr-x 5 D Eng Deng 4096  June  9 17:25 document Drwxr-xr-x 3 Deng Deng 4096  June 11 09:51 Download Drwxr-xr-x 2 Deng Deng 4096  June 
   6 11:19 Music drwxr-xr-x 2 Deng Deng 4096  June 10 18:13 Desktop </span>

instance, the first property of the dump file is represented by "D". "D" on Linux represents the file as a directory file.

The first character in Linux means that the file is a directory, a file, or a linked file, and so on.

    • When [ D ] is the directory
    • When [ - ] is the document;
    • If [ l ] is indicated as a linked document (link file);
    • If [ b ] is indicated as the device file inside the storage interface device (can be random access device);
    • If [ C ] is indicated as a serial port device inside the appliance file, such as a keyboard, mouse (one-time reading device).

in the following characters, a group of three, each of which is a combination of three parameters, is "rwx". where [R] stands for readable (read), [W] stands for writable (write), [x] stands for executable (execute). Note that the location of the three permissions does not change, and if there is no permission, a minus sign [-] is present.

The properties of each file are determined by the 10 characters of the first part of the left (for example).


0-9 of these numbers are used to indicate from left to right. The No. 0 bit determines the file type, and 第1-3位 determines that the owner of the file owns the file's permissions. 第4-6位 determines that the owning group (the same group of users of the owner) has permission to the file, 第7-9位 determines the permissions that other users have on the file. Among them, the 1th, 4, 7 is the Read permission, if the "R" character, then there is read permission, if the "-" character is indicated, there is no Read permission, 2nd, 5, 8 bits for write permission, if the "w" character, there is write permission, if the "-" character indicates no write permission; 3rd, 6, The 9-bit represents the executable permission, and if it is represented by an "x" character, there is an EXECUTE permission, and if the "-" character is represented, then the permission is not executed.

Linux file owner and owner Group

for a file, it has a specific owner, that is, the user who owns the file. At the same time, in a Linux system, users are categorized by group, and one user belongs to one or more groups. Users other than the file owner can be divided into the same group of users and other users as the file owner. Therefore, the Linux system sets different file access rights by file owner, file owner, and other users. In the above example, the dump file is a directory file, both the master and the group are Deng, the owner has a readable, writable, executable permissions, and other users of the same group are readable and executable permissions, other users have the ability to read and execute permissions.

Change file Properties1. CHGRP: Change file group

Grammar:

<span style= "FONT-SIZE:14PX;" >CHGRP [-R] Genus group name file name </span>

Parameter options

- R: Recursively change the group of files, that is, when you change the genus of a directory file, if you add the-r parameter, the group of all files under that directory will change.

2, Chown: Change the owner of the file, you can also change the file group

Grammar:

<span style= "FONT-SIZE:14PX;" >chown [–R] is the main name Chown [-R] belongs to the main name: Group name File name </span>

3, chmod: Change the file 9 properties

There are two ways to set up Linux file attributes, one is a number and one is a symbol.

Linux files have the basic permissions of nine, respectively, owner/group/others three identities each have their own Read/write/execute permissions.

First review the data just mentioned above: The file's permission character is: "-rwxrwxrwx", these nine permissions are three three a group! Where we can use numbers to represent individual permissions, the scores for each permission are as follows:

    • R:4
    • W:2
    • X:1

each identity (Owner/group/others) 's respective three permission (R/W/X) scores are cumulative, such as when the permission is: [-rwxrwx---] score:

    • Owner = rwx = 4+2+1 = 7
    • Group = RWX = 4+2+1 = 7
    • others=---= 0+0+0 = 0

so wait a minute. When we set the permission change, the permission number of the file is 770! The syntax for the Change permission directive chmod is this:

<span style= "FONT-SIZE:14PX;" >chmod [-r] XYZ file or directory </span>

Options and Parameters:

    • XYZ: is the permission attribute of the number type just mentioned, which is the sum of the numeric values of the Rwx property.
    • -R: Continuous change of recursion (recursive), i.e. all files in the secondary directory will be changed
symbol Type change file permissions

There is also a way to change the permissions yo! From the previous introduction, we can find that basically nine permissions are (1) User (2) group (3) Others three kinds of identities! Then we can represent three kinds of identities by u, G, O!

In addition, a represents all and all identity! Then the permission to read and write can be written as R, W, x! That is, you can see it in the following way:

chmod U
G
O
A
+ (Join)
-(remove)
= (set)
R
W
X
File or directory

<pre name= "code" class= "CPP" ><span style= "FONT-SIZE:14PX;"  >[email protected]:~$ chmod a+x dump[email protected]:~$ ls-l Dump total usage 16drwxrwxr-x 2 Deng Deng 4096  June  9 17:14  *drwxrwxr-x 2 Deng Deng 4096  June  9 17:14 doubandrwxrwxr-x 2 Deng Deng 4096  June  9 17:56 newsdbdrwxrwxr-x 2 Deng Deng 4096  June  9 17:56 test</span>




Linux File Basic Properties

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.