【问题标题】:User script location linux (debian etch) [closed]用户脚本位置 linux(debian etch)[关闭]
【发布时间】:2008-08-18 20:15:13
【问题描述】:

在linux文件系统中,用户脚本应该放在哪里?

我正在考虑专门由 cron 调用的 python 脚本。

【问题讨论】:

    标签: linux debian


    【解决方案1】:

    我坚信如果一个文件是由用户创建的,如果他没有创建它,它会进入他的用户目录(/home/username),那么它会变得更加复杂。我过去只是将它们放在 /usr/local/bin、/bin 或 /usr/local/scripts 中,我不确定 etch,但您需要检查以确保 /usr/local/ scripts 实际上在 Cron 的 $PATH 中。

    【讨论】:

      【解决方案2】:

      我得到的信息:

      /usr/local/sbin     custom script meant for root
      /usr/local/bin      custom script meant for all users including non-root
      

      来自 irc.debian.org #debian: 的聊天记录片段:

      (02:48:49) c33s: question: where is the _correct_ location, to put custom scripts
      for the root user (like a script on a webserver for createing everything needed 
      for a new webuser)? is it /bin, /usr/local/bin,...? /usr/local/scripts is 
      mentioned in (*link to this page*)
      (02:49:15) Hydroxide: c33s: typically /usr/local/sbin
      (02:49:27) Hydroxide: c33s: no idea what /usr/local/scripts would be
      (02:49:32) Hydroxide: it's nonstandard
      (02:49:53) Hydroxide: if it's a custom script meant for all users including 
      non-root, then /usr/local/bin
      (02:52:43) Hydroxide: c33s: Debian follows the Filesystem Hierarchy Standard, 
      with a very small number of exceptions, which is online in several formats at 
      http://www.pathname.com/fhs/ (also linked from http://www.debian.org/devel/ and 
      separately online at http://www.debian.org/doc/packaging-manuals/fhs/fhs-2.3.html)
      (02:53:03) Hydroxide: c33s: if you have the debian-policy package installed, it's 
      also in several formats at /usr/share/doc/debian-policy/fhs/ on your system
      (02:53:37) Hydroxide: c33s: most linux distributions follow that standard, though 
      usually less strictly and with more deviations than Debian.
      

      感谢 Hydroxide

      【讨论】:

        【解决方案3】:

        对于感兴趣的人来说,Filesystem Hierarchy Standard (FHS) 是一个标准文档,并且仍然非常适合阅读。我描述了几乎所有 Linux 发行版的基础,并得到官方认可,例如Debian 和 Linux 标准库 (LSB)。

        但是,您不会为该问题找到任何肯定的答案,因为......它没有定义;-)。我只能说:不要放入 /bin(也不要放入 /usr/bin)。 /usr/local/scripts 也很不寻常。 $HOME/bin 似乎是一个可以接受的地方,如果该脚本仅由该单个用户使用。

        【讨论】:

          【解决方案4】:

          如果您谈论的是由用户创建的脚本,这些脚本将从该用户的 crontab 运行,我通常将它们放在主目录的 bin 或 scripts 文件夹中,或者如果它们打算在用户之间共享, /usr/local/scripts 目录。

          【讨论】:

            【解决方案5】:

            Debian guide 在 Ubuntu 中非常有用:

            通常,程序会自行安装在 /usr/local 子目录中。但是,Debian 软件包不能使用该目录,因为它是为系统管理员(或用户)的私人用途保留的

            /usr/local/bin 根据指南似乎是可以接受的。

            我个人将我的脚本放在$HOME/.scripts

            我希望 LSB 能专门解决这个问题。

            【讨论】:

              【解决方案6】:

              /home/username/bin 怎么样?

              将 ~/bin 添加到 $PATH 并使用 chmod +x 文件名使脚本可执行。

              【讨论】:

                【解决方案7】:

                个人比较喜欢

                /home/username/.bin
                

                这样 bin 文件夹会被隐藏,但您仍然可以将其添加到 PATH 并执行所有带有 x 位的脚本。

                我喜欢我的主目录干净(乍一看),文件夹很少。

                【讨论】:

                  【解决方案8】:

                  您还可以将路径添加到您的 crontab 文件中,如 previous cron-related question 所示。

                  【讨论】:

                    猜你喜欢
                    • 1970-01-01
                    • 1970-01-01
                    • 1970-01-01
                    • 1970-01-01
                    • 1970-01-01
                    • 1970-01-01
                    • 2022-01-17
                    • 2015-07-09
                    • 1970-01-01
                    相关资源
                    最近更新 更多