chmod is used to change the permissions of files or directories.
Let's say you are the owner of a file named myfile, and you want to set its permissions so that:
the user can read, write, and execute it;
members of your group can read and execute it; and
others may only read it.
Following are the symbolic representation of three different roles:
u is for user,
g is for group,
and o is for others.
Following are the symbolic representation of three different permissions:
r is for read permission,
w is for write permission,
x is for execute permission.
This command will do the trick:
chmod u=rwx,g=rx,o=r myfile
Here is the equivalent command using octal permissions notation:
chmod 754 myfile
Here the digits 7, 5, and 4 each individually represent the permissions for the user, group, and others, in that order. Each digit is a combination of the numbers 4, 2, 1, and 0:
4 stands for "read",
2 stands for "write",
1 stands for "execute", and
0 stands for "no permission."
So 7 is the combination of permissions 4+2+1 (read, write, and execute), 5 is 4+0+1 (read, no write, and execute), and 4 is 4+0+0 (read, no write, and no execute).
Let's say you are the owner of a file named myfile, and you want to set its permissions so that:
the user can read, write, and execute it;
members of your group can read and execute it; and
others may only read it.
Following are the symbolic representation of three different roles:
u is for user,
g is for group,
and o is for others.
Following are the symbolic representation of three different permissions:
r is for read permission,
w is for write permission,
x is for execute permission.
This command will do the trick:
chmod u=rwx,g=rx,o=r myfile
Here is the equivalent command using octal permissions notation:
chmod 754 myfile
Here the digits 7, 5, and 4 each individually represent the permissions for the user, group, and others, in that order. Each digit is a combination of the numbers 4, 2, 1, and 0:
4 stands for "read",
2 stands for "write",
1 stands for "execute", and
0 stands for "no permission."
So 7 is the combination of permissions 4+2+1 (read, write, and execute), 5 is 4+0+1 (read, no write, and execute), and 4 is 4+0+0 (read, no write, and no execute).
No comments:
Post a Comment