unix file permissions...

They have: 447 posts

Joined: Oct 1999

the host that i have been using and learning perl on automatically chmods all files to 755, but now im starting to write scripts that will work universally but i dont fully understand these permissions.

does read/write mean the file can be read/written to, or the file can read/write to other files?

what is the difference between owner and group permissions?

If i have a count file that just stores a counter number, does that file need write permissions, or does the script writing to it need write permissions? owner, group or public?

I have looked and i cannot find a unix permissions tuit that makes much sense. If you know of one please post it.

Thanks!

They have: 568 posts

Joined: Nov 1999

I dont pay any attention to user, group, other.

I just use numbers, like on my linux pc

755 exec
777 write
666 worship sata... errr read. (just a little humour, no offense intended)

They have: 453 posts

Joined: Jan 1999

Each "normal" file has 9 flags.
3 for the owner of the file
3 for users in the same group as the owner
3 for others

the flags are:
r - for reading the file/directory
w - for writing to the file/directory
x - for executing the file/cding through the dir

usually you encode the flags in an octal triplet.
ABC
A = owner-perm
B = group-perm
C = other-perm

r = 4
w = 2
x = 1

So if you want rwx for the user and r-x for all others (including groups) you get:
A = 4(r)+2(w)+1(x) = 7
B = C = 4(r)+1(x) = 5
-> 755

Actually you don't you use a permission triplet, but don't bother with the fourth number, that's really complicated ...

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.