LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   chown problem (https://www.linuxquestions.org/questions/linux-newbie-8/chown-problem-634400/)

jovie 04-10-2008 08:35 AM

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]$

matthewg42 04-10-2008 08:41 AM

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 }')

matthewg42 04-10-2008 08:45 AM

Also, do this:
Code:

lsattr -d .

jschiwal 04-10-2008 08:45 AM

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.

matthewg42 04-10-2008 08:48 AM

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.

jovie 04-10-2008 09:08 AM

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


matthewg42 04-10-2008 09:47 AM

No, you need root permissions to do this, as jschiwal said. Forget my posts. I have a hang over :)

overlook 04-10-2008 09:58 AM

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)

jovie 04-10-2008 11:09 AM

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.

:)


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