Linux File Management Commands (ii)

Source: Internet
Author: User

Linux File Management Commands (ii)

chgrp : The group that is used to change the file or directory.

The control of file or directory permissions is managed by the owner and the group to which it belongs. The settings are either group name or group ID.

Grammar:

Chgrp [-cfhrv][--help][--version][belongs to group] [file or directory ...] or chgrp [-cfhrv][--help][--reference=< reference file or directory >][-- version][file or directory ...]
Parameters:

The-C or--changes effect resembles the "-V" parameter, but returns only the part of the change.

-F or--quiet or--silent does not display an error message.

-H or--no-dereference only modifies the signed file, without altering any other related files.

-R or--recursive recursively handles all files and subdirectories under the specified directory.

-V or--verbose shows the instruction execution process.

--help online Help.

--reference=< reference file or directory > set all of the assigned files or directories to the same group as the reference file or directory.

--version Displays version information.

eg

1: Change the group properties of the file.

Chgrp-v bin Log2017.log

Output:

[email protected] test]# LL
---xrw-r--1 root root benet 9-7 16:34 log2017.log

[Email protected] test]# Chgrp-v bin Log2017.log

The owning group for "Log2017.log" has changed to Bin

[email protected] test]# LL
---xrw-r--1 root bin Benet 9-7 16:34 log2017.log

Description

Change the Log2017.log file to a bin group with the root group.


2. Change the group properties of the file according to the development document.

Chgrp--reference=log2017.log Log1996.log

Output:

                   [[email  Protected] test]# ll
                 ---xrw-r--1 root bin  b Enet 9-7 16:38 log2017.log
                   -rw-r--r--1 root root     9-7 16:38 log1996.log
                  &NBSP;[[EMAIL&NBS P;protected] test]#  chgrp--reference=log2017.log log1996.log
              & nbsp    [[email protected] test]# ll
                   --- xrw-r--1 Root bin  benet 9-7 16:38 log2017.log
                  &NB sp;-rw-r--r--1 Root bin      61 9-7 16:38 log1996.log

Description

Change the group properties of the file Log1996.log, making the group properties of the file Log1996.log the same as the group attributes log2017.log the reference file.


Unix: File invocation permissions are divided into three levels: file owners, groups, and others. Chmod can be used to control how files are called by others.

Permission to use:

All users.

Grammar:

chmod [-CFVR] [--help] [--version] mode file...
Parameters:

Mode: Permission set substring in the following format:

[Ugoa ...] [[+-=][RWXX] ...] [,...]

U represents the owner of the file, and G indicates that the owner of the file belongs to the same group (group), and O means the other person, and a means that all three are.

+ indicates an increase in permissions,-represents a cancellation permission, = Represents a unique set of permissions.

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

-C: If the file permission has changed, it will not show its change action

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

-V: Show details of permission changes

-r: The same permissions change for all files in the current directory as subdirectories (that is, they are changed in a recursive manner)

--HELP: Show Auxiliary Instructions

--version: Display version

eg

Set the file Yuping.txt to be readable by everyone:

chmod ugo+r Yuping.txt

Set the file Yuping.txt to be readable by everyone:

chmod a+r Yuping.txt

The file Yuping.txt and Chutianyi.txt are set to the owner of the file, and the same group that they belong to can write to, but not others:

chmod ug+w,o-w yuping.txt Chutianyi.txt

Set yuping.py to only the owner of the file can execute:

chmod u+x yuping.py

Set all files and subdirectories in the current directory to be readable by anyone:

Chmod-r A+r *

In addition chmod can also use numbers to represent permissions such as:

chmod 777 File

The syntax is:

CHMOD ABC File

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

R=4,w=2,x=1

To rwx the attribute then 4+2+1=7;

To rw-the attribute then 4+2=6;

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

chmod a=rwx File

And

chmod 777 File

Same effect

chmod ug=rwx,o=x File

And

chmod 771 File

Same effect

Use chmod 4755 filename to give this program root privileges





This article is from the "13176526" blog, please be sure to keep this source http://13186526.blog.51cto.com/13176526/1963471

Linux File Management Commands (ii)

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.