How do I create a symbolic link in Mac OSX?
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?
What you did should work. Troubleshooting:
-
Are you under root? Did
ln
command actually succeed? Verify withls -l /usr/bin/roo
which should list the newly created link. If the link is not there, add "sudo " beforeln
to execute it as root (sudo will prompt for root's password):sudo ln -s /path/roo.sh /usr/bin/roo
-
Sometimes bash remembers where a certain executable is, and will not search in other locations. Enter
hash -r
to make it forget, and then tryroo
again. -
"/usr/bin" should definitely be in your PATH, but it won't hurt to verify:
echo $PATH
should include "/usr/bin"
Use the command alias roo="/usr/bin/roo"
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"