LINUX under CHMOD|CHOWN|CHGRP and usage and distinction __linux

Source: Internet
Author: User
Tags chmod readable file permissions sqlplus

1, chgrp (change file to belong to user group)

CHGRP user Group filename # # #就是这个格了. If the entire directory is changed, the plus-r parameter is used for recursion.

such as: Chgrp-r user smb.conf

The CHGRP command changes the file or directory-owning group, such as the simplest:
View now the AA file belongs to the clip group:
[Root@clip clip]# ls-l AA
Total 32040
-rwxrwxr-x 1 Clip clip 1260 APR 14:05 AA
Want to change to Delijia
[Root@clip clip] #chgrp Delijia AA
[Root@clip clip]# ls-l AA
-rwxrwxr-x 1 Clip Delijia 1260 APR 14:05 AA
It's been successfully changed.

2. Chown (change file owner)

Format: A:chown user name File/directory

B:chown Username: User group: File/Directory

If the entire directory is changed, the plus-r parameter is used for recursion.

Example: Chown-r root/etc/config.cfg

Chown-r Root:root/home

3, chmod (change file properties)

There are two ways to set up a file property, which are numbers and symbols, respectively.

Mode: Permission set string, the format is as follows: [Ugoa ...] [[+-=][RWXX] ...] [,...] where u represents the owner of the file, G means that the owner of the file belongs to the same group (group), o means other people, and a says all three are.

+ means to increase permissions,-to indicate cancellation rights, = to represent a unique set of permissions.

R means readable, W is writable, X is executable, x means only if the file is a subdirectory or the file has been set to executable.

-S: The owner or group ID of the process is placed as the file owner of the file when the file is executed.

-C: Display the change action if the file permissions have actually changed

-F: Do not display error messages if the file permissions cannot be changed

-V: Show details of permission changes

-r: The same permission changes are made to all files under the current directory and subdirectories (that is, to be changed one at a time)

--HELP: Show Auxiliary Instructions

--version: Display version

  Example : Set the file file1.txt to be readable by all people:

chmod ugo+r File1.txt

Set the file file1.txt to be readable by all people:

chmod a+r File1.txt

The file file1.txt and File2.txt are set to the owner of the file and are writable by the same group as which they belong, but others are not writable:

chmod ug+w,o-w file1.txt File2.txt

Set ex1.py as only the owner of the file can perform:

chmod u+x ex1.py

All files and subdirectories under the current directory are set to anyone can read:

Chmod-r A+r *

When another user executes Oracle's sqlplus this program, his identity becomes Oracle for the time being.

chmod u+s Sqlplus

In addition, chmod can also use numbers to represent permissions such as chmod 777 file

Syntax is: chmod ABC file

Each of these a,b,c is a number, representing the permissions of user, Group, and other respectively.

R=4,w=2,x=1

To rwx the property is 4+2+1=7;

To rw-the property is 4+2=6;

To r-x the property is 4+1=5.

  Example :

chmod a=rwx File

And

chmod 777 File

Same effect

chmod ug=rwx,o=x File

And

chmod 771 File

Same effect

If you use chmod 4755 filename, you can make this program have root permissions

If the administrator is often said root user, basically have the right to see all the files

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.