Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use chgrp and umask commands to control file permissions in Linux

2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article will explain in detail how to use chgrp and umask commands to control file permissions in Linux. The content of the article is of high quality, so the editor shares it for you as a reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.

Chgrp-change the group ownership of the file

Overview

Chgrp [options] group files. POSIX option: [- R] [- -]

Austin drafting option: [- hHLPR]

GNU group instruction: [--reference=rfile]

GNU option (simple format): [- cfvR] [--help] [--version] [[]]

Parameters.

-c,-- changes

Describe in detail the actions for each file: which group is actually changed.

-f,-- silent,-- quiet

Error messages are not listed. Those groups cannot be changed.

-h,-- no-dereference

Act on the symbolic link itself instead of what it points to. Available only when lchown system calls are provided.

-v,-- verbose

Describe in detail all files that work or do not work.

-R,-- recursive

Recursively change the group ownership of the directory and its contents

The code is as follows:

[root@localhost www] # chgrp zhangy phpinfo.php # change the user group

[root@localhost www] # ll | grep phpinfo

-rw-r--r-- 1 root zhangy 21 2012-07-28 phpinfo.php

[root@localhost www] # chgrp-R zhangy myweb # change the myweb directory and all the files in the directory belong to the group

Umask

The umask command is used to set a mask that restricts permissions for new files. 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 is automatically set to change the default value, and the new permissions will overwrite the old one.

Parameters:

-S: displays the current mask in the form of characters.

-p: displays the current mask with umask starting with a number

Umask "removes" the corresponding bit from the permission, and cannot grant execution permission when the file is created.

Example:

The code is as follows:

[root@localhost ~] # umask # View current user's preset permissions

0022

[root@localhost ~] # umask-S # shows permissions in alphabetical form

Uprirwx, gendrx, gendrx, overnrx.

[root@localhost] # umask-p

Umask 0022

[root@localhost ~] # umask 755 # set default permissions

[root@localhost ~] # umask

0755

On how to use chgrp and umask commands in Linux to control file permissions is shared here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report