The Gateway to Computer Science Excellence
+8 votes

A student wishes to create symbolic links in a computer system running Unix. Three text files named "file 1", "file 2" and "file 3" exist in her current working directory, and the student has read and write permissions for all three files. Assume that file 1 contains information about her hobbies, file 2 contains information about her friends and 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
in Operating System by Boss (16.3k points) | 1.3k views
Is this in syllabus for 2018?

2 Answers

+13 votes
Best answer
option B

As ln -s is symbolic link. In this case

File3 ⇒ File2 ⇒ File1 ⇒ Hobbies(actual data).

So File2 and File3 content are lost.
by Active (1k points)
selected by
What does this symbolic link mean ??

Could you expand your answer a bit more please.
symbolic link is like shortcut to a file.
But that has been used in both commands !!

How did it make the difference ?
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 . :)
+6 votes
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
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.
by Active (2.5k points)
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.


Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,737 questions
57,384 answers
105,341 users