|
| 1 | +## Python CHMOD Simplifier |
| 2 | + |
| 3 | +### What is CHMOD? |
| 4 | +'CHMOD' is a command used in Unix based systems that is used to change access permissions of files and directories. It is an abbreviation for 'Change Mode.' |
| 5 | + |
| 6 | +The CHMOD numerical format is composed of 3 digits, each ranging between 0 and 7. From left to right, each digit represents the corresponding permissions for _user_, _group_ and _other_ respectively. |
| 7 | + |
| 8 | +Each of these digits represents a binary value which controls the _read_, _write_ and _execute_ permissions pertaining to that group. A value of 1 indicates that the corresponding group is allowed an action, where as 0 indicates that the action is not allowed. |
| 9 | + |
| 10 | +Thus, each digit can be represented as r (read), w (write) and x (execute) symbolically based on the binary value of the indicating digit. |
| 11 | + |
| 12 | +For example, the chmod permission 755 can we interpreted as follows: |
| 13 | + |
| 14 | +| NUMBER | CLASS | BINARY | PERMISSION | rwx | |
| 15 | +|--------|--------|--------|----------------------|-----| |
| 16 | +| 7 | USER | 111 | read, write, execute | rwx | |
| 17 | +| 5 | GROUP | 101 | read, execute | r-x | |
| 18 | +| 5 | OTHERS | 101 | read, execute | r-x | |
| 19 | + |
| 20 | +Thus, 755 in the numerical format would translate to rwxr-xr-x. |
| 21 | + |
| 22 | + |
| 23 | +### This script converts symbolic representation of CHMOD permissions to it's numerical equivalent, and the Numerical representation of CHMOD permissions to its Symbolic equivalent as well. |
| 24 | +Example (numerical to symbolic representation): |
| 25 | +input: 777 |
| 26 | +output: rwxrwxrwx |
| 27 | + |
| 28 | + |
| 29 | +[Symbolic Representation](./SymbolicNotation.PNG) |
| 30 | + |
| 31 | +Example (symbolic to numerical representation): |
| 32 | +input: rwxrwxrwx |
| 33 | +output: 777 |
| 34 | + |
| 35 | + |
| 36 | +[Numerical Representation](./NumericalNotation.PNG) |
| 37 | + |
| 38 | +### How to use this script? |
| 39 | + |
| 40 | +1. The script has 2 options: |
| 41 | +- Symbolic to Numerical (N) |
| 42 | +- Numerical to Symbolic (S) |
| 43 | + |
| 44 | +Pass the desired mode of conversion while executing the script |
| 45 | + |
| 46 | +2. Run the following command: |
| 47 | + python chmod_simplifier.py <representation> <mode> |
| 48 | + |
| 49 | + Replace: |
| 50 | + - <representation> with 777 or rwxrwxrwx based on your preferred mode of conversion |
| 51 | + - <mode> with either 'S' or 'N' as per the desired mode |
| 52 | + |
| 53 | +3. View output on console |
| 54 | + |
| 55 | +### Author |
| 56 | + |
| 57 | +[Schezeen Fazulbhoy](https://github.com/schezfaz) |
0 commit comments