skip to Main Content

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


  1. 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.

    Login or Signup to reply.
  2. 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:

    sudo yum install unzip
    curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
    unzip awscliv2.zip
    sudo ./aws/install --bin-dir /usr/local/sbin
    

    then confirm with:

    aws --version
    

    which should produce:

    aws-cli/2.0.44 Python/3.7.3 Linux/3.10.0-1127.el7.x86_64 exe/x86_64.centos.7
    
    Login or Signup to reply.
  3. What worked for me was

    sudo ./aws/install --bin-dir /usr/bin
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search