Help?!


Recommended Posts

what command would you use to make sure that you cannot easily delete a file called backup (which you own) without affecting other permissions?

This is a question in a lab I'm doing. I've racked my brain, I've racked Google's brain. I've tried a TON of other things, and I can't seem to figure it out... can anyone help?

Link to comment
https://www.neowin.net/forum/topic/1056948-help/
Share on other sites

have a look at chattr command

e.g : chattr +i filename.

with this command the permissions does not change and nor you can edit or delete the file unless >>>> chattr -i filename

Good command, but chattr +u backup is probably better (makes the file only undeleteable).

http://linux.about.com/od/commands/l/blcmdl1_chattr.htm

Link to comment
https://www.neowin.net/forum/topic/1056948-help/#findComment-594643080
Share on other sites

Upon closer inspection of the man page for chattr, +u would appear to be wrong:

When a file with the `u' attribute set is deleted, its contents are saved. This allows the user to ask for its undeletion.

But +i should work:

A file with the `i' attribute cannot be modified: it cannot be deleted or renamed, no link can be created to this file and no data can be written to the file. Only the superuser or a process pessessing the CAP_LINUX_IMMUTABLE capability can set or clear this attribute.
Link to comment
https://www.neowin.net/forum/topic/1056948-help/#findComment-594643230
Share on other sites

rm /bin/rm :D

But then again if you don't want to screw the system, chattr +i is the way to go.

AFAIK you must execute it as root, though, and root still can delete the file. It just prevents plain users from modifying it in any way.

You could also make the file undeletable for every user including root using SELinux, or replace rm with the safe-rm wrapper and add your backup file to the blacklist.

Link to comment
https://www.neowin.net/forum/topic/1056948-help/#findComment-594643438
Share on other sites

Correct answer is

Chmod u-w backup

That removes write permissions, but that doesn't prevent you from deleting the file, even in a regular, non-root account.


[nick@fedora16vm ~]$ touch file.txt
[nick@fedora16vm ~]$ ll file.txt
-rw-rw-r-- 1 nick nick 0 Feb 10 13:06 file.txt
[nick@fedora16vm ~]$ chmod u-w file.txt
[nick@fedora16vm ~]$ ll file.txt
-r--rw-r-- 1 nick nick 0 Feb 10 13:06 file.txt
[nick@fedora16vm ~]$ rm file.txt
rm: remove write-protected regular empty file `file.txt'? y
[nick@fedora16vm ~]$ ll file.txt
ls: cannot access file.txt: No such file or directory
[/CODE]

Edit:

/threadhijack: I'm unfamilar with the chattr, but highly interested... but I can't get it work. Any ideas? (Fedora 16)

[CODE]
[nick@fedora16vm ~]$ chattr +i file.txt
chattr: Operation not permitted while setting flags
[/CODE]

Link to comment
https://www.neowin.net/forum/topic/1056948-help/#findComment-594646092
Share on other sites

That was the answer the Professor gave me, and the program he wrote to check answers said it was correct... thus I have to accept it's wrong, even if it isn't. :s

Link to comment
https://www.neowin.net/forum/topic/1056948-help/#findComment-594646242
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • The problem of course is simply that government does not always know best. My point is that agency is taken away from the EU consumer in these cases. I'm sorry, but I do not believe that governments (politicians) are inherently good, and "looking out for me." Primarily they look to themselves and their own personal desires first, foremost, and always. When the EU or the DOJ fines these companies, claiming to "represent the welfare of the consumer," how much of these billion-dollar judgments are handed to the consumers they claim to represent? Not even a dollar, as I've seen. Yet the EUC lawyers who are paid to sit around and dream up these suits make huge commissions on the fines the EUC adjudicates, which is an ironclad fact I hope everyone is aware of. It's also rank corruption, of course, but that's another topic. Last, when the EU inflicts these judgments, or the DOJ, take your pick, the costs are bundled right along in the cost of the goods and services these companies provide the consumers they are "looking out for." If you are someone who believes his government is his savior then you have my condolences. I think Apple is right here, because the whole scheme of consumer choice is that consumers pick and choose among the products companies offer. Microsoft Windows is more compatible with third party software and hardware than any desktop OS on Earth, which is my sole reason for choosing it. Just because the EUC forces companies do certain things it knows the companies do not want to do, "or else", has no bearing on consumer benefit. This Siri thing is almost idiotic it's so infantile. But this is what the EUC does when the EU in Brussels becomes cash-strapped and needs a big infusion of cash. Some people get upset by "big companies" but it's the opposite when governments dwarf the size and scope of these companies, which is so obvious it hurts.... I mean you can't honestly believe that forcing Apple to do things with Siri it has its own reasons to decline is something that "opens up" Apple, do you? Say it aint' so...
    • Looks like many years since the request was made, a directory tree view finally may be added. https://github.com/files-community/Files/pull/18537
    • There's this from last year https://gist.github.com/threat...364659a8887841aa43deca4efd9 but nothing about a buffer overflow that MS somehow can't code against. No matter what, it makes sense to take a "protected by default" approach.
  • Recent Achievements

    • One Month Later
      sjbousquet earned a badge
      One Month Later
    • Week One Done
      sjbousquet earned a badge
      Week One Done
    • First Post
      DragonOfMercy earned a badge
      First Post
    • First Post
      bella52 earned a badge
      First Post
    • Reacting Well
      Techinmay earned a badge
      Reacting Well
  • Popular Contributors

    1. 1
      +primortal
      501
    2. 2
      PsYcHoKiLLa
      214
    3. 3
      +Edouard
      156
    4. 4
      Steven P.
      84
    5. 5
      FloatingFatMan
      72
  • Tell a friend

    Love Neowin? Tell a friend!