3,033 views

A student wishes to create symbolic links in a computer system running Unix. Three text files named $\text{file 1}", \text{file 2}"$ and $\text{file 3}"$ exist in her current working directory, and the student has read and write permissions for all three files. Assume that $\text{file 1}$ contains information about her hobbies, $\text{file 2}$ contains information about her friends and $\text{file 3}$ contains information about her courses. The student executes the following sequence of commands from her current working directory

ln -s file 1 file 2
ln -s file 2 file 3

Which of the following types of information would be lost from her file system?

1. Hobbies
2. Friends
3. Courses
1. I and II only
2. II and III only
3. II only
4. I and III only

### 1 comment

Is this in syllabus for 2018?

Correct option: B

As ln -s is a symbolic link. In this case

File$3 \Rightarrow$ File$2 \Rightarrow$ File$1 \Rightarrow$ Hobbies (actual data).

So File$2$ and File$3$ contents are lost.

by

ln -s file1 file2

Here file2 becomes a symbolic link to file1. (first file is destination and second one the link).

So, in the question a file with the same name as link already exists and hence that is replaced by the link. In most OS, this won't happen by default and we have to use

ln -sf file1 file2

to force the replacement.
Thanx @ Arjun.

Got it . :)

see this practical

fig1

fig2

fig3

Combining it all :

ln -s arg1 arg2 => creates a symbolic link
if both arg1 & arg2 are file names, agr2 becomes a link and points to file arg1
Here,
ln -s file1 file2 => file2 is now a link name that points to file1.
ln -s file2 file3 => ambiguity -> file2 is the name for a link as well as a file, link is prioritized over file so file2 is no more a filename. file3 becomes a link pointing to link file2(pointer to another pointer)

Hence all point to file1 & data of file2 & file3 are lost.

But why the data is lost of file 2 and file 3

@Chawlaajay file 2 starts referring to file 1 so now it doesnot refer to its data so the data of file 2 is lost

file 3 starts referring to file 2 which is referring to file 1 so that implies file 3 also starts referring to file 1 so the data of file 3 is also lost.

This is how the data  of both the files are lost.