Linuxsucks
Rules:
- FOSS advocates and Linux evangelists aren't welcome. -We ask that you block us.
- Moderation is heavy handed. Try to stay on topic (that is LINUXSUCKS!).
- No Complaining Mute the sub if users, content, or rules bother you *it's ok to report rule violations
:w !sudo tee %
If you are in vim you can do this
Does it have the same effect as sudoedit?
Does it work in Helix as well?
It looks like you can run shell commands so it should be possible although the syntax may be a bit different. I haven’t used Helix.
Same shit happens with notepad in windows when editing the hosts file.
Notepad++ handles this gracefully
It offers to relaunch itself elevated without losing what you just edited.
And vim lets you elevate from inside it also.
This isn't an OS issue at all.
You're right, some AI chat told me it wouldn't even open (by default). But at least it has a decent suggested solution in the error.
Kudos for being willing to try it and see!
One very minor detail to note, in your test you weren't actually overwriting the original file that you opened, but instead Notepad appended a .txt
to the filename, which is its default behavior, but you still got the same type or error because you didn't have write permission for any file in that directory.
It's so stupid that it can't bring open an UAC prompt instead. Come on Windows you have a standardized way to elevate! Why don't you use it?
:w !sudo tee %
Further research because you wouldn't use sudo for something you don't understand, right?
Right?!?
Modern versions of Vim warn about this. I guess, this might still be an annoyance with other editors?
Ironically, I did this today when editing /etc/sudoers
This is why i love micro. When you tell it to save without sudo it asks to elevate your privileges.
I saw a one liner somewhere that lets you privesc the vi process you're running from the vi command prompt
The bike meme is accurate in that it is you who did it to yourself
This description accurately describes the joke
Based on the community, I figured it was trying to imply that this is somehow Linux's fault
This reply is a reasonable consideration
Based on the other replies to my original comment, it seems that I was right...
If you open it in code instead of vim or nano, then you can escalate the privileges if needed. It's also easier to work with overall.