Operating System - HP-UX
1836775 Members
2178 Online
110109 Solutions
New Discussion

rm: xyz not removed. Permission denied

 
Sanjiv Sharma_1
Honored Contributor

rm: xyz not removed. Permission denied

batch1 and batch2 are member of the same group rst. File created by batch1 with permission rw-rw---- cannot be removed by batch2.

$ ll xyz
rw-rw---- 1 batch1 rst 0 Jun 17 23:50 xyz
$ whoami
batch2
$ rm -f xyz
rm: xyz not removed. Permission denied

What could be the reason?
Everything is possible
11 REPLIES 11
Steven E. Protter
Exalted Contributor

Re: rm: xyz not removed. Permission denied

The file is probably open and held by a process.

fuser -cu might help you find the process and kill it.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Sanjiv Sharma_1
Honored Contributor

Re: rm: xyz not removed. Permission denied

I have created a file xyz from user batch1.
$ touch xyz

Then login as batch2 and try to remove the file but it doesn't.

The file xyz is not open.
Everything is possible
Fred Ruffet
Honored Contributor

Re: rm: xyz not removed. Permission denied

Could you provide output from the id command with both users ? Also, to remove a file, you must have permission to write in the directory in order to remove inode.

Regards,

Fred
--

"Reality is just a point of view." (P. K. D.)
Dave Hutton
Honored Contributor

Re: rm: xyz not removed. Permission denied

Is batch2 in the same group as batch1?

Did you log out of batch2 and back in to make the changes?
What does
$id
show?
Do you have the link for /etc/logingroup
Bill Hassell
Honored Contributor

Re: rm: xyz not removed. Permission denied

Actually, the ownership and permissions of a file NEVER control whether you can remove it (or rename it). A file's permissions are only related to the content. The existence (creation or removal) are 100% controlled by the directory. If you do not have write capability to the directory (and access to the parent directories above it) then the file can be rw-rw-rw and you can't remove it. Normal Unix behavior.

There is one consideration called the sticky bit. If the directory has 777 permissions (like /tmp) then anyone can remove any file in /tmp, even if the file is owned by root and has 000 permissions. But change the directory to 1777 permissions (drwxrwxrwxt - the t is the sticky bit) and now, only the file's owner can remove or rename/move a file in that directory.


Bill Hassell, sysadmin
Sanjiv Sharma_1
Honored Contributor

Re: rm: xyz not removed. Permission denied

$ id
uid=18056(batch1) gid=205(rst)

$ id
uid=18056(batch2) gid=205(rst)

The folder permission is
drwxr-x---

I think the folder permission is the cause.
Everything is possible
Sandman!
Honored Contributor

Re: rm: xyz not removed. Permission denied

Could be that the sticky bit is set on the directory that contains the file. Could you post the output of "ls -latr"

thanks
Steve Lewis
Honored Contributor

Re: rm: xyz not removed. Permission denied

It could also be because of chmod u+t on the directory.

Except that in the case of drwxrwxrwt perms it says
rm: xyz not removed. Not owner.

So it looks like you need a case of g+wx on the directory as said above.



Fred Ruffet
Honored Contributor

Re: rm: xyz not removed. Permission denied

Raje,

It's clearly the cause. You didn't put it, but I imagine that group for the directory is rst. This group doesn't have w permission on the directory and so cannot remove a file in it (neither create).

Regards,

Fred
--

"Reality is just a point of view." (P. K. D.)
Bharat Katkar
Honored Contributor

Re: rm: xyz not removed. Permission denied

Yes Fred is right. just change the directory permissions to 770 and it should solve ur problem.
Regards,
You need to know a lot to actually know how little you know
Bill Hassell
Honored Contributor

Re: rm: xyz not removed. Permission denied

You posted the permissions on the directory (750) which means only the owneer of the directory can remove files from the directory. If users batch1 and batch2 are members of the same group, then the directory must also be owned by that group *AND* change the permission to 770 (drwxrwx---)


Bill Hassell, sysadmin