> For the complete documentation index, see [llms.txt](https://evansastre.gitbook.io/srvops/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://evansastre.gitbook.io/srvops/linux/linux-fundamental/file-management/permissions.md).

# chmod-Permissions

chmod用于改变文件和目录的权限

给指定文件的属主和属组所有权限(包括读、写、执行)

```
$ chmod ug+rwx file.txt
```

删除指定文件的属组的所有权限

```
$ chmod g-rwx file.txt
```

修改目录的权限，以及递归修改目录下面所有文件和子目录的权限

```
$ chmod -R ug+rwx file.txt
```

更多示例：[7 Chmod Command Examples for Beginners](http://www.thegeekstuff.com/2010/06/chmod-command-examples/)

```bash
# Permission  File                       | Directory
# r read     Allows a file to be read.   | Allowd file names in the directory to be read.   
# w write    Allows a file to be modified. | Allows entries to be modified within the directory.
# x execute  Allow the exexution of a file | Allows access to contents and metadata for entries.

#Permission Categories
#u    User
#g    Group
#o    Other
#a    All

#display a user's groups
groups
#or 
id -Gn


```

![](https://1210440778-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LFmi39lo4Ue7CKGIK7z%2F-LWgDH42zzhG-7vAV78-%2F-LWgDNrsv6KA2ytQ7Ll-%2Fimage.png?alt=media\&token=8c140697-9926-4560-bb97-350080b0d15e)

```
#change permission
#chmod        change mode command
#ugoa         user, group, other, all
+-=           Add, subtract, or set permissions
rwx           Read, Write, Execute

#example
chmod u=rwx,g=rx,o=     filename

```

```
#Numeric Based Permissions
#  r        w         x
#  0        0         0    value for off
#  1        1         1    binary value for on 
#  4        2         1    base 10 value for on

#example
chmod u=7,g=5,o=0    filename

#Symbolic       Octal
-rwx------      700
-rwxr-xr-x      755
-rw-rw-r--      664
-rw-rw----      660
-rw-r--r--      644

```

Umask

```
default
directory 777 
file      755
umask     0022
```
