On Wed, Mar 26, 2025 at 07:48:16 -0500, Richard Owlett wrote:
> On 3/26/25 6:55 AM, Greg Wooledge wrote:
> > I normally use "sudo -s", which is the closest sudo approximation to
> > the traditional behvior of "su" (before it was broken in buster).
> 
> I don't understand the reference to some "brokenness" of "su".
> I've not closely followed this thread so I may be missing context.

Out of the box, in Debian 1.1 through 9, "su" with no arguments would
give you a root shell with the PATH variable changed to include
/usr/local/sbin, /usr/sbin and /sbin.

Out of the box, in Debian 10 and later, "su" with no arguments no
longer changes the PATH variable.  Your root shell has the same PATH
as your previous shell, with directories like /usr/games but not
/usr/sbin or /sbin.

This caused ALL KINDS of problems.  People would do things like:

    $ su
    # apt update
    # apt install somepkg

And the postinstall script for somepkg would fail because it couldn't
find commands that are in /sbin or /usr/sbin, because those directories
which should have been in PATH, which *had* been in PATH for the last
20 years, were suddenly not there.

Some people proposed using "su -" as a workaround.  And this is fine for
many situations:

    $ su -
    # apt update
    # apt install somepkg

Here, it works fine.  The commands spawned by apt to install the package
don't care what directory they're executed from.

But in other cases, it's not fine:

    $ cd /somewhere/that/is/obnoxiously/long/program-1.2.3
    $ ./configure
    $ make
    $ su -
    # make install

Whoopsie!  That just blew up catastrophically, because su - changes
your working directory.  You're no longer in the
/somewhere/that/is/obnoxiously/long/program-1.2.3 directory, so you're
no longer in the right place for "make install" to work from.

> I only use "su" when doing something in MATE terminal on my local machine. I
> do not use any command line options to "su". I just wait for it to ask for
> my root password. I perform a few commands and then close that MATE
> terminal.
> 
> Does this "brokenness" of "su" have any potential effect on my usage?

Maybe.  If you haven't created an /etc/default/su file, then something
like this:

    $ su
    # adduser richard

may fail.  You could work around it in various ways (e.g. explicitly
typing out /usr/sbin/adduser richard).

My recommendation is to create a one-line configuration file:

hobbit:~$ cat /etc/default/su
ALWAYS_SET_PATH yes

That's all it takes.  With this file, with this setting, "su" with no
arguments will behave the way it's supposed to: it changes PATH without
changing your working directory.

Reply via email to