Question

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 use in /usr/bin. For each verify whether or not you can use your hard or symbolic link to execute the command.

Create both a hard link and a symbolic link to the symbolic link you created in the previous step. If either of these work this introduces 2 levels of indirection which you can think of as: file2 -> file1 -> cmd

Record the commands you used. Test and report on which (if any) of these secondary links can be used as an alias to the command.

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

N. B.

According to your requirement I have executed the command sequentially and give you the recorded command list.

"iteradmin@C126-C072:~$" This is the user name i have used.

For creation of Hard link it may ask for sudo password. you can use sudo at the beginning of link command

For Soft link use -s in ln command (Ex- ln -s source_file_name link_file_name) and for hard link don't use -s (Ex- ln source_file_name link_file_name)

The Exact command for Execution are as follows (recorded)

iteradmin@C126-C072:~$ touch linktest.txt

iteradmin@C126-C072:~$ cat linktest.txt

iteradmin@C126-C072:~$ ln -s linktest.txt softlink

iteradmin@C126-C072:~$ ln linktest.txt hardlink

iteradmin@C126-C072:~$ cat > linktest.txt

link test for Sot link and Hard link

iteradmin@C126-C072:~$ cat linktest.txt

link test for Sot link and Hard link

iteradmin@C126-C072:~$ cat softlink

link test for Sot link and Hard link

iteradmin@C126-C072:~$ cat hardlink

link test for Sot link and Hard link

iteradmin@C126-C072:~$ wc linktest.txt

1 8 37 linktest.txt

iteradmin@C126-C072:~$ wc softlink

1 8 37 softlink

iteradmin@C126-C072:~$ wc hardlink

1 8 37 hardlink

iteradmin@C126-C072:~$ ls -l softlink

lrwxrwxrwx 1 iteradmin iteradmin 12 Feb 18 17:04 softlink -> linktest.txt

iteradmin@C126-C072:~$ ls -l hardlink

-rw-r--r-- 2 iteradmin iteradmin 37 Feb 18 17:05 hardlink

iteradmin@C126-C072:~$ ln -s /usr/bin/who softlink_cmd

iteradmin@C126-C072:~$ ln -s /usr/bin/who hardlink_cmd

iteradmin@C126-C072:~$ export PATH=$PATH:$PWD

iteradmin@C126-C072:~$ softlink_cmd

iteradmin :0 2020-02-18 15:11 (:0)

iteradmin@C126-C072:~$ hardlink_cmd

iteradmin :0 2020-02-18 15:11 (:0)

iteradmin@C126-C072:~$ who

iteradmin :0 2020-02-18 15:11 (:0)

iteradmin@C126-C072:~$ ln -s softlink_cmd softlink_cmd_l

iteradmin@C126-C072:~$ ln hardlink_cmd hardlink_cmd_l

iteradmin@C126-C072:~$ softlink_cmd_l

iteradmin :0 2020-02-18 15:11 (:0)

iteradmin@C126-C072:~$ hardlink_cmd_l

iteradmin :0 2020-02-18 15:11 (:0)

iteradmin@C126-C072:~$ ls -l softlink_cmd_l

lrwxrwxrwx 1 iteradmin iteradmin 12 Feb 18 17:12 softlink_cmd_l -> softlink_cmd

iteradmin@C126-C072:~$ ls -l softlink_cmd

lrwxrwxrwx 1 iteradmin iteradmin 12 Feb 18 17:09 softlink_cmd -> /usr/bin/who

iteradmin@C126-C072:~$ ls -l hardlink_cmd_l

lrwxrwxrwx 2 iteradmin iteradmin 12 Feb 18 17:09 hardlink_cmd_l -> /usr/bin/who

iteradmin@C126-C072:~$ ls -l hardlink_cmd

lrwxrwxrwx 2 iteradmin iteradmin 12 Feb 18 17:09 hardlink_cmd -> /usr/bin/who

----------------------------------------------------------------------------------------

Explanation

It is proof that the alias is a copy of the original file because the contents written is copied to link file and tested using cat and wc commands. Also in ls -l command it showing the link of original and alias.

We can execute the link command (both Sot and Hard) by setting the path of home directory to PATH environment variable using export PATH command.

secondary links can be used as an alias to the command.

Screen Sorts

Add a comment
Know the answer?
Add Answer to:
Create a new file and create a hard link and a symbolic link to it. Use...
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
  • Objective: The objective of this lab is to work with files of UNIX file system. Procedure:...

    Objective: The objective of this lab is to work with files of UNIX file system. Procedure: 1. OpenyourUnixshellandtrythesecommands: Ø Create a new file and add some text in it v cat > filename Ø View a file v cat /etc/passwd v more /etc/passwd v more filename Ø Copy file1 ,making file2 v cp file1 file2 Ø Rename file1 as file2 v mv file1 file2 Ø Delete file1 as file2 vrm file //Deletefile // Double-check first v rm -i file Ø...

  • [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?...

  • 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...

  • 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...

  • 5.Create two files also called file file1 and file2 in testdir_2 Use the ls -lR to show you created the directories 6. Change the permission of the files in the directories below and show their permi...

    5.Create two files also called file file1 and file2 in testdir_2 Use the ls -lR to show you created the directories 6. Change the permission of the files in the directories below and show their permissions testdir/testdir_1/file1 where owner has read and execute permissions testdir/testdir_1/file2 where where owner has read, write and execute permissions. Group has read only permissions 7. Create a directory called newdir/newdir_1/newdir_2 copy the file testdir/testdir_1/file1 to this directory Change the permisions of the file to owner,...

  • 19. UNIX/Linux normally include two editors: vi and (choose the single best answer). 20. You can...

    19. UNIX/Linux normally include two editors: vi and (choose the single best answer). 20. You can use thecommand to create empty a create b. make c touch d mu 21. Which command can be used to leave vi temporarily to access the command line? 22 If you execute the contents of filel are sorted and the results are stored in file2. a sort file1 -ofile2 b. sort file1 >file2 c sort filel -d file2 d sort filel filez field or...

  • Question: Hands-On Project 3-3 Use a Batch File A file with a bat file extension is...

    Question: Hands-On Project 3-3 Use a Batch File A file with a bat file extension is called a batch file. Yo... Use a Batch File A file with a .bat file extension is called a batch file. You can use a batch file to execute a group of commands, sometimes called a script, from a command prompt. Do the following to learn to use a batch file: 1. Using a command prompt window, copy the files in your Documents folder...

  • LINUX QUESTIONS (dont have to display output, I will be running these commands myself to check...

    LINUX QUESTIONS (dont have to display output, I will be running these commands myself to check the output) Display the command(s) used to do the following: create an empty file called history by using just a redirection operator. Verify and show. Show/verify all results (i.e., all commands and their corresponding outputs). Wait 1 minute or more and then display the command(s) used to do the following: change the timestamp on the history file you just created. Verify/display the change. Show/verify...

  • COSC 3411 /ITAP 3411 Homework (UNIX Shell Commands) How would you ensure that all ordinary files...

    COSC 3411 /ITAP 3411 Homework (UNIX Shell Commands) How would you ensure that all ordinary files created by you have rw-rw---- as default permissions? How would you sort in the background a file called "bad.txt", and place the results in a file called "sort.txt"? Archive the contents of your home directory (including any subdirectories) using tar. Compress the tar archive with gzip. Now extract their contents. Use the “find” command to locate in /docs and /usr/docs all files that Begin...

  • Using Unix processes Submit a README file that lists the files you have submitted along with...

    Using Unix processes Submit a README file that lists the files you have submitted along with a one sentence explanation. Call it Prj1README. MakeCopy.c : Write a C program that makes a new copy of an existing file using system calls for file manipulation. The names of the two files and copy block sizes are to be specified as command line arguments. Open the source file in read only mode and destination file in read/write mode. ForkCopy.c : Write a...

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