[FAQ] "Command not found" when using su

Share your own howto's etc. Not for support questions!

[FAQ] "Command not found" when using su

Postby Head_on_a_Stick » 2019-07-30 15:10

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
Don't break DebianHow to report bugs

SharpBang GNU/Linux — a pre-configured Openbox/Tint2 desktop running on Debian stable
User avatar
Head_on_a_Stick
 
Posts: 10675
Joined: 2014-06-01 17:46
Location: /dev/chair

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

Postby cuckooflew » 2019-07-31 02:33

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
My grand father knows all about everything:
…one flew east, one flew west,
One flew over the cuckoo’s nest.
cuckooflew
 
Posts: 72
Joined: 2018-05-10 19:34
Location: Some where out west

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

Postby mrkapqa » 2019-08-04 15:54



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.
mrkapqa
 
Posts: 127
Joined: 2014-04-22 08:30

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

Postby Bulkley » 2019-08-04 16:31

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.
Bulkley
 
Posts: 5848
Joined: 2006-02-11 18:35

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

Postby Head_on_a_Stick » 2019-08-04 17:15

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
Don't break DebianHow to report bugs

SharpBang GNU/Linux — a pre-configured Openbox/Tint2 desktop running on Debian stable
User avatar
Head_on_a_Stick
 
Posts: 10675
Joined: 2014-06-01 17:46
Location: /dev/chair

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

Postby sickpig » 2019-08-07 13:02

pkexec is in built, why not use that?
User avatar
sickpig
 
Posts: 320
Joined: 2019-01-23 10:34

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

Postby Head_on_a_Stick » 2019-08-07 18:59

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.
Don't break DebianHow to report bugs

SharpBang GNU/Linux — a pre-configured Openbox/Tint2 desktop running on Debian stable
User avatar
Head_on_a_Stick
 
Posts: 10675
Joined: 2014-06-01 17:46
Location: /dev/chair

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

Postby Ardouos » 2019-08-28 11:27

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
Ardouos
 
Posts: 1055
Joined: 2013-11-03 00:30
Location: Elicoor II

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

Postby sunrat » 2019-08-28 23:55

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
sunrat
 
Posts: 2918
Joined: 2006-08-29 09:12
Location: Melbourne, Australia

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

Postby dilberts_left_nut » 2019-08-29 02:25

It would also break su'ing to other users.
AdrianTM wrote:There's no hacker in my grandma...
User avatar
dilberts_left_nut
 
Posts: 5020
Joined: 2009-10-05 07:54
Location: enzed

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

Postby sunrat » 2019-08-29 03:13

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
sunrat
 
Posts: 2918
Joined: 2006-08-29 09:12
Location: Melbourne, Australia

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

Postby dilberts_left_nut » 2019-08-29 07:10

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
dilberts_left_nut
 
Posts: 5020
Joined: 2009-10-05 07:54
Location: enzed

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

Postby Ardouos » 2019-08-30 09:51

Oh, I understand, forgive my ignorance. Best to leave it there so that others know I guess?
User avatar
Ardouos
 
Posts: 1055
Joined: 2013-11-03 00:30
Location: Elicoor II


Return to Docs, Howtos, Tips & Tricks

Who is online

Users browsing this forum: No registered users and 4 guests

fashionable