Create a symbolic link on Linux for a domain name - linux

I need to create a symbolic link mysite.com to point to a directory /home/drupal/sites/mysite
Where do I cd into to create this? Do I need to run this command in /home/drupal/sites/mysite or can I be anywhere on the server to do this?
Can this be done in the vhosts file instead?

Try this in the directory where you want the link created:
ln -s /home/drupal/sites/mysite mysite.com
See: http://frankmash.blogspot.com/2007/11/ln-s-examples.html

Related

creating symbolic link of file in a different directory in linux

trying to create a symbolic link to an xml file in a different directory. I am using the command in the current file directory.
ln -s file_name.xml /home/path_to_desired_symbolic_link_location/file_name.xml
The symbolic link is created but it is empty.
It's safe to use the absolute address if you want to link to the file in another directory. Like this:
ln -s /path a/file_name.xml /path b/file_name.xml

How to make saved files end up nowhere?

I want to disallow a program from keeping local files, and I thought I would accomplish that by pointing a shortcut with its local folder's name to /dev/null, but I cannot seem to get it working.
If I try ln .app /dev/null, I get a message saying
ln: ‘.app’: hard link not allowed for directory
And if I add symbolic, by doing ln .app /dev/null -s, then I get
ln: failed to create symbolic link ‘/dev/null’: File exists
So I don't really know how to accomplish this idea. What is the correct solution?
You should be using:
ln -s /dev/null .app
to create a symlink called .app pointing to /dev/null

Linux Centos webserver Softlink (Symbolic Link) Issue

To create a symbolic link in Linux webserver , at the shell prompt, i am using the
following command:
# ln -s {target-filename} {symbolic-filename}
For example to create softlink for
/viewer/PENG07/index.php
as
/home/name1/public_html/viewer/index.php
i enter the following command:
# ln -s /viewer/PENG07/index.php /home/name1/public_html/viewer/
Now the issue is it only loads index.php and misses the supporting sub folders and all next level folders and directories
what i want was to softlink (symbolic link)
/viewer
instead of
/viewer/index.php
to
/home/name1/public_html/viewer/
it should be recursive all folders and files ..
kindly help me please ...
If index.php resides in /viewer/PENG07, you presumably mean to link /viewer/PENG07 rather than just /viewer.
ln -s /viewer/PENG07 /home/name1/public_html/viewer
- Note: There must not be a / at the end.

Create symbolic link of a folder

Into the folder /usr/local/var I would like to create a symbolic link run that point to /var/run folder. But I'm quite bit confused how to correctly create the link. Should I create initially the run folder?
You can create it like this without the need of creating something before:
ln -s /usr/local/var /var/run
If you are windows users and want to create a symbolic link of a folder is here how:
NOTE: Just make sure you run the command prompt as administrator.
WINDOWS
mklink /d "D:\site\abc\js" "F:\xyz\js"
MAC
ln -s /usr/local/var /var/run

Why is my symbolic link creating a file and not a folder?

I want a create a symbolic link to a folder. The follow command will create a file with the link name but I'm trying to link to the source folder. What am I doing wrong?
ln -s /Users/me/somefolder somefolder
This creates a file "somefolder" in my current directory. How do I create a symbolic link to the folder and it's contents?
Thanks!
You need to use absolute path names to create the links.
For example, I'm now at
$ pwd
/home/alex/my_folder
And I'm creating a symbolic link to the folder "directoryA" in a sub-directory under my pwd (present working directory):
$ ln -s $PWD/directoryA $PWD/temp/link_to_directoryA
In this case variable $PWD holds absolute path to my working directory.
You can surely use your absolute path without any variables like this:
$ ln -s /home/alex/my_folder/directoryA /home/alex/my_folder/temp/link_to_directoryA
You need to be inside the same directory where you create the symbolic link
For instance:
cd /Users/me
ln -s somefolder somefolderNewName
Not creating a directory is an expected behavior.
When you do
ls -ali
It should show something beginning with;
lrwxrwxrwx
In which "l" represents symlink and allows you to traverse using cd.
NOTICE: ln command will not complain when you provide an invalid source path. And this will result with an error message when you try cd in to that.
Late for the party..
This is what worked for me..
if you want to create a symbolic link from sourceFolder to destinationFolder
you should be inside the parent of the destinationFolder "parentOfDestinationFolder" while doing so.
I think you have what you want, you just don't know it. A link has an entry in the directory, just like data files or directories do. You can see this most clearly if you run ls -l in the directory where you're creating the link.
You can use your link as if it were a directory, e.g.:
$ cd somefolder
You might also like to know that if you change directory this way, the parent of somefolder will be the directory that contains the link. If you don't want that, use:
$ cd -P somefolder

Resources