Ubuntu: Help with creating a symbolic link



Question:

I'm confused with how symbolic links work. I hope someone can guide me in the right direction.

I want to put a demo online from our software, which normally only runs locally on a Mac Mini. So I put all the files in the var/www from my Ubuntu 12.04 server installation.

There are a lot of hardcoded links in the software which point to /Applications/XAMPP/xamppfiles/htdocs/narrowcasting

Of course, I could change all these code on my html/php files in /var/www, but that would be quite annoying. I hope I can fix this by creating a symbolic link. For example, I have a directory called thumb in /var/www/thumb. The PHP code is trying to put an image in /Applications/XAMPP/xamppfiles/htdocs/narrowcasting/thumb.

Can anyone give me a tip how to achieve this with a symbolic link?


Solution:1

use the ln command to do symbolic links.

 ln -s <real folder> <link folder>  

in this example, you will create link folder that will actually contain what real folder have, and if you save something to link folder it will actually save it into real folder

You can verify the link with the command ls -l which will show an arrow to where the link points.

Note that the folder containing the link must exist, so you would have to create it first.

So in your situation, the commands that you are looking for are

sudo mkdir /Applications/XAMPP/xamppfiles/htdocs/narrowcasting    sudo ln -s /var/www/thumb /Applications/XAMPP/xamppfiles/htdocs/narrowcasting/thumb  

Again, you can verify that the link was actually made with

ls -l /Applications/XAMPP/xamppfiles/htdocs/narrowcasting/thumb  


Solution:2

ln -s [source_folder] [link_location]  

This will create a link named like source folder, but you can rename the link. This way you can quickly switch content of folder. Useful for things like swapping git repos without reconfiguring IDE and build scripts.


Solution:3

if you want to create a SOFT or symbolic link from

/Applications/XAMPP/xamppfiles/htdocs/narrowcasting/link-file  

to

/var/www/destination-file  

yo do:

$ ln -s /var/www/destination-file /Applications/XAMPP/xamppfiles/htdocs/narrowcasting/link-file  

Try to use absolute paths because if not, the paths should be writen not from your current directory but from the directory the link-file will be


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »