Unix C++
Would you like to react to this message? Create an account in a few clicks or log in to continue.

diff bet ln and cp

+4
Saradha Kannan
Navitha
Mahee
ARVINTH B.J
8 posters

Go down

diff bet ln and cp Empty diff bet ln and cp

Post by ARVINTH B.J Wed Mar 10, 2010 1:22 pm

whats ln command? whats its use?????
whats the diff bet ln command and cp command.

ARVINTH B.J

Posts : 20
Points : 31
Join date : 2010-02-26

Back to top Go down

diff bet ln and cp Empty Re: diff bet ln and cp

Post by Mahee Wed Mar 10, 2010 1:25 pm

ln creates a link(reference) to file
cp creates a new copy of a file in the destination
Mahee
Mahee

Posts : 29
Points : 233
Join date : 2010-03-03
Location : Haldia

Back to top Go down

diff bet ln and cp Empty Re: diff bet ln and cp

Post by Navitha Wed Mar 10, 2010 2:07 pm

how ln works.

when i tried the command
$ ln j4.log empty2

It showed

ln: creating hard link `empty2' to `j4.log': File exists

Navitha

Posts : 14
Points : 24
Join date : 2010-02-26

Back to top Go down

diff bet ln and cp Empty Re: diff bet ln and cp

Post by ARVINTH B.J Wed Mar 10, 2010 2:09 pm

even the referenced file has the contents in it which is same as the original file. So whts the diff? can u pls xplain.....

ARVINTH B.J

Posts : 20
Points : 31
Join date : 2010-02-26

Back to top Go down

diff bet ln and cp Empty Re: diff bet ln and cp

Post by ARVINTH B.J Wed Mar 10, 2010 2:15 pm

I got the difference between cp and ln.

After creating a link,when you modify the original file it reflects in the referenced file and viceversa.

This wont happen with the cp command.

ARVINTH B.J

Posts : 20
Points : 31
Join date : 2010-02-26

Back to top Go down

diff bet ln and cp Empty Re: diff bet ln and cp

Post by ARVINTH B.J Wed Mar 10, 2010 2:32 pm

i think....

its not possible to link a file to another file which already exists.
if we dont specify the type of link it by default creates the hard link.
the other is the soft(symbolic) link for which the option -s is used.

ln with no options creates a hard link, ln -f forces a hard link, ln -s creates a symbolic link, and ln -fs forces a symbolic link.

ARVINTH B.J

Posts : 20
Points : 31
Join date : 2010-02-26

Back to top Go down

diff bet ln and cp Empty Re: diff bet ln and cp

Post by Saradha Kannan Wed Mar 10, 2010 4:27 pm

Can u pls tel me what wud be the cmd for exercise lab session1-->
q.10: Create a link 'tmp' under FIN directory for matter,which is another directory..

Saradha Kannan

Posts : 25
Points : 25
Join date : 2010-03-04

Back to top Go down

diff bet ln and cp Empty Re: diff bet ln and cp

Post by Maithreyi Wed Mar 10, 2010 5:14 pm

ln name of another directory/matter tmp

this is the syntax.

Eg :- 335818
/ \
FIN HRD
\
matter
Say your directory structure is

suppose I am in directory FIN and matter is in directory HRD, then the command would be

ln ~-/HRD/matter tmp

~- refers to previous directory

Maithreyi

Posts : 76
Points : 142
Join date : 2010-03-03
Age : 36
Location : Haldia

Back to top Go down

diff bet ln and cp Empty Re: diff bet ln and cp

Post by Christopher Wed Mar 10, 2010 9:56 pm

to be more specific, "~-" stands for previous working directory not previous directory.

Code:
$ ln ~-/HRD/matter tmp

the above command wont work in all situations. its better to use

Code:
$ ln /335818/HRD/matter tmp
Christopher
Christopher
Admin

Posts : 240
Points : 429
Join date : 2010-02-26
Age : 35

https://unixcpp.forumotion.com

Back to top Go down

diff bet ln and cp Empty Re: diff bet ln and cp

Post by Saradha Kannan Thu Mar 11, 2010 1:50 pm

If I try the cmd the above cmd, i get dis error msg:
ln: accessing `/home/335837/hrd/HRD/matter': No such file or directory
What is it that is happening?

Saradha Kannan

Posts : 25
Points : 25
Join date : 2010-03-04

Back to top Go down

diff bet ln and cp Empty Re: diff bet ln and cp

Post by Christopher Thu Mar 11, 2010 2:09 pm

check the path.
Christopher
Christopher
Admin

Posts : 240
Points : 429
Join date : 2010-02-26
Age : 35

https://unixcpp.forumotion.com

Back to top Go down

diff bet ln and cp Empty Re: diff bet ln and cp

Post by akalya Thu Mar 11, 2010 2:16 pm

since ur already in 335837 directory..../335837/hrd/matter tries to search for another 335837 directory within 335837....so try
ln hrd/HRD/matter tmp

where hrd is a directory within 335837......

akalya

Posts : 70
Points : 86
Join date : 2010-03-04

Back to top Go down

diff bet ln and cp Empty Re: diff bet ln and cp

Post by shivangi shah Fri Mar 19, 2010 1:35 pm

nice explanation about hard link and symbolic link is given in wikipidea..
shivangi shah
shivangi shah

Posts : 3
Points : 3
Join date : 2010-03-11
Age : 36
Location : Haldia

Back to top Go down

diff bet ln and cp Empty Re: diff bet ln and cp

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum