Solved: az cli commands not working without sudo in Linux/ubuntu

Photo by Sai Kiran Anagani on Unsplash

Are you facing PermissionError: [Errno 13] Permission denied: ‘/.azure’ while executing az CLI commands?

This issue could be caused due to incorrect user ownership for the files/directories under /.azure directory.

To fix the issue follow below steps:

1. Check for the ownership of the file/ directory for which you are getting the permission denied error

ls -l /home/username/.azure

You will see the ownership for the directory and files under it. If the owner is not the current user then you have found the culprit.

2. Change the Ownership of the directory/file for which the current user is not the owner using the below commands to fix the issue.

sudo chown -R user /home/username/.azure

Now user will be the owner of directory /.azure and files under it

az

Now all your az CLI commands will run without sudo.

Great!