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

    • Kind of glad I upgraded to S26 Ultra 1TB this year, with trade-in and discounts it cost me €1199, that's only €119 more than the S23 Ultra (256 GB) cost me. Last time I bought it via my phone provider outright with committing to two years, now via Samsung.com I reckon the S27 series will be more expensive too.
    • Save 66% on a MagTag Ultra Slim Tracker Card for Apple or Android by Steven Parker Never Lose Anything Again with MagTag Today's highlighted deal comes via our Gear + Gadgets section of the Neowin Deals store where you can save 66% on this MagTag Ultra Slim Tracker Card - Works with Apple Find My App. Keep track of your world with MagTag, a sleek, ultra-slim, reliable tracker that’s built to help you safeguard your most important items. In the size of a credit card, just 1.5mm thick, you can slip MagTag easily into your wallet, backpack, passport pouch luggage…etc. Integrated seamlessly with Apple’s FindMy app, MagTag offers precise real-time global tracking, instant left-behind alerts, loud location beeping, and a long-lasting rechargeable battery. Whether you’re heading to work, on vacation, or simply running errands, MagTag ensures you never lose what matters most. No item left behind Precision Global Tracking: Works seamlessly with the Apple FindMy app, providing real-time tracking anywhere in the world, powered by the vast Apple network. Ultra Slim Design: At just 1.5mm thick and the size of a credit card, MagTag slips easily into your wallet, passport pouch, backpack, or luggage. Instant Alerts: Receive notifications the moment you leave behind your valuables, and locate them easily with a loud beeping sound. Versatile Attachment Options: With a built-in keyring hole, attach MagTag to keys, ID lanyards, kids’ bags, or name tags for easy access and protection. Long Battery Life & Wireless Charging: Lasts up to 5 months on a single charge and can be easily recharged with any Qi wireless charger. Durable & Waterproof: IP68 waterproof and dustproof built to withstand your adventures, perfect for vacations and everyday use, no matter where life takes you. Specs Color: Black Materials: ABS Dimensions: 0.05" x 3.35" x 2.13" (1.5mm x 85mm x 54mm) Ultra-slim Apple FindMy App Built-in keyring hole Battery life: up to 5 months Charging: Qi wireless IP68 rating (waterproof, dustproof) Manufacturer's 90-day warranty Good to know Ships to US Expected Delivery: Expected Delivery: Jun 23 - Jul 2 All sales final. This item is excluded from coupons. Here's the deal: This MagTag Ultra Slim Tracker Card (for Apple or Android) normally costs $59.99, but you can pick it up for just $19.99 for a limited time - that represents a saving of $19. For a full description, specs, and shipping info, click the link below. MagTag Ultra Slim Tracker Card now just $19.99 (was $59.99) Get the two-pack and save 70% Ships only to Contiguous US Support queries If you have queries or need support for any of the Neowin Deals, please use the contact form here. Neowin Deals are managed and sold by StackCommerce who represent Neowin on an affiliate basis. Why we post these deals We post these because we earn commission on each sale so as not to rely solely on advertising, which many of our readers block. It all helps toward paying staff reporters, servers and hosting costs. So for those that keep moaning and complaining, be thankful we're still online for you to even do that. Other ways to support Neowin Whitelist Neowin by not blocking our ads Create a free member account to see fewer ads Make a donation to support our day to day running costs Subscribe to Neowin - for $14 a year, or $28 a year for an ad-free experience Disclosure: Neowin benefits from revenue of each sale made through our branded deals site powered by StackCommerce.
    • I cannot believe this is a news post from Neowin. This should be embarassing, coming from a "senior editor". Is it your first day using Windows?! Maybe it's time to find a new Windows news site.
  • Recent Achievements

    • Week One Done
      Huge Trailer earned a badge
      Week One Done
    • Week One Done
      Classifyskilleducation earned a badge
      Week One Done
    • One Month Later
      eurospharma62 earned a badge
      One Month Later
    • Week One Done
      With What earned a badge
      Week One Done
    • Week One Done
      Harris Gilbert earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      586
    2. 2
      +Edouard
      169
    3. 3
      PsYcHoKiLLa
      73
    4. 4
      Michael Scrip
      66
    5. 5
      ATLien_0
      64
  • Tell a friend

    Love Neowin? Tell a friend!