Вы находитесь на странице: 1из 5

Linux: File: Permission: Set: How to set your read/write/execute permissions?

[chmod / run] Method: use chmod Steps: Overview: 1. -In a console type the command chmod <permissions> <your filename> You use a 3 digit number to indicate the permissions. chmod 617 myfilename chmod 644 myfilename chmod 750 myfilename chmod 755 myfilename The first digit defines what permissions the owner (or creator) of the file has. The second digit defines what permissions the group the owner belongs to (e.g. the other developers) has. The third digit defines what permissions everybody else has. --Each category of permissions (read, write and execute) is assigned a numeric value (that is, the sum of 4, 2, 1 and 0 thus any integer number 0, 1, 2, 3, 4, 5, 6, 7) Read permission is 4 Write permission is 2 Execute permission is 1 (execute permission for a directory means that the directory can be searched) No permission is 0 If you want the owner or creator of the file to have permission to read, write, not execute the file, you assign 6 to the first digit (=4 + 2 + 0)

If you want the group of the owner or creator of the file to have permission to not read, not write, execute the file, you assign 1 to the second digit (=0 + 0 + 1) If you want to give everybody else the permission to read, write, execute the file, you assign 7 to the third digit (=4 + 2 + 1) Thus all together this gives: chmod 617 myfilename If you want the owner or creator of the file to have permission to read, write, not execute the file, you assign 6 to the first digit (=4 + 2 + 0) If you want the group of the owner or creator of the file to have permission to read, not write, not execute the file, you assign 4 to the second digit (=4 + 0 + 0) If you want to give everybody else the permission to read, not write, not execute the file, you assign 4 to the third digit (=4 + 0 + 0) Thus all together this gives: chmod 644 myfilename If you want the owner or creator of the file to have permission to read, write, execute the file, you assign 7 to the first digit (=4 + 2 + 1) If you want the group of the owner or creator of the file to have permission to read, not write, execute the file, you assign 5 to the second digit (=4 + 0 + 1) If you want to give everybody else the permission to not read, not write, not execute

the file, you assign 5 to the third digit (=0 + 0 + 0) Thus all together this gives: chmod 750 myfilename For example: If you want the owner or creator of the file to have permission to read, write, execute the file, you assign 7 to the first digit (=4 + 2 + 1) If you want the group of the owner or creator of the file to have permission to read, not write, execute the file, you assign 5 to the second digit (=4 + 0 + 1) If you want to give everybody else the permission to read, not write, execute the file, you assign 5 to the third digit (=4 + 0 + 1) Thus all together this gives: chmod 755 myfilename Note:You can quickly see if a file is executable for a group. If the digit is odd, it will be an executable (this because the execute option has the value 1, which is an odd number, and all the other numbers are even. And a sum of only even numbers is always even, but the sum of an even and an odd number is always odd. So if the sum includes the executable option it will the sum of (some even numbers) and an odd number. And there is only one odd number here, the executable option). Or thus a quick overview of each individual 1 digit: 0 = 0 + 0 + 0 = not read + not write + not execute 1 = 0 + 0 + 1 = not read + not write + execute 2 = 0 + 2 + 0 = not read + write + not execute

3 = 0 + 2 + 1 = not read + write + execute 4 = 4 + 0 + 0 = read + not write + not execute 5 = 4 + 0 + 1 = read + not write + execute 6 = 4 + 2 + 0 = read + write + not execute 7 = 4 + 2 + 1 = read + write + execute You can also use another accepted notation, using: r for read w for write x for execute u for owner g for group o for everybody else A quick way to make a file executable, is to type: chmod +x <your filename> chmod +x a.out To give read and write access to the 'owner', type: chmod u=rw <your filename> chmod u=rw lilo.conf To give execute access to the 'group', type: chmod g=x <your filename> chmod g=x a.out to add read access for 'everybody else' to the 'scd0' device, type

chmod o+r /dev/scd0

Вам также может понравиться