12

I have the following go program that runs with:

 ./hack/go/bin/wego

How can I create a symlink to run this program with the command weather?

JZ.
  • 239
  • 1
  • 2
  • 4

1 Answers1

24
sudo ln -s /whole/path/to/script.extension /bin/weather

This will create a symlink into the /bin/ folder, which is included in everyone's PATH. If it requires sudo to run, I recommend placing it in /sbin instead of /bin.

Tim
  • 31,115
  • 24
  • 113
  • 172
Andrew Meyer
  • 1,277
  • 8
  • 7
  • 3
    It's more of a cosmetic difference, but traditionally scripts that require elevated or superuser access go in sbin so they can be differentiated from scripts that do not require superuser access (those in bin). – Andrew Meyer May 15 '15 at 16:19
  • I really have the same problem as before, maybe I need to be more clear. Is there a way I can type "weather" and omit "./" in "./weather" to run the program? This is the type of functionality I am looking for – JZ. May 15 '15 at 20:29
  • If you symlink it Into /bin and log out then back in it should work without the ./. Once it is included in a directory in your PATH you won't need to specify the location – Andrew Meyer May 16 '15 at 01:59
  • As an added note, you should probably use /usr/local/bin since it is a more canonical directory for user scripts – Andrew Meyer Oct 20 '17 at 16:38