Some people think before they type. They also do not think mindlessly typing "sudo" before every fucking line in bash is a valid substitute for knowing what they do. Many of them have been doing so for decades on HPUX, Solaris, BSDs and IRIX on their own and other people's/companies machines, not just on their single bedroom machine.
It's easier to just call su once and run every single command as root rather than having to randomly use sudo for some commands and not for others (/s if it's not obvious)
In a lot of situations it's actually bad to use sudo because it can impact settings that make programs or file ownership go to root instead of the user.
You've got to be a damn idiot jumping over his own shadow to get that done. How would you even do that? Running
chown -R root.root
over directories or mount points? Deleting files in /dev or /run and recreating them using "touch" without looking up ownerships before? I wrote "touch" because anyone proceeding to "mknod" would at least have read some man pages. BTW, you'd need su for that rather than sudo.
Ah, I see your problem, you need to add --no-preserve-root.
See the French are super into wine - and grape vines are notoriously hard to get rid of, so if you want to really get rid of the French language pack, you need to rip that grapevine out by the root (e.g. don't preserve the root). Otherwise, the French language pack will just grow back harder and Frenchier than before.
I moved my father on Bluefin 1.5 years ago from his antique MacBook Air. He doesn't know sudo exists. He has never heard of ujust. He doesn't even command line. He hasn't had to do a single update because it all happens in the background. He just.. uses it.
doesn't even have to be atomic, I rescued my wife's shit laptop using Ubuntu Mate (snaps booing in background) and she has never seen the command line unless I open it. It's been like that for over a year at least.
I once did a HackTheBox where the privilege escalation weakness was a cronjob running a script. I'm not sure if I correctly remember all the details, but I think it read some parameters from a file and fed them to some other script. Since it had something to do with the webserver the user was administrating, they needed write access to the file, granted via ACL. That took me a while to spot, actually. Not sure why, but ACL is a constant blind spot for me. As for passing the parameters, you can just append the contents of the file to the command and pipe it to bash.
I don't recall what the normal script did, but it needed writing permissions for something. The proper way to do this would be ACL, but I guess I'm not the only one with a blind spot. The easy way to ensure the script can do whatever it needs to is to sudo the whole thing.
So what do you do if you have a script running every ten minutes, reading the first line of a file you can edit, then executing it with superuser privileges?
sudo -i starts a login shell as the specified user. Login shell means it'll read that user's bashrc/zshrc/whatever other login files and apply those. If no user is specified, then it'll login as root, so you get a root shell
OMG. There's literally more ignorance and bullshit than words in that sentence. It is so wrong that not even the opposite is true. I hope that was sarcasm - in which case I draw my hat because it would be a true peace of art.
Before voting me down, be sure to
man environ
and be sure you've understood at least what the environment variables do. If that is too hard for you, at least find out what the difference between a binary and a UID might be.
No arguments, just downvotes... I almost suspect some participants do not even understand what might be wrong with "you are sudo"? I also bet you don't have the right idea what the difference between effective UIDs might be depending if you're using "su", "su -i" , "su - " sudo or "sudo su". The differences are not exactly subtile and I dare to say admins on unixoids who don't know them are basically talking heads without an idea what they're actually talking about.
I have no idea how any of this is different. Sudo does things as root. Sudo -i logs you in as root where you can do things. So if there is a difference it is v subtle.
!! basically pastes the last ... action you took as an interaction with the shell. it's the same as pressing the up arrow, and putting whatever you want in the same position relative to the !!
Your terminal at boot. That would be TECTONIX or VT100 when your good old VAX has made a boo-boo once more? But I wouldn't know where to fill any Chinese contact spray ("sudo su", "Fu Manchu"...) in there. Or do you by any means mean your .bashrc? You know, before sucessfully shooting your own foot you'd need how to load and unlock.
Unpopular opinion:
On 99% of all Linux systems, you don't need sudo.
It's not like you have hundreds of users with varying levels of access logging into your PC.
Just use root for admin tasks.
Su often takes more time and is more involved, even if it's a difference between very little effort and no effort at all.
For example, I update and install apps through CLI about once a week, and I'd rather just bang the sudo than go su, enter root credentials, and only then go for what I wanted in the first place.
su [Enter] [Password] [Command] doesn't take longer than sudo [Command] [Enter] [Password]
And after you've done it once, you can just keep the terminal open and do all other admin tasks without typing sudo
Open another terminal (or tab) for user stuff.
This wouldn't do anything. Sudo is white magick while su is the devil's work, so they cancel out each other. I know, because I've read Harry Potter, seen "War Games" and am a social net Linux expert.
101 Comments
nieceandtows@programming.dev · 68 pts · 221d
Yeah I only use sudo once, for the su.
Hawke@lemmy.world · 44 pts · 221d
… but why? “sudo -i” is a thing. Why get another program involved?
SnotFlickerman@lemmy.blahaj.zone · 22 pts · 221d
Some people just want to watch the world burn.
b_tr3e@feddit.org · 9 pts · 221d
Some people think before they type. They also do not think mindlessly typing "sudo" before every fucking line in bash is a valid substitute for knowing what they do. Many of them have been doing so for decades on HPUX, Solaris, BSDs and IRIX on their own and other people's/companies machines, not just on their single bedroom machine.
exu@feditown.com · 8 pts · 221d
I don't think many people know about this feature
CoyoteFacts@piefed.ca · 7 pts · 221d
Personally it's because my fingers are already on "s" and "u".
nieceandtows@programming.dev · 6 pts · 221d
It's easier to just call su once and run every single command as root rather than having to randomly use sudo for some commands and not for others (/s if it's not obvious)
Hawke@lemmy.world · 6 pts · 221d
But you can do that without involving ‘su’.
slothrop@lemmy.ca · 7 pts · 221d
I don't use sudo.
Ever.
It's disabled by default in slackware, and I don't know why it's even there.
nieceandtows@programming.dev · 4 pts · 221d
Tell me how you can run rm rf / no preserve root without su, I'm waiting.
Hawke@lemmy.world · 14 pts · 221d
Is this some kind of joke going over my head or something?
Run “sudo -i” then run “rm -rf --no-preserve-root”
nieceandtows@programming.dev · 4 pts · 221d
Yeah I'm just joking around. I pretty much never use su except in rare cases
caseyweederman@lemmy.ca · 6 pts · 221d
Straight to jail.
stupidcasey@lemmy.world · 3 pts · 221d
I just delete every user but root.
MonkderVierte@lemmy.zip · 2 pts · 220d
I've seen that piece, mostly in beginner instructions, for a root shell. But does it even make sense? Why run a elevated su? Just run su.
nieceandtows@programming.dev · 2 pts · 220d
I think some distros don't expose or create a root password and make you do sudo su. I might be wrong.
SnotFlickerman@lemmy.blahaj.zone · 54 pts · 221d
Shut the front door!
In a lot of situations it's actually bad to use sudo because it can impact settings that make programs or file ownership go to root instead of the user.
30p87@feddit.org · 14 pts · 221d
makepkg won't even run as root iirc
exu@feditown.com · 12 pts · 221d
sudo -i -u user -s /usr/bin/bashb_tr3e@feddit.org · -2 pts · 221d
You've got to be a damn idiot jumping over his own shadow to get that done. How would you even do that? Running
over directories or mount points? Deleting files in /dev or /run and recreating them using "touch" without looking up ownerships before? I wrote "touch" because anyone proceeding to "mknod" would at least have read some man pages. BTW, you'd need su for that rather than sudo.
assa123@lemmy.world · 2 pts · 221d
fakesudo exists for a reason
Samsy@lemmy.ml · 41 pts · 221d
But rm -fr / * seems not to work for removing the French language pack. Can someone confirm if it works with sudo?
eatham@aussie.zone · 25 pts · 221d
Works fine with sudo, removes all the French bloat.
wltr@discuss.tchncs.de · 13 pts · 221d
I see French bloated my system to the fullest!
Samsy@lemmy.ml · 13 pts · 221d
Glad you fixed it. Don't forget to reboot.
plateee@piefed.social · 18 pts · 221d
Ah, I see your problem, you need to add
--no-preserve-root.See the French are super into wine - and grape vines are notoriously hard to get rid of, so if you want to really get rid of the French language pack, you need to rip that grapevine out by the root (e.g. don't preserve the root). Otherwise, the French language pack will just grow back harder and Frenchier than before.
Sacrebleu!
Samsy@lemmy.ml · 4 pts · 221d
Mondieu!
How could I have forgotten that?
TomMasz@piefed.social · 37 pts · 221d
How else will the OS know I'm serious ?
lost_faith@lemmy.ca · 9 pts · 221d
"Yes, Do as I say!"
varnia@lemmy.blahaj.zone · 22 pts · 221d
Oh, you mean better use doas everywhere? Got it.
RickyRigatoni@retrolemmy.com · 19 pts · 221d
sudon't tell me what to do
phaedrus@piefed.world · 2 pts · 221d
su:
SilentObserver@lemmy.world · 19 pts · 221d
Don’t need sudo if you’re always root.
Now excuse me. I need to call the bank and find out why my checking account is suddenly $0.
shane@feddit.nl · 4 pts · 221d
And yet half the time when I'm root I preface with sudo. I can't stop myself!
dream_weasel@sh.itjust.works · 17 pts · 221d
sudo man sudo
blaue_Fledermaus@olio.cafe · 17 pts · 221d
IMO the "year of the Linux desktop" will come when distros are designed for people who shouldn't even be allowed to use sudo.
Wfh@lemmy.zip · 20 pts · 221d
Let me introduce you to atomic distros.
I moved my father on Bluefin 1.5 years ago from his antique MacBook Air. He doesn't know
sudoexists. He has never heard ofujust. He doesn't even command line. He hasn't had to do a single update because it all happens in the background. He just.. uses it.Skullgrid@lemmy.world · 4 pts · 221d
doesn't even have to be atomic, I rescued my wife's shit laptop using Ubuntu Mate (snaps booing in background) and she has never seen the command line unless I open it. It's been like that for over a year at least.
Wfh@lemmy.zip · 6 pts · 221d
Yes, but contrary to atomic distros, it's not explicitely designed to be as administration free as possible.
luciferofastora@feddit.org · 16 pts · 221d
I once did a HackTheBox where the privilege escalation weakness was a cronjob running a script. I'm not sure if I correctly remember all the details, but I think it read some parameters from a file and fed them to some other script. Since it had something to do with the webserver the user was administrating, they needed write access to the file, granted via ACL. That took me a while to spot, actually. Not sure why, but ACL is a constant blind spot for me. As for passing the parameters, you can just append the contents of the file to the command and pipe it to bash.
I don't recall what the normal script did, but it needed writing permissions for something. The proper way to do this would be ACL, but I guess I'm not the only one with a blind spot. The easy way to ensure the script can do whatever it needs to is to
sudothe whole thing.So what do you do if you have a script running every ten minutes, reading the first line of a file you can edit, then executing it with superuser privileges?
Whatever the fuck you want.
FauxLiving@lemmy.world · 8 pts · 221d
You mean we shouldn't have a 'while true; eval $file' job running as root??? Goddammit, someone help me fix my remote admin script!!!
SilentObserver@lemmy.world · 1 pts · 221d
Huh. I might need to take a peek at one of my cronjobs now. 😂
FancyPantsFIRE@lemmy.world · 15 pts · 221d
klymilark@herbicide.fallcounty.omg.lol · 14 pts · 221d
I mean, yeah, it's your computer. Just login on the root account, nothing bad ever comes of that, not even once, nope.
SpikesOtherDog@ani.social · 2 pts · 221d
It's a lesson many of us learn the hard way.
commie@lemmy.dbzer0.com · 14 pts · 221d
sudo bash
wiccan2@lemmy.world · 14 pts · 221d
sudo -i
commie@lemmy.dbzer0.com · 3 pts · 221d
ooo what's that one do?
Hawke@lemmy.world · 11 pts · 221d
Starts an interactive session as root (or another user when combined with -u)
Oisteink@lemmy.world · 4 pts · 221d
It provides a login shell - like
So you get the full environment from that user
Hawke@lemmy.world · 1 pts · 221d
…Yes, I know.
sem@piefed.blahaj.zone · 0 pts · 221d
Not everything is all about you, dude.
rem26_art@fedia.io · 4 pts · 221d
sudo -istarts a login shell as the specified user. Login shell means it'll read that user's bashrc/zshrc/whatever other login files and apply those. If no user is specified, then it'll login as root, so you get a root shellmumblerfish@lemmy.world · 2 pts · 221d
Gives you a shell where you basically are sudo for every command.
b_tr3e@feddit.org · -2 pts · 221d
OMG. There's literally more ignorance and bullshit than words in that sentence. It is so wrong that not even the opposite is true. I hope that was sarcasm - in which case I draw my hat because it would be a true peace of art.
Before voting me down, be sure to
b_tr3e@feddit.org · 2 pts · 221d
No arguments, just downvotes... I almost suspect some participants do not even understand what might be wrong with "you are sudo"? I also bet you don't have the right idea what the difference between effective UIDs might be depending if you're using "su", "su -i" , "su - " sudo or "sudo su". The differences are not exactly subtile and I dare to say admins on unixoids who don't know them are basically talking heads without an idea what they're actually talking about.
sem@piefed.blahaj.zone · 1 pts · 221d
I have no idea how any of this is different. Sudo does things as root. Sudo -i logs you in as root where you can do things. So if there is a difference it is v subtle.
Steamymoomilk@sh.itjust.works · 12 pts · 221d
Sudo !!
👌👌👌 perfection
Atomilehma@sopuli.xyz · 2 pts · 221d
I came here to look for this.
Allero@lemmy.today · 1 pts · 220d
So for all that time one could do THIS?
BeatTakeshi@lemmy.world · 11 pts · 221d
Diplomjodler3@lemmy.world · 10 pts · 221d
Pfft. Real men always log in as root.
kill_dash_nine@lemmy.zip · 1 pts · 221d
You got that right. https://www.garyshood.com/root/
phaedrus@piefed.world · 7 pts · 221d
root@box ~# sudo fdisk -lTipsyMcGee@lemmy.dbzer0.com · 7 pts · 220d
AA5B@lemmy.world · 6 pts · 220d
Look at OP, claiming to have that mythical girlfriend who will make a sandwich without escalating privileges
yesman@lemmy.world · 6 pts · 221d
SAF77@lemmy.world · 6 pts · 221d
All you need is a single sudo su, correct.
bytesonbike@discuss.online · 13 pts · 221d
tourist@lemmy.world · 13 pts · 221d
FauxLiving@lemmy.world · 4 pts · 221d
People wouldn't just go on the Internet and lie... would they?
SAF77@lemmy.world · 1 pts · 220d
This is the way.
msage@programming.dev · 5 pts · 221d
Y'er a root, Harry!!
Flax_vert@feddit.uk · 5 pts · 221d
It's a nice precautionary measure
DasFaultier@sh.itjust.works · 17 pts · 221d
It is indeed.
For those unaware:
sudo !!if your previous command failed because you forgotsudo.PotatoesFall@discuss.tchncs.de · 8 pts · 221d
Let's say I run something like
rm a.txt && rm b.txt, willsudo !!work for both commands or just the first?Skullgrid@lemmy.world · 7 pts · 221d
!! basically pastes the last ... action you took as an interaction with the shell. it's the same as pressing the up arrow, and putting whatever you want in the same position relative to the !!
https://youtu.be/PRm6tYo8nGY?t=64
DasFaultier@sh.itjust.works · 4 pts · 221d
Relevant bash manpage section here.
DasFaultier@sh.itjust.works · 4 pts · 221d
I wasn't sure, so I tested this. Turns out, only
a.txtwould be deleted and removal ofb.txtfails due to lack of permissions.PoolloverNathan@programming.dev · 3 pts · 221d
!!is pure textual substitution, so it'd besudo rm a.txt && rm b.txt. You could do something likesudo sh -c "!!"though.thisisbutaname@discuss.tchncs.de · -2 pts · 221d
Both
themeatbridge@lemmy.world · 2 pts · 221d
TIL thank you!
jdr@lemmy.ml · 5 pts · 221d
sudo claude just fuck my shit upirelephant@lemmy.dbzer0.com · 5 pts · 221d
Sudo -iNaich@lemmings.world · 5 pts · 221d
Just once.
sudo -s
unknown1234_5@kbin.earth · 5 pts · 221d
sudo dnf --help
BurnedDonutHole@ani.social · 4 pts · 221d
Blasphemy!!!
ieatpwns@lemmy.world · 4 pts · 221d
If you’re using sudo for Rm -r / You’re doing it wrong
Endymion_Mallorn@kbin.melroy.org · 3 pts · 221d
Right. Just put sudo su in your terminal on boot, and you're set.
b_tr3e@feddit.org · 3 pts · 221d
Your terminal at boot. That would be TECTONIX or VT100 when your good old VAX has made a boo-boo once more? But I wouldn't know where to fill any Chinese contact spray ("sudo su", "Fu Manchu"...) in there. Or do you by any means mean your .bashrc? You know, before sucessfully shooting your own foot you'd need how to load and unlock.
leadpipe@piefed.social · 3 pts · 221d
But how will I run that command I copied from some murky internet forum?
bless@lemmy.ml · 3 pts · 221d
sudo winemech@feddit.org · 3 pts · 221d
Unpopular opinion:
On 99% of all Linux systems, you don't need sudo.
It's not like you have hundreds of users with varying levels of access logging into your PC.
Just use root for admin tasks.
Allero@lemmy.today · 2 pts · 220d
Su often takes more time and is more involved, even if it's a difference between very little effort and no effort at all.
For example, I update and install apps through CLI about once a week, and I'd rather just bang the sudo than go su, enter root credentials, and only then go for what I wanted in the first place.
mech@feddit.org · 2 pts · 220d
su [Enter] [Password] [Command]doesn't take longer thansudo [Command] [Enter] [Password]And after you've done it once, you can just keep the terminal open and do all other admin tasks without typing
sudoOpen another terminal (or tab) for user stuff.
CrazyLikeGollum@lemmy.world · 2 pts · 220d
You're right, just add
Sudo -sto/etc/profileprettybunnys@piefed.social · 2 pts · 221d
What if I told you I sudo as root
b_tr3e@feddit.org · 1 pts · 221d
This wouldn't do anything. Sudo is white magick while su is the devil's work, so they cancel out each other. I know, because I've read Harry Potter, seen "War Games" and am a social net Linux expert.
FreddiesLantern@leminal.space · 1 pts · 220d
Sudo -ku
DieserTypMatthias@lemmy.ml · 1 pts · 221d
Tell this to my cousin (though he probably does this to gaslight me).
DarkSideOfTheMoon@lemmy.world · 1 pts · 221d
I normally disable root, so I don’t think su would work. Never tried, so maybe I am using it wrong.
w3ird_sloth@lemmy.world · 1 pts · 221d
doas
MonkderVierte@lemmy.zip · 1 pts · 220d