LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-18-2006, 05:36 AM   #1
venki
Member
 
Registered: Sep 2006
Location: India
Distribution: suse10.2
Posts: 128

Rep: Reputation: 15
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
 
Old 12-18-2006, 05:51 AM   #2
henry0712
LQ Newbie
 
Registered: Dec 2006
Posts: 5

Rep: Reputation: 0
check out the permission of the file
 
Old 12-18-2006, 06:10 AM   #3
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 63
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
 
Old 12-18-2006, 06:32 AM   #4
venki
Member
 
Registered: Sep 2006
Location: India
Distribution: suse10.2
Posts: 128

Original Poster
Rep: Reputation: 15
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.
 
Old 12-18-2006, 07:09 AM   #5
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 63
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).
 
Old 12-18-2006, 07:57 AM   #6
venki
Member
 
Registered: Sep 2006
Location: India
Distribution: suse10.2
Posts: 128

Original Poster
Rep: Reputation: 15
Thks sir , thks a lot! it is very use-ful to me!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Research Looks at How Open Source Software Gets Written LXer Syndicated Linux News 0 09-21-2006 02:33 PM
help on compiling a file written in expect bluelite28 Linux - Software 2 06-27-2006 02:08 AM
Geting error loop QFike:getch: File not open QFile:atEnd: this file is not open badgerbox76 Linux - Newbie 6 01-07-2006 06:30 PM
reading file written by shell using C kapil_dev Programming 9 09-10-2005 01:11 AM
How to get last file written to directory kd5giv Linux - Networking 4 03-29-2004 03:26 PM


All times are GMT -5. The time now is 06:42 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration