Python scripts in /usr/bin

后端 未结 5 502
野的像风
野的像风 2021-02-04 04:07

I\'m writing a pretty basic application in python (it\'s only one file at the moment). My question is how do I get it so the python script is able to be run in /usr/bin without

5条回答
  •  心在旅途
    2021-02-04 04:35

    The first line of the file should be

    #!/usr/bin/env python
    

    You should remove the .py extension, and make the file executable, using

    chmod ugo+x htswap
    

    EDIT: Thomas points out correctly that such scripts should be placed in /usr/local/bin rather than in /usr/bin. Please upvote his answer (at the expense of mine, perhaps. Seven upvotes (as we speak) for this kind of stuff is ridiculous)

提交回复
热议问题