sudo python vs python

0

I have an instance in EC2 running Linux. I am trying to use the AWS Python DAX Client. The Dax Client is operating at the TCP level. I am running one of their example sample code https://github.com/awsdocs/amazon-dynamodb-developer-guide/blob/master/doc_source/DAX.client.run-application-python.03-getitem-test.md

When i run the code with "python 03-getitem-test.py" it works, but when i run with "sudo python 03-getitem-test.py" it fails with a client error.

I am trying to understand the diff between running python vs sudo python. How do i make sure that running "python" and "sudo python" does the same thing?

atdevyesh

Posted 2018-07-27T07:38:13.120

Reputation: 1

What client error? You'd accomplish the same by running python as root because sudo executes it with root permissions. – Seth – 2018-07-27T08:12:37.430

@Seth i think what i am trying to understand is in ec2, the default user name is ec2-user. So when i run the python file as ec2-user , its running fine. But when i run it as 'sudo python', i am seeing issues. I am trying to understand whats the difference between running as root vs ec2-user. – atdevyesh – 2018-07-27T12:56:03.267

Actually name the error instead of playing guess the error. – Seth – 2018-07-29T18:04:49.990

Answers

0

The only differences that can be of significance and come to my mind when running a python script as a normal user against running it as root, is that:

  1. The default home and library directories are different, if the script is in any way using variables for home directories, or even libraries, then it might produce an error.
  2. They have different permissions and access. However, this should not produce error in this case, as root is the one that has all permissions granted.
  3. Root might use a different Python interpreter than the other users.
  4. In this case, amazondax might not permit being run as root or may have different restrictions for being used in that case.

The information you have given us isn't enough to pinpoint what the causes might be. If you supply us with the given error, we'd be able to tell you more about why does it happen and what else could possibly happen.

Fanatique

Posted 2018-07-27T07:38:13.120

Reputation: 3 475