Linux File Basic Properties

Source: Internet
Author: User
Tags readable

Linux system is a typical multi-user system, different users in different positions, with no permissions, in order to protect the security of the system, the Linux system for different users

Access to the same file (including directory files) is provided differently.

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:

# ls-l

Total 64

Dr-xr-xr-x 2 root root 4096 Dec

instance, the first property of the bin 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, etc.

[d] Directory

[-] File

[/] Link document

[b] Storage-ready interface devices in the device file

[c] Serial port device inside the device file

The next character is a group of three, each of which is a combination of [rwx] parameters.

which

[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 attributes of each file have 10 characters to the first part of the left to determine

The file type belongs to the Master permission group permission other user rights

0 123 456 789

D rwx R-x R-x

Read and write read and write execution of directory files

0-9 of these numbers are used to indicate from left to right.

No. 0 To determine the file type, 第1-3位 determines that the owner of the file owns the file's permissions.

4–6 the permissions of the file to determine the owning group (the same group of users of the owner), 第7-9位 determines the permissions that other users have for the file.

Where the 1th, 4, 7 is the Read permission, if the R character is indicated, then there is read permission, if the-character representation, there is no Read permission;

2nd 5 8 for Write permission if the W character is indicated, there is write permission, if the-character indicates no write permission;

3rd 6 9 Bits represents the executable permission, if it is represented by the x character, there is execute permission, if the-character is represented, there is no execute permission

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.

As a result, the Linux system specifies the file access permissions that are not passed by the file owner, the file owner, and other users.

In the above example, the MySQL file is a directory file, the owner and the group are MySQL, belong to the master has a readable, writable executable permissions, and other users of the same group as the owner has

Readable and executable permissions, and other users have readable and executable permissions.

For root users, the file's permissions generally do not work on it.

Change file properties

1. CHGRP: Change file group

Grammar:

CHGRP [-R] belongs to group name file name

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 file owner, you can also change the file group

Grammar:

Chown [-R] belongs to group name file name

Chown [-R] Main name: Name of Group name

Enter the/root directory (~) to change the owner of the Install.log to bin this account:

CD ~

# Chown Bin Installl.log

# ls-l

Change the owner and group of the Install.log back to root:

# chown Root:root Install.log

3 chmod: Change a 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 for a group of which, we can use numbers to represent

Each permission, the number of permissions of the following table:

R:4

W:2

X:1

Each identity (owner/group/others) of the respective three permissions (r/w/x) number is required to accumulate, for example, when the permission is: [-RWXRWX---]

Owner = rwx = 4+2+1 = 7

Group = RWX = 4+2+1 = 7

Othors =---= 0+0+0 = 0

The syntax of chmod

chmod [-r] XYZ file or directory

Options and Parameters:

The numbers represented by the syz:rwx and

-R: Continuous change of recursion (recursive)

Cases

chmod 777. BASHRC

Other examples

#chmod u=rwx,g=rx,o=r Test1

#chmod a-x Test1

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.