Link to home
Start Free TrialLog in
Avatar of tonydba
tonydba

asked on

link file

When we link two files
what will be the expected output..

ln –s /usr/lib/libnsrora.a $ORACLE_HOME/lib/libobk.a

ie,
we get the contents of libnsrora.a + libobk.a


is that right?
Avatar of ozo
ozo
Flag of United States of America image

man ln
NAME
     link, ln -- make links

SYNOPSIS
     ln [-Ffhinsv] source_file [target_file]
     ln [-Ffhinsv] source_file ... target_dir
     link source_file target_file

DESCRIPTION
     The ln utility creates a new directory entry (linked file) which has the same modes as the original file.  It is useful for maintaining multiple copies of a file in many places at once without
     using up storage for the ``copies''; instead, a link ``points'' to the original copy.  There are two types of links; hard links and symbolic links.  How a link ``points'' to a file is one of the
     differences between a hard and symbolic link.

     The options are as follows:
...
     -s    Create a symbolic link.
...
     By default, ln makes hard links.  A hard link to a file is indistinguishable from the original directory entry; any changes to a file are effectively independent of the name used to reference the
     file.  Hard links may not normally refer to directories and may not span file systems.

     A symbolic link contains the name of the file to which it is linked.  The referenced file is used when an open(2) operation is performed on the link.  A stat(2) on a symbolic link will return the
     linked-to file; an lstat(2) must be done to obtain information about the link.  The readlink(2) call may be used to read the contents of a symbolic link.  Symbolic links may span file systems and
     may refer to directories.
No, not at all.

You will get an error message saying that $ORACLE_HOME/lib/libobk.a already exists.

And should you specify the "-f" (=force) flag along with "-s" then $ORACLE_HOME/lib/libobk.a will be deleted (!) and replaced with a link to /usr/lib/libnsrora.a! Accessing this link $ORACLE_HOME/lib/libobk.a will be the same as accessing /usr/lib/libnsrora.a directly!

To repeat it: $ORACLE_HOME/lib/libobk.a will be gone when using the "-f" flag!
 
Be careful!
Avatar of tonydba
tonydba

ASKER

Actually I did not understand

what is the expected output of the command I provided..
ln: creating symbolic link `$ORACLE_HOME/lib/libobk.a' to `/usr/lib/libnsrora.a': File exists
If the target file already exists, the output will be an error message, as woolmilkporc has said.
Otherwise, there will be no output, and the link will be silently created.

Were you thinking of the `cat` command?
it won't work.. to create the symbolic link the destination file must not be exist.

TY/SA
Avatar of tonydba

ASKER

Sir only only question..


Wht is the expected output if we link two file.

I definitely understand that source and target exist...
how the output looks like that is my question.
ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of tonydba

ASKER

Thank you.