0

I want to check if root user exist in AWS account using Python or any cli command.

Thanks

Alfabravo
  • 7,493
  • 6
  • 46
  • 82
RAcharya
  • 45
  • 1
  • 5

2 Answers2

0

Try these commands

aws iam list-users

aws iam list-roles

Santosh
  • 41
  • 4
  • Hi Santosh... thank for your reply. By using these commands how will I know which user is Root user. – RAcharya Oct 26 '18 at 11:57
  • Hi RAcharya, using this command you can list all the users and user roles separately. Please go ahead and test this. If this doesn't answer your query then try this command to switch to root user sudo su - for more detail, you can read these two stack answers https://stackoverflow.com/questions/10882310/how-to-switch-to-root-user-without-entering-password-in-bash-script-on-redhat or https://stackoverflow.com/questions/5866767/shell-script-sudo-permissions-lost-over-time/6198418#6198418 – Santosh Oct 26 '18 at 16:15
  • Hi Santosh...I mean Root user of AWS not Linux. – RAcharya Oct 29 '18 at 12:37
0

Every AWS account has a root user. It cannot be deleted. There is no need to test for the presence of this.

If you're able to retrieve the access key for the root user programmatically (e.g. on the CLI or with boto), then you must be signing the request with the root key, which implies that the account has a root user access key.

Owen
  • 919
  • 5
  • 11
  • Hi Owen.. thank you for your reply. I know each account has root user but some customer delete the Root user for safety purpose. So I want to know whether a given AWS account has Root user or not. – RAcharya Oct 26 '18 at 11:56
  • You cannot delete the root user. You can, however, delete the access key for the root user. Is this what you want to check for? – Owen Oct 26 '18 at 16:52