title: Python exception and permission denied exception while trying to run "az login" on ubuntu
body: <p>I am new in Linux/k8s and trying to run az CLI on Ubuntu VM. </p>
  
  <p>After following all instructions to install CLI and kubectl as following: </p>
  
  <pre><code>- Install az CLI:
      ○ AZ_REPO=$(lsb_release -cs) echo "deb [arch=amd64] 
         https://packages.microsoft.com/repos/azure-cli/ $AZ_REPO main" | sudo 
         tee /etc/apt/sources.list.d/azure-cli.list
      ○ curl -L https://packages.microsoft.com/keys/microsoft.asc | sudo apt key add -
      ○ sudo apt-get install apt-transport-https
        sudo apt-get update &amp;&amp; sudo apt-get install azure-cli
  - Install kubectl:
      ○ sudo apt-get update &amp;&amp; sudo apt-get install -y apt-transport-https
        curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo 
        apt-key add -
        sudo touch /etc/apt/sources.list.d/kubernetes.list 
        echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee 
         -a /etc/apt/sources.list.d/kubernetes.list
        sudo apt-get update
        sudo apt-get install -y kubectl
  </code></pre>
  
  <p>I got the following error message if I try to run az login as root: </p>
  
  <p>"Port '8400' is taken. Trying with the next one
  Note, we have launched a browser for you to login. For old experience with device code, use "az login --use-device-code"
  Running Firefox as root in a regular user's session is not supported.  "</p>
  
  <p>Also, if I try to run it using my non-root account, it gives me the following trace erros:</p>
  
  <pre><code> Traceback (most recent call last):
    File "/opt/az/lib/python3.6/configparser.py", line 1138, in _unify_values
    sectiondict = self._sections[section]
  KeyError: 'cloud'
  
  During handling of the above exception, another exception occurred:
  
  Traceback (most recent call last):
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/cloud.py", line 234, 
  in get_active_cloud_name
  return cli_ctx.config.config_parser.get('cloud', 'name')
  File "/opt/az/lib/python3.6/configparser.py", line 781, in get
  d = self._unify_values(section, vars)
  File "/opt/az/lib/python3.6/configparser.py", line 1141, in _unify_values
    raise NoSectionError(section)
  configparser.NoSectionError: No section: 'cloud'
  
  During handling of the above exception, another exception occurred:
  
  Traceback (most recent call last):
  File "/opt/az/lib/python3.6/runpy.py", line 193, in _run_module_as_main
  "__main__", mod_spec)
  File "/opt/az/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/__main__.py", line 32, in 
    &lt;module&gt;
    az_cli = get_default_cli()
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/__init__.py", line 
    493, in get_default_cli
    help_cls=AzCliHelp)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/__init__.py", line 
    53, in __init__
    self.cloud = get_active_cloud(self)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/cloud.py", line 299, 
    in get_active_cloud
    return get_cloud(cli_ctx, get_active_cloud_name(cli_ctx))
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/cloud.py", line 236, 
    in get_active_cloud_name
    _set_active_cloud(cli_ctx, AZURE_PUBLIC_CLOUD.name)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/cloud.py", line 229, 
    in _set_active_cloud
    cli_ctx.config.set_value('cloud', 'name', cloud_name)
  File "/opt/az/lib/python3.6/site-packages/knack/config.py", line 91, in 
    set_value
    self.set(config)
  File "/opt/az/lib/python3.6/site-packages/knack/config.py", line 78, in set
    with open(self.config_path, 'w') as configfile:
  
  PermissionError: [Errno 13] Permission denied: '/home/&lt;useraccount&gt;/.azure/config'
  </code></pre>
  
  <p>Please help.</p>
  
  <p>Thanks</p>