简体   繁体   English

ubuntu / linux中具有相同名称的多个二进制文件

[英]multiple binaries with same name in ubuntu/linux

I have recently installed a webframework play ( http://www.playframework.com/ ) and want to have the play executable in the system path ie $PATH. 我最近安装了一个webframework播放器( http://www.playframework.com/ ),并希望该播放器在系统路径(即$ PATH)中具有可执行文件。 But ubuntu already defines a command called play. 但是ubuntu已经定义了一个名为play的命令。 How do I overwrite the system defined command with my framework binary path so that command play on commandline calls my framework rather than the old application. 如何用框架二进制路径覆盖系统定义的命令,以便在命令行上播放的命令调用框架而不是旧应用程序。

Installation: I downloaded zipped file of the framework and upzipped in one of my personal folder which contains the docs and the executable. 安装:我下载了该框架的压缩文件,然后将其压缩到我的个人文件夹之一中,其中包含文档和可执行文件。

If you are sure you'll never use the original play command, you could just remove the binary. 如果确定您永远不会使用原始的play命令,则可以删除二进制文件。 But in general, this isn't a good idea, since some system component you don't think of might need it, and the next update will probably restore it. 但是总的来说,这不是一个好主意,因为您可能不会想到的某些系统组件可能需要它,而下一次更新可能会还原它。

The best thing to do is to prepend the directory of your play command to the PATH, for example, using PATH=/opt/framework/bin:$PATH in your .profile (assuming your play command installs to /opt/framework/bin/play ), or the script that starts your web server, or wherever you need your play command. 最好的做法是将play命令的目录放在PATH的前面,例如,使用.profile中的PATH=/opt/framework/bin:$PATH (假设play命令安装到/opt/framework/bin/play ),启动Web服务器的脚本,或者需要play命令的任何位置。

Remember that does not make your play command global. 请记住,这不会使您的播放命令成为全局命令。 A common mistake is to add the path in their .profile file, then call the program from crontab - crontab scripts will not execute .profile or .bashrc. 一个常见的错误是将路径添加到其.profile文件中,然后从crontab调用该程序-crontab脚本将不会执行.profile或.bashrc。

Never alter the contents of installed packages. 切勿更改已安装软件包的内容。 Such changes can provoke hard to find problems in the system and anyway, they will most likely be overwritten again in subsequent updates. 这样的更改可能会导致很难在系统中发现问题,并且无论如何,它们很可能会在后续更新中再次被覆盖。 There are other alternatives: 还有其他选择:

  1. obviously you can chose another name for your executable 显然,您可以为可执行文件选择其他名称
  2. place the executable in another part of your $PATH if its a "personal installation", typically ~/bin is used for such approach 如果可执行文件是“个人安装”,通常将~/bin用于这种方法,则将其放在$PATH另一部分
  3. use the traditional /usr/local/bin location for locally added "wild" installations, this way there is some form of clean separation between clean packages and wild installed files inside the system 使用传统的/usr/local/bin位置进行本地添加的“狂野”安装,这样,干净包与系统内部狂野安装文件之间便存在某种形式的清晰分离
  4. store your software in some other location and prepend that to your personal or system wide $PATH variable 将软件存储在其他位置,并将其放在个人或系统范围的$PATH变量中
  5. store your executable under another name and create an alias (see man alias for an explanation) for it which allows to call it by some name that "hides" the original command this way. 以另一个名称存储您的可执行文件,并为其创建一个alias (请参阅man alias以获取解释),该man alias允许使用某种名称来调用它,从而以这种方式“隐藏”原始命令。 For this the executable can be addressed with an absolute path, so it dies not have to be found inside the $PATH variable. 为此,可执行文件可以使用绝对路径进行寻址,因此不必$PATH变量中找到它。

In my personal opinion options 2. and 5. and the best if it comes to "personal installations". 我个人认为,选项2.和5.最好是“个人安装”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM