when we need use sudo python xxx.py or just python xxx.py or xxx.py -


I have written a website, what's confusing to me when I run a website, first I need to start an app , So there are 3 ways:

  1. sudo python xxx.py
  2. python xxx.py
  3. xxx.py

How did I use each of them, it has not been clear, currently the No. 3 method in my computer does not work well

pseudo app The executor will run with permissions. Keeping in mind that if you are referring to a website, surely it not is what you want to do (for a webpad, if it requires superuser permission, then it is broken It has yet to happen. In fact, you may have a python program in which to maintain and root the system. Walk as Is required. In this situation, you will use the sudo , but you do never want to do something that is publicly accessible and potentially exploited it In fact, for anything other than testing, you probably have to run the webapp with a very limited reach as a limited user (such as / dev / null from their shell) Has been set on, read anything or They do not need to be worn, etc. ...)

The other two are effectively the same (in what they are doing in thermal), but the last option (directly need to execute the script ):

  1. Executable bit set (on Unix-Y system) (like chmod + x whatever.py )
  2. One first line ( Like #! / Usr / bin / python ) Above is worth pointing out that you want to run things (again, it is only UNIX-

Python Calling ( dragon whatever JS ) to run the code and follow the steps above (resulting in you Can only call with whatever.py ) the same thing (assuming that in Python file numbers, Shebang performs " dragon " as a single python executable Is, anyway ...)


Comments