In AWS EC2, I am using Centos 7, I observe strange behaviour where a binary for Hashicorp Vault CLI (/usr/local/bin/vault) is available during boot to commands I run in user data. It is also available for users normally. However, if I run sudo -i it is not available. If I run sudo su - root, then it is available!

Why would a command be available in user data as root, but not if I try to login as root using sudo -i?

  • What do you mean by "available"? What happens when root runs /usr/local/bin/vault? – berndbausch Apr 9 at 7:04
  • 2
    Because you're ending up with a different $PATH between sudo -i and sudo su - root. sudo -i is instructing sudo to behave as if it's a login, sudo su - root is instructing su to behave that way. Read the man page for each command to understand the behavior. – yoonix Apr 9 at 7:31

Browse other questions tagged or ask your own question.