Linux Learning: Linux basic Command Set (4)

Source: Internet
Author: User

This records the following commands such as chmod, Chown, CHGRP, unmask use formats, common options, and what usages they have.

    • Rights Management Related commands

1. chgrp Change the user Group command of the file

Changes the user group to which the specified file belongs, where the group name can be a user group ID or a group name for the user group. If the user is not the file master or Superuser, the file's group cannot be changed.

Change the format of the user Group command to which the file belongs:

CHGRP [OPTION] ... GROUP FILE ...

CHGRP [OPTION] ...--reference=rfile FILE ...

OPTION:

- R recursive processing, processing all files and subdirectories under the instruction directory

- v show Instruction execution process

[Email protected] ~]# CHGRP-RV gentoo/usr/test

The owning group of "/usr/test/123/456/789" has been changed to Gentoo

The owning group of "/usr/test/123/456" has been changed to Gentoo

The owning group of "/usr/test/123" has been changed to Gentoo

The owning group of "/usr/test" has been changed to Gentoo

[Email protected] ~]# Ll-r/usr/test

/usr/test:

Total Dosage 4

Drwxrwxr-x. 3 Allen Gentoo 4096 September 3 20:39 123

/usr/test/123:

Total Dosage 4

Drwxrwxr-x. 3 Allen Gentoo 4096 September 3 20:39 456

/usr/test/123/456:

Total Dosage 4

Drwxrwxr-x. 2 Allen Gentoo 4096 September 3 20:39 789

/usr/test/123/456/789:

Total dosage 0

--reference the group in which the specified file or directory belongs to the same group as the reference file or directory

[[email protected] lab]# LL ABC TTT

-rw-rw-rw-. 1 root Allen 0 September 3 20:52 ABC

-rw-r--r--. 1 root root 0 September 3 20:52 TTT

[Email protected] lab]# chgrp--reference=./abc TTT

[[email protected] lab]# LL ABC TTT

-rw-rw-rw-. 1 root Allen 0 September 3 20:52 ABC

-rw-r--r--. 1 root Allen 0 September 3 20:52 TTT

2. chown Change the owner of the file or the workgroup command it belongs to

Change the owner of a file or directory and the group it belongs to, which can authorize a user to become the owner of the specified file or to change the group to which the file belongs. The user can be either a user or a user ID, and the user group can be either a group name or a group ID.

Change the file owner or the owning Workgroup command format:

chown [OPTION] ... [OWNER] [: [GROUP]] FILE ...

chown [OPTION] ...--reference=rfile FILE ...

OPTION:

-R recursive processing, processing all files and subdirectories under the instruction directory

-V Show Instruction execution process

[[email protected] lab]# LL ABC TTT

-rw-rw-rw-. 1 root Allen 0 September 3 20:52 ABC

-rw-r--r--. 1 root Allen 0 September 3 20:52 TTT

[Email protected] lab]# chown-v gentoo ABC TTT

The owner of "ABC" has changed to Gentoo

The owner of "TTT" has changed to Gentoo

[[email protected] lab]# LL ABC TTT

-rw-rw-rw-. 1 gentoo Allen 0 September 3 20:52 ABC

-rw-r--r--. 1 Gentoo Allen 0 September 3 20:52 TTT

--reference the owner of the specified file or directory to the owning group and the owner of the referenced file or directory is the same as the owning group

[Email protected] lab]# chown oracle:agetest ABC TTT

[[email protected] lab]# LL ABC TTT

-rw-rw-rw-. 1 Oracle agetest 0 September 3 20:52 ABC

-rw-r--r--. 1 Oracle agetest 0 September 3 20:52 TTT

3. chmod Change file Permissions command

Change permissions for a file or directory. The settings are either text or data code.

Change file Permissions command format:

chmod [OPTION] ... Mode[,mode] ... FILE ...

chmod [OPTION] ... Octal-mode FILE ...

chmod [OPTION] ...--reference=rfile FILE ...

OPTION:

- R recursive processing, processing all files and subdirectories under the instruction directory

-V Show Instruction execution process

[[email protected] lab]# ll TTT

-rw-r--r--. 1 Oracle agetest 0 September 3 20:52 TTT

[Email protected] lab]# chmod-v 755 TTT

The permission mode for "TTT" has been changed to 0755 (Rwxr-xr-x)

[[email protected] lab]# ll TTT

-rwxr-xr-x. 1 Oracle agetest 0 September 3 20:52 TTT

--reference the group in which the specified file or directory belongs to the same group as the reference file or directory

3. umask Set file default Permissions command

Sets the mask that restricts new file permissions. When a new file is created, its initial permissions are determined by the file creation mask. Each time the user registers into the system, the Umask command is executed and the mask mode is automatically set to restrict the permissions of the new file. The user can change the default value by executing the umask command again, and the new permission will overwrite the old.

Cannot have execute permissions based on security considerations

Set limit file default Permissions command format:umask [OPTION] [ARGS]

OPTION:

-S output a permission mask in symbolic form

[Email protected] lab]# umask-s

U=rwx,g=rx,o=rx

Default root masking code: 0022

Default masking code for normal users: 0002

Normal file initialization permissions are: 666

The directory file initialization permission is: 777

New file (-rw-rw--rw-)-(-----w--w-) ==>-rw-r--r-

When creating a new directory (DRWXRWXRWX)-(d----w--w-) ==>drwxr-xr-x

[email protected] lab]# Touch JJJ

[email protected] lab]# ll JJJ

-rw-r--r--. 1 root root 0 September 3 23:38 jjj

If you want to umask settings so that other users can access the JJJ file

[Email protected] lab]# Umask 0

[Email protected] lab]# umask

0000

[email protected] lab]# Touch JJJ

[email protected] lab]# ll JJJ

-rw-rw-rw-. 1 root root 0 September 4 09:22 jjj

This article is from the "Craft Life" blog, so be sure to keep this source http://allenh.blog.51cto.com/481430/1691335

Linux Learning: Linux basic Command Set (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.