CHMOD: Tool for Open Source Administration - Mentally Converting from “read/write/execute” to 777 (Page 5 of 5 )
Now we go through the process of converting the -r, -w, -e modes, to the numerical (faster) way of implementing a chmod command. Remember how I said that the first three bits in binary (read 4, 2, 1) are what are used for read, write, and execute? That’s what we use. Look at Figure 2 to see this in a graphical implementation.

Figure 2
But that’s just one number. Yes, that one number is the first number, which is used for the owner. We still have two other permissions to set: one for group and one for world. You do the same for group and world as we did for owner: convert the textual (read, write, execute) permissions to the octet (777) permissions.
As we do this over the process, we come up with a situation. We need to set the following permissions for a file called test.txt: owner = read, write, execute; group = read, execute; world = read. This is our practical example. The permissions would be: 754. To get this follow Figure 3 as a guide.

Figure 3
So by way of the guide, you just add up the numbers that are “on” and leave out or put a zero (0) in place of an “off” number. You get your number and you go to the next object. When you are finished you come out with three (3) numbers; this is the chmod mode you are going to use. Remember that your mode is just permissions, so if you want to set certain permissions, your mode will change.
Using the Octet version of chmod in UNIX/LinuxNow that we know how to convert from mode permissions using -r, -w, -e to 777 (note: it's not always 777, it could be 755 -- it’s dependent on your permissions), we can now use this methodology in a UNIX/Linux environment. Say that we want to do a basic chmod, giving the owner read and write access, group write access, and the rest of the world read access to a file called text.txt. The following would be the correct way to do it:
Bash
That’s it! Take if from here, explore more ways of using the command line syntax. Don’t just look at it from the chmod perspective, look up other commands and compare them. Most of all, have fun and learn something new! Hope you enjoyed the article and that it helped you.
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |