Question

[2] What happens when you try to create a hard link to a directory? [2] Create...

[2] What happens when you try to create a hard link to a directory? [2] Create a new directory. In the new directory, create a new file. In the new directory, create a symbolic link to the new file with its relative path. Test that the link is really working by 'cat'ing the symbolic link. Use the mv command to move the symbolic link to another directory (either the parent or a new subdirectory. Will the symbolic link still work? Explain why or why not. What would happen if you used a hard link? Explain.

Hello I am studying IT and i need help in my course operating system ?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

1)

An error message is thrown.

A hard link to a directory can link to a parent of itself, which creates a file system loop. For example, these commands could create a loop with the back link l:

mkdir -p /tmp/a/b
cd /tmp/a/b
ln -d /tmp/a l

A filesystem with a directory loop has infinite depth:

cd /tmp/a/b/l/b/l/b/l/b/l/b

Avoiding an infinite loop when traversing such a directory structure is somewhat difficult (though for example POSIX requires find to avoid this).

A file system with this kind of hard link is no longer a tree, because a tree must not, by definition, contain a loop.

2)

mkdir new_dir

cd new_dir

touch new_file.txt

ln -s ~/Desktop/new_dir/new_file.txt my_link.txt

cat my_link.txt

mkdir sub_dir

mv my_link.txt sub_dir/

No, the symbolic link won't work now since the relation path of the link file has changed to an invalid file path.

Once a hard link has been made the link is to the inode. deleting renaming or moving the original file will not affect the hard link as it links to the underlying inode. Any changes to the data on the inode is reflected in all files that refer to that inode.

Add a comment
Know the answer?
Add Answer to:
[2] What happens when you try to create a hard link to a directory? [2] Create...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Create a new file and create a hard link and a symbolic link to it. Use...

    Create a new file and create a hard link and a symbolic link to it. Use vim or redirection to add content of the original file, then use cat and wc to examine each of the two aliases that you created. How does the result prove or disprove that either alias is a copy of the original file? In your home directory create a hard link and a symbolic link to one of the commands that you know how to...

  • do numbers 4-8 4. Given any directory, use the Is command to display: • all files...

    do numbers 4-8 4. Given any directory, use the Is command to display: • all files and sub-directories starting with the letter "D" (note do not list anything in any sub-directory) • its immediate sub-directories (sub-directories only, and no other ordinary files) its immediate hidden sub-directories only - take a screenshot (#3-3) that clearly shows the command and the result. 5. Assume that the following files are in the working directory: $ ls intro notesb ref2 section 1 section3 section4b...

  • Completion is a screenshot of the batch file showing all of the steps to create the file system s...

    Completion is a screenshot of the batch file showing all of the steps to create the file system shown below. Instructions Create a batch file clifilesystem.cmd using Notepad which performs the following steps to create the file system shown below. Also use a proper comment for each step before the command. Proof your work. Finally submit the clifilesystem.cmd file in Blackboard Figure 1. The clijfilesystem.cmd file system Work from Desktop unless using an absolute path Desktop NOS110 OS Labs Homework...

  • Question 4 0/1 point (graded) Which of the following statements does NOT correctly describe the utility...

    Question 4 0/1 point (graded) Which of the following statements does NOT correctly describe the utility of a command in Unix? The q key exits the viewer when you use less to view a file. The command ls lists files in the current directory. The command mkdir makes a new directory and moves into it. The mv command can move a file and change the name of a file. incorrect Answer Incorrect: Try again. The mv command can move a...

  • 2. Create a directory using “mkdir” and change into that directory using “cd”. Next, create another...

    2. Create a directory using “mkdir” and change into that directory using “cd”. Next, create another directory within the new directory and then change into that directory. Now, run cdwithout any arguments, then run pwd. What do you conclude about the cd command when run with no arguments? 3. You won't find the set command in either /bin or /usr/bin, or in any directory listed in the PATH setting. How is it executed then? (That is, if there is no...

  • Question 2 0/1 point (graded) What happens when you remove a directory using the command rm...

    Question 2 0/1 point (graded) What happens when you remove a directory using the command rm -r? You cannot remove a directory using the rm command. You permanently remove the entire directory, including all files and subdirectories. You move the entire directory to a trash folder, but it can be restored later. You get a warning message asking if you want to proceed, then you delete the directory. incorrect Answer Incorrect: Try again. Unix does not warn you before permanently...

  • 3. File and Directories Files and directories provide a basic abstraction of persistent data to users. Here we explore (ab systems work, focusing on links. Sometimes links lead to pretty odd performa...

    3. File and Directories Files and directories provide a basic abstraction of persistent data to users. Here we explore (ab systems work, focusing on links. Sometimes links lead to pretty odd performance problems. (a) Assume we have a regular file that is referred to by the pathname /a/b/c/orig.txt-how many directories wil we access when opening this file? (b) Now assume we create a hard link to this file, as follows: 1n /a/b/c/orig.txt /hard.txt. How directories will we access when opening...

  • For each command give me the ENTIRE COMMAND SEQUENCE. If I ask you 'What command would...

    For each command give me the ENTIRE COMMAND SEQUENCE. If I ask you 'What command would I use to move the file one.txt to the parent directory and rename it to two.txt?", the answer is NOT 'mv'. That is only part of the command. 16. What command could I run to determine whether the ssh daemon is listening? With OpenSSH installed and running, the result should show that ssh/port 22 as "listening.' (5 pts) 17. Create a crontab entry that...

  • Problem 8 (18 points): Answer the following questions regarding managing files and directories: a) What command...

    Problem 8 (18 points): Answer the following questions regarding managing files and directories: a) What command would remove the directory /trashbin and all of the files and subdirectories inside of it? b) What command flag can you use with cp so that it doesn’t accidentally overwrite a file if it already exists? c) What command exists to delete a directory if and only if it is already empty? d) Which command can be used to rename a file or directory?...

  • VI Exercise Ex 1. At your home directory, create a new file “test1” which contains following...

    VI Exercise Ex 1. At your home directory, create a new file “test1” which contains following 2 lines, save and exit. Hello, This is my vi test file SOI Asia project stands for School of Internet Asia project Ex 2. Edit file “test1” to contain following content. Change content on first line by using command “x” to delete unwanted characters and then inserting desired texts. Then use “G” to go to last line and press “o” to insert text at...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT