LinuxQuestions.org
Visit Jeremy's Blog.
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 04-10-2008, 09:35 AM   #1
jovie
Member
 
Registered: May 2006
Posts: 54

Rep: Reputation: 15
chown problem


Hi

I want to create files then change the ownership so a group of users (webdevelopers) can access them. Should be simple but I get "Operation not permitted" if I do the chown as myself. I can chown as root but I don't want to. I own both the dir the files are in and the files so what's the issue?

Thanks if you can help.


[ann@localhost tom]$ rm test
[ann@localhost tom]$ ls -l test
ls: cannot access test: No such file or directory
[ann@localhost tom]$ touch test
[ann@localhost tom]$ ls -l test
-rw-rw-r-- 1 ann ann 0 2008-04-10 14:26 test
[ann@localhost tom]$ chown ann:webdevelopers test
chown: changing ownership of `test': Operation not permitted
[ann@localhost tom]$ ls -ld ../tom/
drwxrwxr-x 3 ann webdevelopers 4096 2008-04-10 14:26 ../tom/
[ann@localhost tom]$
 
Old 04-10-2008, 09:41 AM   #2
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 63
The directory in which you are doing this might have the sticky bit set. Do this from the same location where you have this chown problem:
Code:
ls -ld .
*EDIT* scratch that, I saw the last lines of your code posting.
*ANOTHER EDIT* Well, do my command anyway. Maybe your prompt is mis-leading. Also, do this to see the filesystem type and mount options:
Code:
mount |grep $(df -k . |tail -n 1 |awk '{ print $1 }')

Last edited by matthewg42; 04-10-2008 at 09:44 AM.
 
Old 04-10-2008, 09:45 AM   #3
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 63
Also, do this:
Code:
lsattr -d .
 
Old 04-10-2008, 09:45 AM   #4
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670
Try chgrp instead to change the group ownership.

Or you could use acl's instead and add that group to the read list.

Code:
example:
setfacl -m group:tuser:rw- vlclog
jschiwal@hpamd64:~> getfacl vlclog
# file: vlclog
# owner: jschiwal
# group: jschiwal
user::rw-
group::r--
group:tuser:rw-
mask::rw-
other::r--
PS. You should also give your computer a real hostname instead of localhost.
PPS. I was wrong about not being able to change a group with chown if the owner stays the same.

Last edited by jschiwal; 04-10-2008 at 09:50 AM.
 
Old 04-10-2008, 09:48 AM   #5
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 63
Doh, I am silly. You're quite right. So you can switch to root first using su, or you can run using sudo if you have the right permissions.
 
Old 04-10-2008, 10:08 AM   #6
jovie
Member
 
Registered: May 2006
Posts: 54

Original Poster
Rep: Reputation: 15
I tried some of those but they don't enlighten me any.
I'm creating these files with a perl script, to chown as root I'd have to run the script as root which I'd rather not do.
I'll investigate the acl's. In the mean time is there a shell command that will let you set the owner:group as you create the file?

Thanks

Code:
[ann@localhost tom]$ chgrp webdevelopers test 
chgrp: changing group of `test': Operation not permitted

[ann@localhost tom]$ ls -ld .
drwxrwxr-x 3 ann webdevelopers 4096 2008-04-10 14:53 .

[ann@localhost tom]$ mount |grep $(df -k . |tail -n 1 |awk '{ print $1 }')
/dev/sda2 on /var type ext3 (rw)

[ann@localhost tom]$ lsattr -d .
-------------- .
[ann@localhost tom]$ man touch
 
Old 04-10-2008, 10:47 AM   #7
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 63
No, you need root permissions to do this, as jschiwal said. Forget my posts. I have a hang over
 
Old 04-10-2008, 10:58 AM   #8
overlook
LQ Newbie
 
Registered: May 2006
Location: Sweden
Distribution: Custom
Posts: 12

Rep: Reputation: 1
Just to make sure you didn't miss the obvious..

You are logged in as user "ann" right? She needs to be a member of "webdevelopers" if she's going to chown files to that group's ownership. The error message ("Operation not permitted") is exactly the message you'd get if ann lacks group membership.

(Yes, I noticed that the current directory was owned by ann:webdevelopers, but you might have not have gotten the Operation not permitted message if you chown'ed that directory as root)
 
Old 04-10-2008, 12:09 PM   #9
jovie
Member
 
Registered: May 2006
Posts: 54

Original Poster
Rep: Reputation: 15
Smile

Yeah, ann's a member of webdevelopers group.

I find it really strange that you have to be root to chown on a file you own but you can setfacl on the same file as yourself!?

Anyway, thanks jschiwal setfacl was exactly what I needed once I'd worked out what it was.

 
  


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
samba problem chown venki Linux - Newbie 2 02-06-2007 11:58 AM
[SOLVED] chown problem Wim Sturkenboom Linux - General 7 02-06-2007 03:18 AM
Problem with chown fgagnon Linux - General 9 04-03-2005 10:35 PM
chown problem rafc Linux - Newbie 6 07-06-2004 12:18 AM
chown problem Ayesha Linux - Newbie 4 04-17-2002 10:38 PM


All times are GMT -5. The time now is 06:54 AM.

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