[RESOLVED] Homework - Permission
Hi,
I'm not sure if this goes in here or not but I am having trouble understanding how permission are changed.
Example:
This is an example our lecturer went through with us in class.
Determine the permissions that would apply if the following chmod commands were run?
chmod 777 file1 –rwxrwxrwx file1
chmod 754 file2 –rwxr-xr- file2
chmod 4222 file3 –wS-w—w- file3
chmod 2345 file4 –rwxr-Sr-x file4
chmod 1555 file5 –r-xr-xr-t file5
chmod 5705 file6 –rws---w-xt file6
Now, I understand that 777 is for a file and 666 is for a folder when everything is in player I am just confused how we ended up with the other values?
Thanks,
Nightwalker
Re: Homework - Permission
Re: Homework - Permission
Thanks! Although, I notice that S and t, etc weren't on that page?
Re: Homework - Permission
Code:
s setuid/gid details in Special modes section
t sticky details in Special modes section
from wikipedia source:
http://en.wikipedia.org/wiki/Chmod
-
edited to add:
http://superuser.com/questions/14771...le-permissions
Re: Homework - Permission
Quote:
Originally Posted by
Nightwalker83
Hi,
I'm not sure if this goes in here or not but I am having trouble understanding how permission are changed.
Example:
This is an example our lecturer went through with us in class.
Determine the permissions that would apply if the following chmod commands were run?
chmod 777 file1 –rwxrwxrwx file1
chmod 754 file2 –rwxr-xr- file2
chmod 4222 file3 –wS-w—w- file3
chmod 2345 file4 –rwxr-Sr-x file4
chmod 1555 file5 –r-xr-xr-t file5
chmod 5705 file6 –rws---w-xt file6
Now, I understand that 777 is for a file and 666 is for a folder when everything is in player I am just confused how we ended up with the other values?
Thanks,
Nightwalker
chmod assigns permissions based on octal values. For three-digit assignments, the first digit will be for "user", second digit for "group", third digit for "other". These are commonly called UGO permissions. Wikipedia has more information.
Note: You should never assign permissions of 777 (u=rwx,g=rwx,o=rwx) to any file or directory unless you want it to be world-writable for all users. Some system directories are normally set to 777. eg. /tmp
Files normally have 644 (u=rw,g=r,o=r) so they are not executable. Directories require execute permissions to be able to list the contents. This is normally 755 (u=rwx,g=rx,o=rx).
Re: Homework - Permission
It's easy to get confused coming from a Windows environment to *nix for the first time. Windows uses ACLs instead of the traditional unix permissions (I think Linux/Unix also supports posix ACLs). You can see this in action when you copy a file (eg. .doc) from a Windows machine to a USB stick. Viewing the contents of the USB stick under Linux would show the file to have permissions of 755, since all files in Windows are executable.
Re: Homework - Permission
Not sure if you've got to this yet, but umask can be used to set the file mode creation mask to specify the default permissions on new files. It's normally set from a login script such as ~/.profile.
Re: Homework - Permission
Quote:
Originally Posted by
tr333
Not sure if you've got to this yet, but umask can be used to set the file mode creation mask to specify the default permissions on new files. It's normally set from a login script such as ~/.profile.
Yeah, our lecturer talked to us about unmasking at Monday's class. Hopefully, we will have a repeat of that lesson because I was one of two students in class previously.
Re: Homework - Permission
Here is an example of how chmod works, at least it is simple enough for me to understand.
-rws (s represents suid) r-S (S represents sGid) r-- (the last - is where the sticky bit would be) file x
The chmod for that would be $chmod 6744 file x
rws = 7
r-- = 4
s from the suid = 4
S from the sGid = 2
The sticky bit would equal 1 if it were enabled, represented by a "t".
So the the original number 744 would not change but number in front will depending on whether a small or big "S" or a sticky bit.
Edit:
Forgot to say that big S or T = 0 or off and small s or t = 1 or on.
Re: Homework - Permission
Great stuff. I never bothered to learn about the extra sticky/setuid/setgid bits, but maybe I should.
Re: Homework - Permission
Yeah, it is interesting although, I have trouble understanding what seems normal teaching methods to some people that is why the above explanation (post #9) may seem a bit dumb down. I personally hate it don't dumb things down and make it easier for everyone to understand.
Edit:
Found this Permissions Calculator which, might be useful if you are a dummy like me at this stuff.