LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 08-10-2020, 08:43 PM   #1
coltson
Member
 
Registered: Oct 2010
Posts: 149

Rep: Reputation: 3
Why I am being able to delete a root ownedfile?


Ok, there is this file "a" that has rwx permissions for everyone, so anyone can erase it.

I use cp to create "a2". a2 is created with has similar permissions, excepted that, for some reason, it does not allow members of other groups to write it. Then I use chown to make it to belong to root.

Yet, when I return to my normal user, I can erase it. How is that possible? And how I can avoid it?

Thanks for the help.
 
Old 08-10-2020, 08:51 PM   #2
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,727

Rep: Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211
How did you use cp? As root?
What are the permies of the containing directory?

Last edited by scasey; 08-11-2020 at 03:07 AM.
 
Old 08-10-2020, 10:09 PM   #3
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
The copy of a file doesn't have to have the same permissions as the original file.

As scasey alludes, to delete a file, you need write permission in the directory that contains the file. To prevent a normal user from deleting the file, remove directory write permissions.

Rather than describing your actions, it would be better to list the commands you enter and show the details of the files you create.

Last edited by berndbausch; 08-10-2020 at 10:12 PM.
 
Old 08-11-2020, 04:53 AM   #4
tshikose
Member
 
Registered: Apr 2010
Location: Kinshasa, Democratic Republic of Congo
Distribution: RHEL, Fedora, CentOS
Posts: 525

Rep: Reputation: 95
Hi,

It is not clear what you mean by "erase" the file, and how it can be different to "delete" the file.

If "erase" the file is emptying its content, then you need write permission to the file.
Remark that the file will still exist after being "erased", but with an empty content.

But differently, you need write permission to the containing folder to be able to "delete" the file.
That had been hinted by scasey in post #2.
 
Old 08-11-2020, 11:50 AM   #5
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Quote:
Originally Posted by coltson View Post
Ok, there is this file "a" that has rwx permissions for everyone, so anyone can erase it.

I use cp to create "a2". a2 is created with has similar permissions, excepted that, for some reason, it does not allow members of other groups to write it. Then I use chown to make it to belong to root.

Yet, when I return to my normal user, I can erase it. How is that possible? And how I can avoid it?
Show us.
Use --verbose switches where possible, and output of 'ls -al'.
 
  


Reply



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
i am not able to delete a Directory from my Pen Drive. when i trying to delete, it showing Error. Shahbaz_Mansuri Ubuntu 6 02-28-2018 05:01 PM
Why i m not being able to create repository using createrepo command in yum? sunilchand Linux - Newbie 5 02-13-2017 01:05 AM
how to prevent root from being able to vsftpd socalheel Linux - Server 5 10-09-2014 01:07 PM
Stopping non root users from being able to reboot a Linux server investmentbnker75 Linux - Security 3 10-30-2008 10:58 PM
how can I stop user from being able to su to root? Randux Slackware 7 06-13-2007 05:30 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:38 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
Open Source Consulting | Domain Registration