Changing Permissions With Numbers

Each permission setting can be represented by a numerical value:


  • r = 4

  • w = 2

  • x = 1

  • - = 0


When these values are added together, the total is used to set specific permissions.


For sneakers.txt, here are the numerical permissions settings:



 -  (rw-)   (rw-)  (r--)
| | |
4+2+0 4+2+0 4+0+0

The total for the user is six, the total for the group is six and the total for others is four. The permissions setting, then, is read as 664.


If you want to change sneakers.txt so those in your group will not have write access, but can still read the file, remove the access by subtracting 2 from that set of numbers.


The numerical values, then, would become six, four, and four — or 644.


So type:


chmod 644 sneakers.txt

-- snapped from Changing permisions with Numbers

0 comments: