Linking Files With Symbolic Links Linux Unix Shell Command Tutorial Guides

Mobile
feeds
Welcome Login | Register

Linking Files With Symbolic Links Linux Unix Shell Command Tutorial Guides
Reply Your Comments:
Click this button if you are interested in replying to this topic and leave your comments
Sent To Friend
CLick this button if you want to send this page to a friend.
Subsribe To Rss Feeds
Subscribe to RSS
CLick this button if you want to subscribe to this RSS Feed. You can use your browsers feeds burners if you have mozilla or internet explorer 7 or higher and keep up with updates.
  Forums Index
      » Linux Forums
        » » Linking Files With Symbolic Links Linux Unix Shell Command Tutorial Guides
Linking Files With Symbolic Links Linux Unix Shell Command Tutorial Guides
Post Description: linking files with symbolic links linux unix shell command tutorial guides Linux
Post Tags:
This Post Has Been Viewed 9574 Times Since Fri Nov 17, 2006 3:53 pm Author unix with 3 replies
Linking Files With Symbolic Links Linux Unix Shell Command Tutorial Guides
Advertise On This Page




FORMAT:
ln -s path/to/directory link_name

The links you created in the prvious post, listed the actual inodes for a file in two direcoties. Links created in this way are called hard links because the inode is hard-coded into the various direcotries that list the file. As will be examined later, hard links do not work for some files, and only the supersuer can create har dlinks for directories.

A method for linking an existing file to another directory does not list the linked files' inode in the decond directory.

ok, to lets say i want to link directory: /var/www/html/web1 to /var/www/html/web2 so when you visit web2, the actual content of web1 will be shown, this is how you do it:

1. make sure you are in the html directory, if you are not sure send this command:
     Code:
cd /var/www/html


2. Once you are in the html directory, send this command to double check:
     Code:
pwd
You should see somthing like this:
     Code:
[root@host html]# pwd
/var/www/html



3. Now that you are defenetly certain that you are in the correct directory, send this command to do display the current files in the html directory to make sure that web1 directory exists:
     Code:
ls
Then you should see something like this:
     Code:
[root@localhost host]# ls
web1


4. Now send the command to link web1 and create the web link with this command:
     Code:
ln -s /var/www/html/web1 /var/www/html/web2


5. After you have executed the ln command, confirm that the web2 symbolic link has been created with this command:
     Code:
ls -l
You shold see semething like this:


. Now confirm that you have created the link by listing the files, send this command:
     Code:
ls -l

You should see something like this:
     Code:
[root@localhost html]# ls -la
total 20
drwxr-xr-x 3 root root 4096 Nov 17 15:48 .
drwxr-xr-x 72 root root 4096 Oct 26 17:38 ..
drwxr-xr-x 2 root root 4096 Nov 17 15:41 web1
lrwxrwxrwx 1 root root 18 Nov 17 15:48 web2 -> /var/www/html/web1
The important thing to notice here is on the web2, you will see a -> (arrow) indication to where the web2 is actually linking, in this case its linking to /var/www/html/web1, which is exactly what we want. So from now on, any visitor going to web2, will actually be seeing the content on web1.

If you want more information, you can send this command for the ln manual:
     Code:
man ln
Then you should see something like this:


ln - make links between files

SYNOPSIS
ln [OPTION]... [-T] TARGET LINK_NAME (1st form)
ln [OPTION]... TARGET (2nd form)
ln [OPTION]... TARGET... DIRECTORY (3rd form)
ln [OPTION]... -t DIRECTORY TARGET... (4th form)

DESCRIPTION
In the 1st form, create a link to TARGET with the name LINK_NAME. In the 2nd form, create a link to TARGET in
the current directory. In the 3rd and 4th forms, create links to each TARGET in DIRECTORY. Create hard links
by default, symbolic links with --symbolic. When creating hard links, each TARGET must exist.

Mandatory arguments to long options are mandatory for short options too.

--backup[=CONTROL]
make a backup of each existing destination file

-b like --backup but does not accept an argument

-d, -F, --directory
allow the superuser to attempt to hard link directories (note: will probably fail due to system restric-
tions, even for the superuser)

-f, --force
remove existing destination files

-n, --no-dereference
treat destination that is a symlink to a directory as if it were a normal file

-i, --interactive
prompt whether to remove destinations

-s, --symbolic
make symbolic links instead of hard links

-S, --suffix=SUFFIX
override the usual backup suffix

-t, --target-directory=DIRECTORY
specify the DIRECTORY in which to create the links

-T, --no-target-directory
treat LINK_NAME as a normal file

-v, --verbose
print name of each file before linking

--help display this help and exit

--version
output version information and exit

The backup suffix is â~â, unless set with --suffix or SIMPLE_BACKUP_SUFFIX. The version control method may be
selected via the --backup option or through the VERSION_CONTROL environment variable. Here are the values:

none, off


Leave Your Comments

Share:   Subscribe - Keep Up With This Topic
You can use this HTML code to put it on your website to show your friends this wallpaper. Use this code on your profile like myspace, friendster, Facebook or others. Just Copy and Paste it in your HTML on your websites
URL:
To embed this topic, just copy the code from the "Embed" box. Once you've copied the code, just paste it into your website or blog to embed it.
Embed:
BBCODE is use on forums. You can put this code on all your BBCODE enabled forums like PhpBB, vBulletin® and others. Just Copy and Paste this code on your Posts and Replies on your forums
Fourms BBCODE:
Links Related to : Linking Files With Symbolic Links Linux Unix Shell Command Tutorial Guides
Add Link:
No Links Have Been Added To This Topic

Comments and replies About Linking Files With Symbolic Links Linux Unix Shell Command Tutorial Guides
:: 1 :: Reply #132 Reply By unix On Thu Dec 21, 2006 10:06 am
unix:
this works great, i did this to link them in linux:


     Code:
cd (to file where link is going to be)



     Code:
ln -s /var/www/web7/allwebs/web web



     Code:
ls -l
:: 2 :: Reply #133 Reply By unix On Sat Dec 23, 2006 9:44 am
unix:
HEllo,

my love pleace i am john fabiam from dakar senegal i love and i need you my private email address: buzzy_af2004 @ yahoo.co.in
contact me urgency
:: 3 :: Reply #11295 Reply By mike On Tue Jul 17, 2007 3:17 pm
mike:
hey all,

a linuks script which prompt for the ur temp dir/files.*($1) to be linked into the exact directory i,e dir/files.* ($2)..and finally a link to these all files is done.....