Effect of Permissions on Files
Effect of Permissions on Directories (Folders)
Directories are special types of files that can contain other files and directories.
Changing File permissions
The syntax of the chmod command when using the symbolic mode has the following format:
chmod [OPTIONS] [ugoa…][-+=]perms…[,…] FILE...
The first set of flags ([ugoa…]), users flags, defines the users’ classes for which the permissions to the file are changed.
u- The file owner.g- The users who are members of the group.o- All other users.a- All users, identical tougo.
When the users’ flag is omitted, it defaults to a.
The second set of flags ([-+=]), the operation flags, defines whether the permissions are to be removed, added, or set:
-- Removes the specified permissions.+- Adds specified permissions.=- Changes the current permissions to the specified permissions. If no permissions are given after the=symbol, all permissions from the specified user class are removed.
Each write, read, and execute permissions have the following number value:
r(read) = 4w(write) = 2x(execute) = 1- no permissions = 0
- Owner: rwx=4+2+1=7
- Group: r-x=4+0+1=5
- Others: r-x=4+0+0=4
Using the method above, we come up to the number 754, which represents the desired permissions.
Here are some examples of how to use the chmod command in numeric mode:
Give the file’s owner read and write permissions and only read permissions to group members and all other users:
chmod 644 dirnameGive the file’s owner read, write and execute permissions, read and execute permissions to group members and no permissions to all other users:
chmod 750 dirnameGive read, write, and execute permissions, and a sticky bit to a given directory:
chmod 1777 dirnameRecursively set read, write, and execute permissions to the file owner and no permissions for all other users on a given directory:
chmod -R 700 dirname
0 Comments
Post a Comment