Unsolved
This post is more than 5 years old
1 Rookie
•
31 Posts
1
1463
September 10th, 2013 09:00
POSIX, Mode bits, UGOs in UNIX Permissions
I understand Windows permissions but when working with the UNIX world and POSIX and mode bits I'm getting lost. How do UNIX permissions work?



ScottPhelps
1 Rookie
•
31 Posts
2
September 10th, 2013 09:00
When looking at permissions on a file or folder (ls -l) you'll see something like this:
drwxr--r-- 1 fred accounting 2618 Sep 10 2013 filename.txt
The "d" means we're looking at a directory, the next three characters (rwx) are permissions for the owner of the file, the next three (r--) for the group, and the last three (r--) for other.
If we converted this to decimal we would would have 744 (111)(100)(100). This also shows that fred is the owner of the file and the group is accounting.
If I wanted to change permissions to give full control to the accounting group I could simply change the mode bits using the "chmod" command.
So, chmod 774 would modify the file so that it would look like this instead:
drwxrwxr-- 1 fred accounting 2618 Sep 10 2013 filename.txt.
Executing chmod 777 then gives everyone (fred, accounting, and other) all 3 permissions Read, write and Execute.
As should be clear, in the UNIX world, it's very important to know the user and group ownership of a file to set permissions correctly.