:: krowemoh

Wednesday | 15 OCT 2025
Posts Links Other About Now

previous
next

Sudo su

2025-10-02
sysadmin

I keep wondering why sudo su doesn't source /etc/profile.

The answer according to this stackoverflow answer is that using su doesn't act as a login shell.

Only login shells source /etc/profile.

Here su won't cause the login to happen:

su
su root

While here it does:

su -
su - root

This means that you can do:

sudo su -

This will put you in superuser while also sourcing /etc/profile. I'm guessing that crons have this same problem in that they are launching shells without them being login shells.