This question already has an answer here:

I realise this is basic but I have read two pages of google answers and am still unclear 'How to put executable in /usr/local/bin?'

I have downloaded a package and made the executable called profit. What is the step by step command line to make profit executable from the terminal without having to add the path/to/profit every time?

marked as duplicate by muru, heemayl command-line Jan 31 '17 at 3:13

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • By "package" do you mean just some source files, or do you mean a autoconf / configure package of some sort? The latter often have an install target that does all the right things for installing executables and support files. – user459652 Jan 30 '17 at 23:57

Just copy it to /usr/local/bin.

sudo cp /path/to/profit /usr/local/bin
  • Also, make sure the file is marked as executable, otherwise you'll get a Permission denied error. – luk3yx Jan 31 '17 at 1:33
  • I keep getting a "cp: /usr/bin/maude: Operation not permitted" – Charlie Parker Sep 13 '18 at 23:05
  • @CharlieParker: sudo? – Gunnar Hjalmarsson Sep 13 '18 at 23:11
  • @GunnarHjalmarsson somehow it doesn't let me in /bin or /usr/bin even with sudo...It worked once I went to /usr/local/bin.... – Charlie Parker Sep 14 '18 at 15:11

There are various things to consider; just for completeness:

First of all, you should make sure that this executable has in fact the required permissions.

sudo chmod a+rx /path/to/profit

(for example when extracting archives that were thrown together using the zip tool, permissions can get lost)

Then you can either copy the file as Gunnar suggested; or you can create a symbolic link:

sudo ln -s /path/to/profit /usr/local/bin

Depending on your context, using a link might be more convenient in the future; on the other hand it carries some security risks (for example when /path/to/profit can be written by non-root users)

  • The symbolic link definitely eases things if you expect to be doing frequent upgrades (eliminating the need to copy the binary there each time), and can save the need to also copy any other binaries it calls from its "home" directory, so it's worth it to set permissions on the real path to not be writable other than by root. – Monty Harder Jan 30 '17 at 20:34

step 1: chmod +x /path/to/profit

step 2: sudo cp /path/to/profit /usr/local/bin/

step 3: profit

Not the answer you're looking for? Browse other questions tagged or ask your own question.