torstai 4. huhtikuuta 2013

Linux permissions

Original instructions: http://linuxcommand.org/lts0070.php

While your computer will only have one keyboard and monitor, it can still be used by more than one user. That is why every file got its own permissions.

Permissions are divided in three sections "---" one "---" two "---" three. First one is for the user rights the "owner", second one is for group members and last one is for everybody else.

To see what permissions a file has type:
$ ls -l filename

-rw-rw-r-- 1 me me 1097374 Sep 26 18:48 filename

The file "some_file" is owned by user "me"
User "me" has the right to read and write this file
The file is owned by the group "me"
Members of the group "me" can also read and write this file
Everybody else can read this file

And to loan my studying material:


CHMOD

If you know how to calculate binaries or if you don't read my binary post below; It is easy to think of the permission settings as a series of bits (which is how the computer thinks about them). Here's how it works:


rwx rwx rwx = 111 111 111
rw- rw- rw- = 110 110 110
rwx --- --- = 111 000 000

---------------------------------------------------------------------

rwx = 111 in binary = 7
rw- = 110 in binary = 6
r-x = 101 in binary = 5
r-- = 100 in binary = 4



Now, if you represent each of the three sets of permissions (owner, group, and other) as a single digit, you have a pretty convenient way of expressing the possible permissions settings. For example, if we wanted to set some_file to have read and write permission for the owner, but wanted to keep the file private from others, we would:

$ chmod 600 some_file

In the link provided on top of this post there you can find better tables how to use chmod with numbers. 


CHANGING GROUP OWNERSHIP

The group ownership of a file or directory may be changed with chgrp. This command is used like this:

$ chgrp new_group some_file

Ei kommentteja:

Lähetä kommentti