656

I am installing p4v in /opt, but /usr/bin is on my path. Is it possible to create a soft or symbolic link for p4v from /opt to /usr/bin, so I can just type "p4v" since /usr/bin is in my path?

César
  • 807
coffee
  • 6,783

8 Answers8

960

See man ln.

To create a symlink at /usr/bin/bar which references the original file /opt/foo, use:

ln -s /opt/foo /usr/bin/bar

You would need to apply the above command as root (i.e. with sudo).

CentaurusA
  • 2,692
62

The error is that you are writing the command wrong. The correct way is

ln -s /<full>/<path>/<to>/<file> /usr/local/bin

http://ubuntuforums.org/showthread.php?t=2001697

Eric Carvalho
  • 55,453
24

If the 'p4v' executable is at /opt/bin/p4v, you can simply run:

sudo ln -s /opt/bin/p4v /usr/bin/p4v
sudo chmod ugo+x /usr/bin/p4v

It would be better to add /opt/bin (or wherever the executable is) to your path:

echo "export PATH=\$PATH:/opt/bin" >> ~/.profile
reset
dv3500ea
  • 37,734
7

This template was more helpful for me than the above answers. Probably not more correct, just less obfuscated:

ln -s <path/to/real/file-or-folder> <symlink path>

Just replace the parts in <>'s

earthmeLon
  • 11,658
LucasY
  • 71
6

Check the software location by this.

which application-name #replace for the application you are looking for

for example

which skype

output will be this.

/usr/bin/skype 

To create the soft link. for example you want to create the soft link for skype on your desktop

ln -s /usr/bin/skype ~/Desktop/

For more information about ln.

man ln

or

ln --help
Alexandre
  • 1,968
4
ln -s -n ./TargetDirectory ./Nickname

Note, this works if you both nodes are below you in the same tree. You can use relative notation

  • -s command makes it a symbolic link
  • -n makes it possible de create a folder-type symlink
muru
  • 207,228
0

I have found that it is easier to go to where you want the link to be and then create the link using sudo ln -s /path/to/source/file, than doing ln -s target source.

So in your case I would do cd /usr/bin then sudo ln -s /opt/bin/pv4. The other way has not been working in my case.

briankip
  • 181
0

If it is saying target is not a folder, it means there are spaces in your folder names eg: New Folder has a space

You need to edit the path and add a backslash \ after every space in the paths

eg:

ln -s /opt/bin /usr/var/New\ Folder
derHugo
  • 3,376
  • 5
  • 34
  • 52
Sam
  • 1