8

I have a .sh file that I need to create a symbolic link. I would like to be able to access the file using the Terminal.

The command I use is:

ln -s /path/roo.sh /usr/bin/roo

But when I type roo, it says command not found. If I type /path/roo.sh, it works. Am I missing a step somewhere?

1
  • Can you verify that /usr/bin/roo exists?
    – poplitea
    Oct 13 '11 at 17:07
9

What you did should work. Troubleshooting:

  1. Are you under root? Did ln command actually succeed? Verify with ls -l /usr/bin/roo which should list the newly created link. If the link is not there, add "sudo " before ln to execute it as root (sudo will prompt for root's password):

    sudo ln -s /path/roo.sh /usr/bin/roo

  2. Sometimes bash remembers where a certain executable is, and will not search in other locations. Enter hash -r to make it forget, and then try roo again.

  3. "/usr/bin" should definitely be in your PATH, but it won't hurt to verify: echo $PATH should include "/usr/bin"

1
  • 2
    What I did wrong was that I use the current directory as the path ./folder1/folder2/roo.sh and when i type ls -l /usr/bin/roo, it shows that error. Thanks for that good tip haimg :)
    – okysabeni
    Oct 13 '11 at 17:41
2

Use the command alias roo="/usr/bin/roo"

1

If you are trying to use roo as a command ou might want to look at the alias command.

In this case you would do :

alias roo="path to roo"

to call it you will just need to do roo

For example

alias test="ruby /Users/user/Desktop/test.rb"
0

I think the symlink is did not created, as you can do this only with sudo from the terminal. Please check /usr/bin/roo is exists.

If exists, please try echo ${PATH} command, it shows you the folders where the shell search you command. If it does not contains /usr/bin, then try to fix it with adding export PATH="${PATH}:/usr/bin" into your ~/.profile

0

My echo $PATH showed me that /usr/local/bin/ was also in my path, so I just used /usr/local/bin/roo as my link target.

ln -s /path/roo.sh /usr/local/bin/roo
-1

If exists, please try echo ${PATH} command, it shows you the folders where the shell search you command. If it does not contains /usr/bin, then try to fix it with adding export PATH="${PATH}:/usr/bin" into your ~/.profile

2
  • -1. The accepted answer which was posted 9 years ago already contains this tip, and more.
    – gronostaj
    Mar 4 at 8:34
  • Welcome to Super User! Before answering an old question having an accepted answer (look for green ✓) as well as other answers ensure your answer adds something new or is otherwise helpful in relation to them. Here is a guide on How to Answer. There is also tour for the site tour, and help center for the help center. Mar 4 at 9:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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