Score:0

Getting command not found using sudo, but not for running command as root without sudo

by flag

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"
Score:0
by flag

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

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.