Computing.Net > Forums > Unix > file permission problem

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

file permission problem

Reply to Message Icon

Name: salman.ghani
Date: August 9, 2003 at 05:32:39 Pacific
OS: unix
CPU/Ram: p iii / 256
Comment:

hi

i have a little problem.

i want to know that can i set different permissions of a file or directory for different users in solaris. like i can do this in NT.

for example i have some users

user1 , user2 , user3 , user4

and file : file1

i want to give permissions of read to user1 and user2

and oermissions of write to user3 and user4.

can i do this in solaris.




Sponsored Link
Ads by Google

Response Number 1
Name: Don Arnett
Date: August 9, 2003 at 15:01:35 Pacific
Reply:

You need to read up on 'chmod', the command to set file permissions.

In UNIX/Linux you can set permissions for three different sets of users:

- the user/owner of the file

- the group (users who are in the same group as the group that owns the file)

- others (everyone else)


Since you want to give read permission to two users and write permission to two users, I think that you'll have to use 'group' and 'other' because two users can't both 'own' a file.

So if I'd suggest putting user3 and user4 in a group (ie writeGroup) and giving read/write permission to the 'writeGroup' and then setting the 'others' permissions to readonly. This actual will let anyone else (not just user1 & user2) have read permission, but I don't see a way around that.


So first, set the 'group' owner of the file to 'writeGroup':

chgrp writeGroup file1


Then, to set the permissions so that the owner has read/write, the group has read/write and the 'others' have readonly:

chmod 664 file1


There are other ways to use the 'chmod' command but I'm most used to using this form to set permissions. It's the quickest & easiest but requires that you can do a little bin to decimal conversion.


664 translates to permissions of

rw-rw-r--

where the first "rw-" is the permissions for the user/owner (read/write)

the second "rw-" is the permissions for the group (read/write)

the "r--" is the permissions for the 'others' (read only)

You'll note that 6 corresponds to rw- and 6 in binary is 110. 4 corresponds to r-- and 4 in binary is 100. Note that the 0 bits in the binary number correspond with the - in the permission sets.


Setting permissions isn't that hard, but there is a lot to explain. So, if this explanation is as clear as mud, you might just need to find a tutorial or chaptor or read 'man chmod'. But, the good news is that permissions in UNIX and Linux work the same, so you should be find with a Linux tutorial, which should be easy to find.

Good luck.

If you have specific questions about the above explanation, feel free to post them. It's just too much to explain.


0
Reply to Message Icon

Related Posts

See More


Shell script to find file... multiply decimals



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: file permission problem

file permission problem. need to open I www.computing.net/answers/unix/file-permission-problem-need-to-open-i/3415.html

File permission problem when using FTP www.computing.net/answers/unix/file-permission-problem-when-using-ftp/2587.html

Returning file permissions in Octal www.computing.net/answers/unix/returning-file-permissions-in-octal/4790.html