I have two computers. One, Computer A, runs Ubuntu 18.04. The other, Computer B, runs Ubuntu 20.04.
On Computer A, I have a ~/.bash_aliases
file
-rw-r--r-- userA userA /home/userA/.bash_aliases
with the following aliases:
alias sudo='sudo '
alias runtest='$HOME/bin/test_script.sh'
The ~/bin/test_script.sh
file
-rwxr--r-- userA userA /home/userA/bin/test_script.sh
has the contents
#!/bin/bash
echo ~
When I run the alias as both userA
and root
, I get
$ runtest
/home/userA
$ sudo runtest
/home/userA
(which is what I want, for what it's worth).
On computer B, I'm trying to make an identical setup. The ~/.bash_aliases
file
-rw-r--r-- userB groupB /home/userB/.bash_aliases
has the same aliases
alias sudo='sudo '
alias runtest='$HOME/bin/test_script.sh'
The script ~/bin/test_script.sh
-rwxr--r-- userB groupB /home/userB/bin/test_script.sh
has the exact same contents as on Computer A. On Computer B, however, running the alias as both userA
and root
gives different results:
$ runtest
/home/userB
$ sudo runtest
/root
Notice that when executing $ sudo runtest
, ~
is interpreted as the $HOME
folder of the user (userA
) on Computer A, but the $HOME
folder of root
on Computer B. I would like it to return /home/userB
, just as it does on Computer A.
Things I've checked:
I have sourced
.bash_aliases
on both machines since last editing them./etc/sudoers
is identical on both computers, and neither hasenv_keep
set anywhere within/etc/sudoers.d/
./etc/pam.conf
and/etc/pam.d/sudo
are identical on both computers.The
$PATH
values are identical for both users and for both roots, respectively.
For the users:
$ echo $PATH
/home/user(A|B)/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
For root
on both Computer A and Computer B:
$ sudo su
# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
There must be something different between the two computers, but I've checked everything I know to check. What else could explain the different behavior? Did something change between 18.04 and 20.04 that would affect this?
0 Answers