LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   cannot open file to written (https://www.linuxquestions.org/questions/linux-newbie-8/cannot-open-file-to-written-511549/)

venki 12-18-2006 04:36 AM

cannot open file to written
 
HI i am admin!

there is /work..

here if user1 shld create a file but it is showing cannot open file.

user1 have to create a file.
user2 can view that file but he cannot delete this file..how it is possible
plz help

henry0712 12-18-2006 04:51 AM

check out the permission of the file

matthewg42 12-18-2006 05:10 AM

There are two general approaches. The first is using traditional user groups and permissions. This often sufficient for this sort of thing, but it is sometimes not fine-grained enough. The second approach is to use ACLs (access control lists) which give more flexibility.

With groups and ownership, you might approach it like this:
  • Change the owner of the directory to user1:
    Code:

    # chown user1 /work/...
  • Change the permissions of the directory to 755 (rwxr-xr-x)
    Code:

    # chmod 755 /work/...

user1's umask should be set so that new files created by user1 will be readable by all users on the system. To check if this is OK, you can just ty it. If if doesn't work, you should edit user's shell init file (probably ~/.bashrc) and add the line:
Code:

umask 0022

venki 12-18-2006 05:32 AM

thks sir,

sir i want both user1 and user2 have to create files ..here only user1 is able to create a file.plz help me.

matthewg42 12-18-2006 06:09 AM

Ah. That wasn't clear from the OP.

You have some choices, depending on other requirements. If you don't mind any user on the system creating files in the directory, you could make it like this:
  1. change the ownership an group of the directory back to root (I assume that was how it was originally):
    Code:

    # chown root:root /your/directory
  2. change the permissions of the directory to 1777. The 1 on the front means "set the sticky bit", which prevents user's from modifying one another's files. The permissions should look like this in the "ls -ld /your/directory" listing:
    Code:

    drwxrwxrwt 10 root root ...
    Now all users can create files in /your/directory, but (assuming their umask is set to the permissions are as described in my previous post) they can only modify only their own files.

You may wish to make it so ONLY these two users can make files in /your/directory. To do this, you need to create a new group. Lets name it "grp1" here for the sake of an example.
  1. Create the new group, grp1
  2. Add each of the users to the group, grp1 (they will need to log out and back in again to get the change)
  3. Change the owner and group of /your/directory like this:
    Code:

    # chown root:grp1 /your/directory
  4. Change the permissions of the directory like this:
    Code:

    # chmod 1775
    This will permit all users on the system to read files in the directory, but only members of grp1 (and root) to be able to create files there (they can read them too of course).

venki 12-18-2006 06:57 AM

Thks sir , thks a lot! it is very use-ful to me!


All times are GMT -5. The time now is 08:28 PM.