简体   繁体   中英

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. But ubuntu already defines a command called 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. 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.

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.

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
  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
  4. store your software in some other location and prepend that to your personal or system wide $PATH variable
  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. For this the executable can be addressed with an absolute path, so it dies not have to be found inside the $PATH variable.

In my personal opinion options 2. and 5. and the best if it comes to "personal installations".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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