make file unchangeable?

Is there a way to make a file unchangeable even with sudo rights in linux?

i am porn addicted to i blocked by 85000+ porn sites via the host file ( /etc/hosts )

The Problem is that i can just change the file and watch porn again.
Is there any way to prevent this?
I was thinking of writting a script that overwrites the file every 3 seconds so every change will be ignored, but i have no idea how to practically do this
Anyone got ideas?

  1. 2 weeks ago
    Anonymous

    From my experience even if you found a way to do this it won't help you. In the end the only way to truly beat an addiction is self-control. Anything else is just temporary. You will eventually give in and simply reinstall your OS to fap. Or you'll use your phone.

    • 2 weeks ago
      Anonymous

      >Or you'll use your phone.
      i already sucessfully a way to block all porn on my phone and never watched porn on my phone ever since again

      • 2 weeks ago
        Anonymous

        Because you watch it on a bigger, better screen.

        From my experience even if you found a way to do this it won't help you. In the end the only way to truly beat an addiction is self-control. Anything else is just temporary. You will eventually give in and simply reinstall your OS to fap. Or you'll use your phone.

        fpbp

    • 2 weeks ago
      Anonymous

      yeah big agree. OP you gotta wrestle with your demons, you're not so weak that trying to lock them away is your only solution. Find strength in god

  2. 2 weeks ago
    Anonymous

    Just delete your sudoers file in /etc/sudoers
    youre welcome bb 😉

  3. 2 weeks ago
    Anonymous

    I don't think that you're asking is possible. The superuser can only slow down their own actions, not really prohibit them. Any mechanism to prevent modification can be dismantled by the superuser.

    I guess what you could do is generate a random throwaway password for root and remove any sudo privileges from yourself. That way you can't sudo into root and you can't login as root.
    Of course you would have prevent a single user mode, so that would have to make a other throwaway password to prevent that as well.
    As for the updating hosts file, you would have to make cron script that runs every 3 second to replace the host file with intended one. Has to be run as root as to prevent dismantling this step.

    Then again, you could just reinstall the computer entirely...

    Just have to work on self-control. Why do you gravitate to porn? boredom? You'll have to find another activity to replace the porn sessions.

  4. 2 weeks ago
    Anonymous

    >Is there a way to make a file unchangeable even with sudo rights in linux?
    Yea. You remove specific sudo priv to that file or makes its permissions only accessible by another user. Like user account you throw away the password for.

  5. 2 weeks ago
    Anonymous

    Yes
    Mount it from a physically RO locked SD Card (just break off the switch so that you won't be able to make it writable again)

    • 2 weeks ago
      Anonymous

      this has to be the smartest post i have seen here in a long time. Like ChatGPT couldn't have come up with this (to dumbed down and pussy).

      I will have to read more into mounting of file systems and changing existing file systems used by the system but this might actually work

      • 2 weeks ago
        Anonymous

        just make a symlink from /etc/hosts to wherever you've mounted it

  6. 2 weeks ago
    Anonymous

    chattr +i /etc/hosts && rm -f $(which chattr)

  7. 2 weeks ago
    Anonymous

    this won't stop your porn addiction

    the problem is, you have a void in your life that you're filling with porn, the moment you find something better to do and spend time on, you won't have to divert your attention towards porn

    instead of coming up with convoluted and easily bypassable solutions, find something better to do

    • 2 weeks ago
      Anonymous

      I fap because I'm lonely. I'm lonely because I fap. What do?

      • 2 weeks ago
        Anonymous

        Fuck men. I'm being serious.

  8. 2 weeks ago
    Anonymous

    run rm -rf /

    • 2 weeks ago
      Anonymous

      >can't change the file when there is no file
      high iq

      • 2 weeks ago
        Anonymous

        >no hosts file to edit
        >no browser to view porn on

        • 2 weeks ago
          Anonymous

          >>no hosts file to edit
          >>no browser to view porn on

          • 2 weeks ago
            Anonymous

            heh

  9. 2 weeks ago
    Anonymous

    Use an SELinux policy

    https://www.apriorit.com/dev-blog/cybersecurity-managing-file-access-with-selinux

    You'll forget how you did it and won't be able to change the file. Or you'll become an SELinux competent admin.

    If you used an sdcard you could just remove the SD card and the hosts file would be gone, defeating your blacklist.

  10. 2 weeks ago
    Anonymous

    Literally just stop looking at porn, if you're truly incapable of doing that then cut your power cables so you can't use the internet until you learn some self control

  11. 2 weeks ago
    Anonymous

    + porn sites via the host file ( /etc/hosts )

    Can I have a copy of that file?

    • 2 weeks ago
      Anonymous

      what for?

      • 2 weeks ago
        Anonymous

        just give us the fuckin file

        • 2 weeks ago
          Anonymous

          i want a fuckin square wave

  12. 2 weeks ago
    Anonymous

    i'm on no fap november and still going. i deleted league of legends a couple days ago. lets see how it goes

    • 2 weeks ago
      Anonymous

      Did you jerk off to League?

      • 2 weeks ago
        Anonymous

        no!! thats funny but its two separate addictions i think they add subliminal shit to league of legends for real dawg

        • 2 weeks ago
          Anonymous

          I once went 2 months without fapping because no new e-boi hentai doujins came out
          And I only fap to e-boi hentai
          If you had any taste you wouldn't get addicted to things in the first place.

  13. 2 weeks ago
    Anonymous

    The bottom line is that you cannot outsmart yourself. It's like trying to determine a winner when you're playing yourself in chess. Addict you is much more resilient than non-addict you. Trust me, if you're smart enough to put technical barriers between you and porn you're smart enough to overcome them when you feel like it.

  14. 2 weeks ago
    Anonymous

    can you just give us line number 54,383

  15. 2 weeks ago
    Anonymous

    make a new user and chown it or even better chown and chmod

Your email address will not be published. Required fields are marked *