When you run sudo command it switches user to “supper user” and environment variables also change. This can be annoying.
For example, on amazon free-tier micro instance you ssh to it as ec2-user but often (almost always I would say) need to run commands as sudo. To solve the issue I always do:
as my first command when I ssh to the instance. This creates shell with root privileges and I don’t need to type sudo all the time and deal with environment variables issue.