0

wierd issue where if you use sudo command for certain commands it is not found. But runnning it as root user WITHOUT sudo does work

root@ip-172-31-43-153:/home/ubuntu# sudo xfs_growfs -d /
sudo: xfs_growfs: command not found
root@ip-172-31-43-153:/home/ubuntu# which xfs_growfs
/usr/sbin/xfs_growfs
root@ip-172-31-43-153:/home/ubuntu# sudo which xfs_growfs
root@ip-172-31-43-153:/home/ubuntu# 

path is identical

root@ip-172-31-43-153:/home/ubuntu# sudo echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
root@ip-172-31-43-153:/home/ubuntu# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

Honestly pretty mind boggling. I can't restart the machine atm so I have no idea if a restart would fix this.

edit:

I recon the problem is the fact that secure_path is repeated here:

root@ip-172-31-43-153:/usr/bin# sudo -l
Matching Defaults entries for root on ip-172-31-43-153:
    env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin, use_pty, secure_path=/usr/bin

Which mean that the path is overrided to just /usr/sbin?

It looks like sudo which works for anything in /usr/sbin

root@ip-172-31-43-153:/usr/bin# sudo which gio
/usr/bin/gio
root@ip-172-31-43-153:/usr/bin# which gio
/usr/bin/gio

But I have no Idea how it got like this or how to fix it

/etc/sudoers only has this:

root@ip-172-31-43-153:/sbin# cat /etc/sudoers |grep secure
Defaults        secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"
user2958456
  • 101
  • 1

1 Answers1

0

Figured it out, my colleague had defined it again in a /etc/sudoers.d file

user2958456
  • 101
  • 1