Linux Learning _ Rookie Tutorial _4

Source: Internet
Author: User
Tags readable file permissions

Linux Telnet

Already understand the login process, learned to use SECURECRT to operate

Linux File Basic Properties

Linux to protect the system security, to different users, open different file access rights.

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.

, the first attribute of the pictures file is denoted by "D". "D" In Linux indicates that the file is a directory file. In Linux, the first character indicates that the file is a directory, a file, or a linked file.

[D] The directory [-] file [ 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).

The following characters are grouped in three and are all combinations of rwx three parameters. where [R] stands for readable (read), [W] stands for writable (write), [x] stands for executable (execure). Note that the location of the three permissions does not change, and if there is no permission, it will appear [-].

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.

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

The 2nd, 5, 8 bits indicate write permissions, if the "W" character is indicated, there is write permission, if the "-" character indicates that there is no write permission, the 3rd, 6, 9 bits indicate the executable permission, if the "x" character is indicated, there is the execution permission, if the "-" character, there is no execute permission.

Owners and genera of Linux files

[[email protected]/]# ls-ltotal 64drwxr-xr-x 2 root  root  4096 Feb 14:46 crondrwxr-xr-x 3 mysql mysql 4096 Apr MySQL .....  

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 MySQL file is a directory file, both the master and the group are MySQL, the owner has a readable, writable, executable permissions, and other users of the same group are 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 owner of the file, or you can change the file group at the same time

Syntax: Chown [-R] belongs to the main name file name

Chown[-r] belongs to the main name: the name of the group name

3.chmod: Change file 9 properties

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

chmod [-r] XYZ file or directory

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 connected sub-directory will be changed

[email protected] ~]# ls-al bashrc-rw-r--r--  1395 Jul  4:  $  777~]# ls-al bashrc-rwxrwxrwx  1395 Jul  4 One: BASHRC.

Symbol Type Change file permissions

There's also a way to change permissions haha

U

G + (Join) R

chmod o-(remove) W file or directory

A = (set) x

Linux Learning _ Rookie Tutorial _4

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.