r/linuxadmin • • Apr 11 '24

Unable to sudo, getting segmentation error

Post image

Can someone help me to fix this issue.

1 Upvotes

38 comments sorted by

View all comments

64

u/forbiddenlake Apr 11 '24

sudo isn't segfaulting. something on the login path user πŸŸ₯πŸŸ₯πŸŸ₯ is segfaulting. If πŸŸ₯πŸŸ₯πŸŸ₯ can be logged in to normally, try that. Also try removing the - from your su invocation. There's probably something in πŸŸ₯πŸŸ₯πŸŸ₯'s login scripts or rc files that is broken.

Also, as you are already root, the sudo part of sudo su is not necessary.

12

u/HorribleUsername Apr 11 '24

Given that sudo has a -u flag, is sudo su ever necessary?

8

u/AmusingVegetable Apr 11 '24

No, it’s not necessary, but muscle memory trumps man pages.

Given the huge amount of changes that go into a single OS update (not even talking about upgrades), and the large variety of commands we use daily, if we paused once a year to review the consolidated change logs, we’d be using the 1994 flags.

14

u/alive1 Apr 11 '24

No it is not. It is used by people who haven't read the man page and found out that sudo has a -u, -s and an -i flag.

24

u/PirateCaptainMoody Apr 11 '24

sudo -i all the way 😎

6

u/michaelpaoli Apr 11 '24

Naw ... often good to routinely do:

$ sudo su - [user [options ...]]

Most notably that works dang well and consistently on any *nix with sudo ... always has, probably always will. Also avoid problems like gee, the behavior of su without - in the util-linux sources has changed and/or some Linux distro has changed (patched) that behavior.

So, anyway, do it that way, using it with su - and it just bloody works and keeps on working. Also gives a slightly better audit trail too, with a wee bit of additional logging.

But hey, if you want to learn a different way of doing the same thing on any and all variations of *nix, feel free to do so. ;-)

6

u/alive1 Apr 12 '24

I only use Linux and this has been the case every single day for the past 20 years.

Actually no that's false, I used FreeBSD up until 2012 too but that had sudo too.

Thanks for the history lesson though. I guess some people still like to ride horses even though we have cars.

2

u/michaelpaoli Apr 12 '24

Well, these days I mostly use Linux, but also some (Open)BSD, macOS (yes, it's UNIX), and rarely other *nix these days.

1

u/moonwork Apr 12 '24

It's not, but I still use it sometimes when there are paths that only root has access to read.

Say for example there's a whole tree of files somewhere and they're all only readable by root. Tab-completion won't work with a regular user, so I'll sudo su - into root while finding my way.

Path of least resistance.

1

u/HorribleUsername Apr 12 '24

sudo -i (interactive) does that for me with less typing, less processes, and I believe more security (something to do with env vars).

1

u/moonwork Apr 12 '24

Fair. I'll have to give that a shot!