3

I recently downloaded Master PDF Editor. It's a proprietary software for Linux and the archive contained bascically only a *.desktop file and the actual binary.

Looking at the *.desktop file, the binary is supposed to be placed in /opt/master-pdf-editor-3. I'm aware I could change that but I followed the suggestion. Naturally, I still cannot call the binary on its own since it's not in my PATH.

I can think of several solutions. I could add the binary path to PATH, I could create a (soft or hard) link inside a folder that already is in PATH, such as /usr/bin, or I could write a shell script in the same place that will call the binary.

I was wondering, is there some sort of commonly accepted best practice or rule when to use one over the other?

If it matters, I'm on Arch Linux.

P.S. This question is very similar but the focus there is on the directory structure and not on the different possibilities how to call the binary itself.

1 Answer 1

4

Creating a hardlink should probably be avoided, there's no need for one and a symlink is simpler and safer. Your other solutions are also fine though. You can create as script that calls the binary or you can add the directory to your PATH. The latter might be preferable if you expect to add other binaries in /opt as well.

This is essentially a matter of preference. In such cases, usually the simplest solution is the best. So, just create a soft link and you're all set:

sudo ln -s /opt/master-pdf-editor-3 /usr/bin

Alternatively, of course, you could just call the binary with its full path:

/opt/master-pdf-editor-3

Finally, if it's only for your user, you can create an alias by adding this line to your shell's initialization file (e.g. ~/.bashrc):

alias master-pdf-editor-3='/opt/master-pdf-editor-3'

Anyway, no, there isn't any single Best Way© to do this. It depends on how you want your system to be set up and your own preferences as the system's administrator.

2
  • Thanks for your answer. Could you maybe elaborate on just one thing. When would you prefer a soft link over of a shell script, and vice versa? BTW, the binary is in the package subfolder of /opt, so you would have to add each package separately to the path which seems messy. Commented May 4, 2016 at 9:02
  • @vic personally, I would always go for the softlink. It's easier and doesn't require the creation of a script. AFAIK, there's no hard technical reason to chose one over the other. I would only use a wrapper script if I always wanted to call a program with certain options/parameters set. As I said though, do what you prefer. I find softlinks to be cleaner, simpler and more elegant than creating wrapper scripts. And yes, if they're in subfolders of /opt (which makes sense) it's more of a pain to add them to PATH. Commented May 4, 2016 at 9:07

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.