When I install the AWS CLI for the root user on CENTOS 7, it installs it to /usr/local/bin as with other users. Problem is though, /usr/local/bin isn’t in $PATH for the root user. At first I thought this was a bug in CENTOS, one that has been around for a very long time, but it’s also possible its for reasons of security, I don’t know.
What would be best practice then to install the AWS CLI for the root user?
3
Answers
This appears to a bug logged in CentOS since 2012 in CentOS 6 but as of yet has not been fixed.
Regarding running AWS CLI as root, you can still run it by running
/usr/local/bin/aws
although I get that this is not ideal. Additionally you should try to avoid running AWS CLI as root if possible, instead run it as a named user.According to the documentation you can use either
--bin-dir
or-b
to specify a different bin directory so you could check a path that both root and named users have in their$PATH
variable.To complement Chris’es answer, you can install the AWS CLI v2 in a folder visible to root, such as
/usr/local/sbin
as follows:then confirm with:
which should produce:
What worked for me was