this post was submitted on 01 Nov 2024
66 points (79.5% liked)

Linuxsucks

172 readers
126 users here now

Shit on Desktop Linux and its evangelists here

No evangelizing for Linux

founded 1 month ago
MODERATORS
 
all 42 comments
sorted by: hot top controversial new old
[–] ladicius@lemmy.world 23 points 2 weeks ago (4 children)

Save a copy anywhere, get rights, overwrite original file with new file.

At least try that.

[–] Droggelbecher@lemmy.world 9 points 2 weeks ago (2 children)

Nice of you to try to help, but I don't think the people who post in this community are open to learning

WRONG

Arch is the only correct choice for an OS!!!

[–] Empricorn@feddit.nl 3 points 2 weeks ago (1 children)

But still not exactly like Windows!

[–] superkret@feddit.org 1 points 1 week ago

Actually if you open a file you only have read access to in Windows, it will be exactly the same.
Save it to your desktop, get rights, copy it to its original location.

[–] iks@lemmy.world 3 points 2 weeks ago

Save in /tmp

[–] madthumbs@lemmy.world -4 points 2 weeks ago

Easiest to rember trick I know of, but most people aren't going to know it the first time they're hit with it. lol

[–] billbasher@lemmy.world 16 points 2 weeks ago (1 children)

:w !sudo tee %

If you are in vim you can do this

[–] stoicmaverick@lemmy.world 2 points 2 weeks ago* (last edited 2 weeks ago) (1 children)

Does it work in Helix as well?

[–] billbasher@lemmy.world 2 points 2 weeks ago

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.

[–] Shadow@lemmy.ca 9 points 2 weeks ago (2 children)

Same shit happens with notepad in windows when editing the hosts file.

[–] MisterD@lemmy.ca 3 points 2 weeks ago (1 children)

Notepad++ handles this gracefully

It offers to relaunch itself elevated without losing what you just edited.

[–] superkret@feddit.org 1 points 1 week ago

And vim lets you elevate from inside it also.
This isn't an OS issue at all.

[–] madthumbs@lemmy.world -3 points 2 weeks ago* (last edited 2 weeks ago) (2 children)

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.

[–] theunknownmuncher@lemmy.world 1 points 2 weeks ago

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.

[–] lud@lemm.ee 1 points 2 weeks ago

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?

[–] Clent@lemmy.world 7 points 2 weeks ago
:w !sudo tee %

Further research because you wouldn't use sudo for something you don't understand, right?

Right?!?

[–] Ephera@lemmy.ml 5 points 2 weeks ago (1 children)

Modern versions of Vim warn about this. I guess, this might still be an annoyance with other editors?

[–] neidu3@sh.itjust.works 3 points 1 week ago

Ironically, I did this today when editing /etc/sudoers

[–] Steamymoomilk@sh.itjust.works 3 points 2 weeks ago

This is why i love micro. When you tell it to save without sudo it asks to elevate your privileges.

[–] baggins@lemmy.ca 1 points 2 weeks ago

I saw a one liner somewhere that lets you privesc the vi process you're running from the vi command prompt

[–] theunknownmuncher@lemmy.world 0 points 2 weeks ago (2 children)

The bike meme is accurate in that it is you who did it to yourself

[–] GBU_28@lemm.ee 5 points 2 weeks ago (1 children)

This description accurately describes the joke

[–] theunknownmuncher@lemmy.world -2 points 2 weeks ago (1 children)

Based on the community, I figured it was trying to imply that this is somehow Linux's fault

[–] GBU_28@lemm.ee 2 points 2 weeks ago (1 children)

This reply is a reasonable consideration

[–] theunknownmuncher@lemmy.world -1 points 2 weeks ago

Based on the other replies to my original comment, it seems that I was right...

[–] Anticorp@lemmy.world 0 points 2 weeks ago

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.