[FAQ] "Command not found" when using su

Share your own howto's etc. Not for support questions!
Post Reply
Message
Author
User avatar
Head_on_a_Stick
Posts: 13450
Joined: 2014-06-01 17:46
Location: /dev/chair

[FAQ] "Command not found" when using su

#1 Post by Head_on_a_Stick »

The su command in Debian buster is now provided by the util-linux package rather than the login package and it will not include the /sbin directories in PATH unless it is called like this:

Code: Select all

su -
^ Note the dash after the command.

Alternatively, to get an approximation of the old behaviour add this line to /etc/login.defs:

Code: Select all

ALWAYS_SET_PATH yes
See also https://www.debian.org/releases/buster/ ... -variables & https://bugs.debian.org/cgi-bin/bugrepo ... bug=905409
Black Lives Matter

Debian buster-backports ISO image: for new hardware support

cuckooflew
Posts: 681
Joined: 2018-05-10 19:34
Location: Some where out west

Re: [FAQ] "Command not found" when using su

#2 Post by cuckooflew »

Thanks again, much needed this Howto, I lost count on how many posts there are, and it was because the person between the chair and keyboard did not know about the new way su is handled on Debian. It had me confused when I first installed Debian 10, but I did some searches, and read about it here: https://wiki.debian.org/NewInBuster
Please Read What we expect you have already Done
Search Engines know a lot, and
"If God had wanted computers to work all the time, He wouldn't have invented RESET buttons"
and
Just say NO to help vampires!

mrkapqa
Posts: 154
Joined: 2014-04-22 08:30

Re: [FAQ] "Command not found" when using su

#3 Post by mrkapqa »

This info suggests using "sudo" instead of "su" .
but to get sudo working, i always had to to do "usermod -aG sudo username" as root
and to get to root it seems that "su" is no more appropriate.

i do understand that when one upgrades from an earlier edition , this info might be included and shown during the upgrade , but for new installs this info is nowhere to be seen.
I think it would be fair that an info screen would display such a " major change" after or during installation.

so in either case it is a bit confusing, and it doesn't clearly state why this change was necessary, if at all.

Bulkley
Posts: 6146
Joined: 2006-02-11 18:35

Re: [FAQ] "Command not found" when using su

#4 Post by Bulkley »

Head_on_a_Stick wrote:The su command in Debian buster is now provided by the util-linux package rather than the login package . . .
Not to sideline your information but do you have any idea why they did that? I've been using su for 20+ years without issue and now, seemingly out of the blue, someone decided to change it. Geez, when something works, don't fix it.

User avatar
Head_on_a_Stick
Posts: 13450
Joined: 2014-06-01 17:46
Location: /dev/chair

Re: [FAQ] "Command not found" when using su

#5 Post by Head_on_a_Stick »

mrkapqa wrote:to get sudo working, i always had to to do "usermod -aG sudo username" as root
If no root password is entered in the installer then the sudo package is installed and the first user is added to the sudo group automatically. Please continue any further discussion in your other thread, it is off-topic here, thanks.
Bulkley wrote:do you have any idea why they did that?
To align Debian with the other major distributions, this bug report has the full discussion: https://bugs.debian.org/cgi-bin/bugrepo ... bug=905409
Black Lives Matter

Debian buster-backports ISO image: for new hardware support

User avatar
sickpig
Posts: 589
Joined: 2019-01-23 10:34

Re: [FAQ] "Command not found" when using su

#6 Post by sickpig »

pkexec is in built, why not use that?

User avatar
Head_on_a_Stick
Posts: 13450
Joined: 2014-06-01 17:46
Location: /dev/chair

Re: [FAQ] "Command not found" when using su

#7 Post by Head_on_a_Stick »

sickpig wrote:pkexec is in built
Not necessarily:

Code: Select all

E485:~$ pkexec apt update
loksh: pkexec: not found
E485:~127$
And pkexec will not include the /sbin directories in PATH so the command will still not be found.
Black Lives Matter

Debian buster-backports ISO image: for new hardware support

User avatar
Ardouos
Posts: 1064
Joined: 2013-11-03 00:30
Location: Elicoor II

Re: [FAQ] "Command not found" when using su

#8 Post by Ardouos »

Another solution could be to alias "su -" in your .bashrc or globally in /etc/bashrc and /etc/bash.bashrc.

e.g.

Code: Select all

alias su="su -"

User avatar
sunrat
Global Moderator
Global Moderator
Posts: 3679
Joined: 2006-08-29 09:12
Location: Melbourne, Australia
Has thanked: 3 times
Been thanked: 5 times

Re: [FAQ] "Command not found" when using su

#9 Post by sunrat »

Ardouos wrote:Another solution could be to alias "su -" in your .bashrc or globally in /etc/bashrc and /etc/bash.bashrc.
That means you would not be able to use su in cases where you don't want to change the environment. I occasionally install a downloaded .deb and I can just use su in ~/Downloads/ to install it with apt as /usr/bin is in my user's environment but /sbin and /usr/sbin are not. apt is in /usr/bin.
I've seen some other chat why aliasing su is not advisable but can't recall right now.
“ computer users can be divided into 2 categories:
Those who have lost data
...and those who have not lost data YET ”
Remember to BACKUP!

User avatar
dilberts_left_nut
Posts: 5129
Joined: 2009-10-05 07:54
Location: enzed
Has thanked: 1 time
Been thanked: 1 time

Re: [FAQ] "Command not found" when using su

#10 Post by dilberts_left_nut »

It would also break su'ing to other users.
AdrianTM wrote:There's no hacker in my grandma...

User avatar
sunrat
Global Moderator
Global Moderator
Posts: 3679
Joined: 2006-08-29 09:12
Location: Melbourne, Australia
Has thanked: 3 times
Been thanked: 5 times

Re: [FAQ] "Command not found" when using su

#11 Post by sunrat »

dilberts_left_nut wrote:It would also break su'ing to other users.
I was going to write that but thought maybe it would just change to the other user's environment?
“ computer users can be divided into 2 categories:
Those who have lost data
...and those who have not lost data YET ”
Remember to BACKUP!

User avatar
dilberts_left_nut
Posts: 5129
Joined: 2009-10-05 07:54
Location: enzed
Has thanked: 1 time
Been thanked: 1 time

Re: [FAQ] "Command not found" when using su

#12 Post by dilberts_left_nut »

Yeah, you're right according to the man page.
I thought the contraction of -l to just - was only valid for root (by omitting <user>), but seems not.
AdrianTM wrote:There's no hacker in my grandma...

User avatar
Ardouos
Posts: 1064
Joined: 2013-11-03 00:30
Location: Elicoor II

Re: [FAQ] "Command not found" when using su

#13 Post by Ardouos »

Oh, I understand, forgive my ignorance. Best to leave it there so that others know I guess?

Post Reply