Solved

link file

Posted on 2014-04-02
9
413 Views
Last Modified: 2014-04-08
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?
0
Comment
Question by:tonydba
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 39972262
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.
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 39972269
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!
0
 

Author Comment

by:tonydba
ID: 39972290
Actually I did not understand

what is the expected output of the command I provided..
0
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 
LVL 68

Expert Comment

by:woolmilkporc
ID: 39972298
ln: creating symbolic link `$ORACLE_HOME/lib/libobk.a' to `/usr/lib/libnsrora.a': File exists
0
 
LVL 84

Expert Comment

by:ozo
ID: 39972300
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?
0
 
LVL 13

Expert Comment

by:Sandy
ID: 39972334
it won't work.. to create the symbolic link the destination file must not be exist.

TY/SA
0
 

Author Comment

by:tonydba
ID: 39974949
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.
0
 
LVL 84

Accepted Solution

by:
ozo earned 500 total points
ID: 39975122
What do you mean by "output"?
The result of a successful link is a new target file which is a link to the source file.
Nothing is displayed to stdout or stderr after a successful link, the exit status will be 0, and you get  a new shell prompt.
If you try to link two existing files, it will fail, an error message will be displayed (which might look like http:#a39972298), the exit status will be 1, and you get  a new shell prompt.

I wouldn't have called any of that "output", so I would say that there is no "output".
But if you try to look at the contents of the target file after it has been created by a successful link, it will look like it's the same as the contents of the source file.
0
 

Author Closing Comment

by:tonydba
ID: 39986486
Thank you.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to enable sync between two yum repo? 1 55
cannot rename datastore 3 98
centos commands 6 93
Unix Help with:  mailx -s 17 59
Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question