Chmod how to understand values
When working with Linux, the user will have to grant or change access rights to files and directories. Use the command to display the access rights to files and directories ls –l.
Permissions are encoded with security bits represented e.g.. by writing:
1 | drwxr-xr-x |
The first signs mean:
- d - stands for directory
- – - means a file
- l - means a symbolic link
The next nine bits of rwxrwxrwx are responsible for the file or directory access settings:
- r - readable
- w - the ability to write
- x —Possibility to run
The first three bits of the rwx specify the permissions for file owner, the next three define user access security groups, to which the owner of the file belongs, and the last three relate to other system users.
A= Owner B= group C= All (Others)
A | B | C | |
chmod | 7 | 7 | 4 |
From the example above, chmod can be seen, that:
Owner and group: Full rights
Others: Read only
Explanation of permission numbers - linux
Digit | Permissions |
0 | Lack |
1 | follow |
2 | Save |
3 | Make and save |
4 | Read it |
5 | Read and execute |
6 | Read and write |
7 | Read it, save and execute |
Giving chmod permission to a file or folder
In the terminal through which you give commands to your linux, for example,. Ubuntu, enter e.g.:
chmod 774 nazwaPliku.sh
and click enter.
Thus, you have given permission to the file "filename.sh" 774, that is, the owner and the group have full rights, while others only read. You assigned the permissions from the example above with this method.
Change of file owner - chown
To change the owner of a file, use the command chown, with syntax:
1 | chown nazwa_właściciela nazwa_pliku |