当前位置: 首页>>技术问答>>正文


安装用户应用程序时,“best practices”建议它们位于何处?

, ,

问题描述

偶尔我会手动安装应用程序,而不是使用apt或其他软件包管理器。

“best practices”为安装用户应用程序提供了哪些位置(/usr//usr/local//opt//home/等)?

最佳解决方法

这取决于,真的。如果应用程序具有makefile,(对于python应用程序)使用distutils(具有setup.py文件)或类似的构建/安装系统,请将其放入/usr/local/(默认行为)。

如果您只需提取tarball并直接运行(例如Thunderbird,Firefox),然后将其放入/opt/

为什么?据我所知,/usr/local/有一个类似于/usr/的层次结构。因此,希望将”installed”放入/usr/的程序应该在/usr/local/中正常工作。一个只需要一个目录并且将获得与该目录相关的所有文件/库的程序可以在/opt/中获得一个目录。

次佳解决方法

最好记住/usr不代表用户,而是unix系统资源。

因此,我倾向于认为任何发行版都有权对/usr,的内容进行踩踏,并且我对该系统的具体增加进入了/usr/local,我在升级之前保留了该版本。

同时,应用程序和其他东西在/opt

有些人很喜欢把东西放在/home中,尽管我很少遵循这个惯例。

尽管如此,我让分发包管理者首先做事,然后在手动滚动时执行上述操作。

第三种解决方法

在/home /user /opt /中安装像firefox devel这样的不稳定程序可以让它更容易删除,而且不会让其他用户感到困惑,因为它们应该使用哪个版本…因此,如果它不是全局使用的程序,请安装它位于您的主目录中的子文件夹中。

不要在/usr /中安装程序,它很可能会导致混乱,安装在/usr /中的东西只能用于分发软件包。 /usr /local /用于本地编译的软件包。该结构的工作方式完全相同! /usr /local /中的文件将优先于/usr /

/opt /应该用于安装pre-compiled(二进制)包(Thunderbird,Eclipse,Netbeans,IBM NetSphere等)等。但是,如果他们只为一个用户,他们应该放在你的主目录。

如果您希望能够运行安装在”weird”位置(如/home /user /opt /firefox /)中的程序而无需输入完整路径,则需要将其添加到$ PATH变量中,您可以添加一个在你的/home/user/.profile中像这样行

export PATH=/home/user/opt/firefox:$PATH

文件夹名称应该是您需要运行的可执行文件所在的位置。

第四种方法

Linux文件系统层次结构标准指示/usr/local

来自http://tldp.org/LDP/Linux-Filesystem-Hierarchy/html/usr.html

The original idea behind ‘/usr/local’ was to have a separate (‘local’) ‘/usr’ directory on every machine besides ‘/usr’, which might be just mounted read-only from somewhere else. It copies the structure of ‘/usr’. These days, ‘/usr/local’ is widely regarded as a good place in which to keep self-compiled or third-party programs. The /usr/local hierarchy is for use by the system administrator when installing software locally. It needs to be safe from being overwritten when the system software is updated. It may be used for programs and data that are shareable amongst a group of hosts, but not found in /usr. Locally installed software must be placed within /usr/local rather than /usr unless it is being installed to replace or upgrade software in /usr.

第五种方法

我通常在我的家中安装了一个名为”Programs”的文件夹,我安装了这些程序,现在它们都很奇怪(或不是)它们都是java的东西。

这对我来说有一个很大的优势,当我重新安装或更换电脑时,他们会与我家的其他人一起移动。它有一个明显的缺点,那些应用程序只对我的用户可用。

参考资料

本文由Ubuntu问答整理, 博文地址: https://ubuntuqa.com/article/237.html,未经允许,请勿转载。