Modification of file access rights under Unix operating system

  

Under the Unix operating system, the chmod command can be used to modify the access rights of the file. The format of the chmod command is as follows:

Format 1: chmod symbolic_mode file… Br>

Format 2: chmod absolute_mode file…

Format 1: symbolic mode (symbolic_mode), symbolic mode command format is as follows:

chmod [who] op permision file…

The who item represents the user type, and its content is one or more of the following:

u file owner (user --- owner)

g user group (group)

o Others (other)

a Everyone (all)

op items represent actions:

+ means to add the rights specified by permission

- Indicates that the permission specified by the permission is canceled.

The permission item is an access permission, and its content is one or more of the following:

r means readable

w means writable

x means executable

Example:

chmod u+w test report Owner-to-test and report files <; writable & rdquo ;

chmod ux abc.c Unable to execute abc.c file


chmod u+rwx myfile1 Owner pair myfile1“readable, writable, executable”

chmod ugo+rwx myfile2 Anyone is readable, writable, executable & rdquo;

Format 2: Absolute mode (absolute_mode), the command format for symbolic mode is as follows:

chmod xyz file…

x, y, and z are numbers from 0 to 7, respectively, indicating the access rights of the owner, user group, and others to the file. The formulas for x, y, and z are:

a*4 + b*2 + c

Tip: Where,

a=1 respectively means readable , a=0 means unreadable;

b=1 means writable, b=0 means not writable;

c=1 means executable, c=0 means unexecutable;

Example:

chmod 751 ncp Owners have all rights to ncp readable, writable, executable & rdquo; members of the group are only readable and readable. The right to execute & rdquo; other users have the right to "execute" for ncp.

Copyright © Windows knowledge All Rights Reserved