CentOS File Rights Management

Source: Internet
Author: User
Tags file type file

Refer to Bird's private cuisine: http://vbird.dic.ksu.edu.tw/


First of all, a comparison of the pit: I used the company's FTP server A few days ago, the hands of the root directory to execute a bit of code

sudo chmod 777/-R

Duang, the system has collapsed. Root can't go in, all kinds of problems follow, remedial method tried a lot, but not all. Finally reluctantly reinstall the system. Fortunately, there is nothing important.


The cause of this problem: the rights management of the file smattering, only know that set 777 permissions, you can rest assured that the use. The final result is the error of non-operation. Can only say that smattering killed people, the Apprentice not fine pit dead.


The landlord to set the thinking, so re-learn the permissions of the file management this together.


The first command for Rights management:

CHGRP//Set permissions for groups Chown//set permissions for users and groups chmod//set Read and write execution permissions

Check the permissions of the files in the/root directory first:

[Email protected] ~]# ls-ll install.log-rw-r--r--. 1 root root 37332 November 21:11 Install.log printing Information The first part:-rw-r--r--//1th bit represents the file type, here is the normal file, if it is D, if it represents the directory, if L is the link 2-4 bits, indicating the permissions of the user who owns the file , here rw-, indicating that the owning user has read and write permissions 5-7 bits, representing the permissions of the group to which the file belongs, where R--, indicates that the owning group has read-only permission 8-10 bits, which represents the permissions of users and groups other than users and groups, where R--, indicates that other users and groups have read-only permission to do so: type User group other type users other part two: 1 means that the document link node has 1 third parts: root root indicates that the user of the file is root, and the group belongs to root Part IV: 37332 means the file size is 37332 bytes Part V: November 30 21:11 indicates time Part VI: Install.log represents the full format of file name files information: File type file permissions file link node belongs to user group file size last Edited time file name

To change permissions by using the Rights Management command:

Chgrp change file belongs to group: [[email protected] ~]# CHGRP test install.log[[email protected] ~]# ls-ll install.log-rw-r--r--. 1 root test 37332 November the 21:11 install.log file belongs to the group test, so members of the test group have read permissions to the Install.log file.

Chown change the user to which the file belongs:

[Email protected] ~]# chown test install.log[[email protected] ~]# ls-ll install.log-rw-r--r--. 1 test test 37332 November 21:11 install.log file belongs to Test.test user has read and write permission to Install.log file

Chown changing users and groups at the same time:

[Email protected] ~]# chown root:root install.log[[email protected] ~]# ls-ll install.log-rw-r--r--. 1 root root 37332 November 21:11 install.log by execution, chown user:group filename simultaneously changes users and groups

chmod changing permissions for a file

R stands for file readable, W stands for file writable, X stands for executable chmod  command format for file:     chmod u=rwx,g=rwx,o=rwx filename  //u represents the user, G represents the group, and O indicates the other     chmod +x filename               //Add executable Permissions     chmod -x  filename              //minus executable permissions [[email  protected] ~]# ls -ll install.log-rw-r--r--.  1 root root 37332  11 Month  30 21:11 install.log[[email protected] ~]# chmod u+x,g+x,o+x  install.log[[email protected] ~]# ls -ll install.log-rwxr-xr-x. 1  Root root 37332 11 month  30 21:11 install.log//increased, executable permissions [[email protected]  ~]# chmod -x install.log[[email protected] ~]# ls -ll  Install.log-rw-r--r--.  1 root rooT 37332 11 Month  30 21:11 install.log//Reduced executable permissions to change permissions digitally:rwx  4,2,1, 4+2+1 =  7 //All rights 4+2 = 6 //readable, writable 4 + 1 = 5 //readable, executable 2 + 1  = 3 //writable executable chmod 777 filename //user, group, others are readable, writable, can execute Chmod 755 filename  //user readable, writable, executable, group and other readable, enforceable [[Email protected] ~]# chmod 777 install.log[[email  protected] ~]# ls -ll install.log-rwxrwxrwx. 1 root root 37332  11 Month  30 21:11 install.log//Restore original permissions [[email protected] ~]# chmod 644  install.log[[email protected] ~]# ls -ll install.log-rw-r--r--.  1  Root root 37332 11 month  30 21:11 install.log file and directory permissions feature differences:file  rwx    //read-Write execution R     represents the contents of a file that can be read and written W write     can edit, add, or modify the contents of the file (but not delete it) x execute   The file can be executed as a binary file, just have such permission, the execution is successful, to see the file insideCapacity dir   rwx   //read and write execution r  representative can read and write the contents of a file w  create new files and directories    Delete existing files and directories    change the name of the file or directory    move the file or directory to another directory x  representative can access the file

CentOS file Rights Management

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.