Lab 11

Back Up Next

horizontal rule

Home
Lab 1
Lab 2
Lab 3
Lab 4
Lab 5
Lab 6
Lab 7
Lab 8
Lab 9
Lab 10
Lab 11
Lab 12
Lab 13
Lab 14
Lab 15
Lab 16
Lab 17
Lab 18
Lab 19
Lab 20

Lab 11

(Chapter 11)

 

 


 

Learning Objectives

  1. To learn how hard and soft links are created and used
  2. To learn what impact do creation of hard and soft links have on the file system structure
  3. To learn about the relationship between links and file access permissions
  4. To learn about the contents of hard and soft links

Lab Work

In this lab, you will learn how to create hard and soft links in UNIX. For this purpose, you will use the file system structure created in Lab 7 and smallFile that you created in Lab 9. We are reproducing both here for your reference.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


 

$ more smallFile

John    Doe     ECE     3.54    doe@jd.home.org 111.222.3333

James   Davis   ECE     3.71    davis@jd.work.org       111.222.1111

Al      Davis   CS      2.63    davis@a.lakers.org      111.222.2222

Ahmad   Rashid  MBA     3.74    ahmad@mba.org   111.222.4444

Sam     Chu     ECE     3.68    chu@sam.ab.com  111.222.5555

Arun    Roy     SS      3.06    roy@ss.arts.edu 111.222.8888

Rick    Marsh   CS      2.34    marsh@a.b.org   111.222.6666

James   Adam    CS      2.77    jadam@a.b.org   111.222.7777

Art     Pohm    ECE     4.00    pohm@ap.a.org   111.222.9999

John    Clark   ECE     2.68    clark@xyz.ab.com        111.111.5555

Nabeel  Ali     EE      3.56    ali@ee.eng.edu  111.111.8888

Tom     Nelson  ECE     3.81    nelson@tn.abc.org       111.111.6666

Pat     King    SS      2.77    king@pk.xyz.org 111.111.7777

Jake    Zulu    CS      3.00    zulu@jz.sa.org  111.111.9999

John    Lee     EE      2.64    jlee@j.lee.com  111.111.2222

Sunil   Raj     ECE     3.36    raj@sr.cs.edu   111.111.3333

Charles Right   EECS    3.31    right@cr.abc.edu        111.111.4444

Diane   Rover   ECE     3.87    rover@dr.xyz.edu        111.111.5555

Aziz    Inan    EECS    3.75    ainan@ai.abc.edu        111.111.1111

Lu      John    CS      3.06    lu.john@xyz.org 111.333.1111

Lee     Chow    EE      3.74    chow@lc.www.ord 111.333.2222

Adam    Giles   SS      2.54    giles@cric.org  111.333.3333

Andy    John    EECS    3.98    john@aj.ece.edu 111.333.4444

$

  1. Log on to your UNIX system
  2. Remove everything that you created under the temp directory in the above structure. Show the session that you used for this purpose.

 

 

 

 

 

  1. Create three directories under the temp directory: d1, d2, and d3. Make a copy of smallFile in d1. Display long listing of smallFile and identify inode number, access permissions, hard link count, and file size. Show your session.

 

 

 

 

 

 

 

  1. Change directory to the d2 directory under the temp directory. Create a hard link to smallFile in d1. Name the link file newFile.hard. Display long listing of newFile.hard and compare its attributes with that of smallFile. How would you confirm that smallFile and smallFile.hard are two names of the same file, i.e., they are hard links to the same file? Show your session.

 

 

 

 

 

 

 

 

 

 

 

  1. Display contents of smallFile by using the pathname for the hard link to the file, smallFile.hard. You should be able to do this. Now, take away the read permission for smallFile for yourself and try displaying the file again. What happens? What do you conclude from the above exercise? Add the read permission for yourself on the file and try redisplaying it. You should be able to do this. Finally, make a backup copy of smallFile and delete smallFile. Now try displaying its contents by using the pathname for smallFile.hard. What happens? Does it make sense to you? Explain.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  1. Keep ~/temp/d2 as your current directory. Create a hard link to ~/temp/d2/smallFile.hard and call it ~/temp/d1/smallFile. This means that you have undone the rm ~/temp/d1/smallFile command executed in 5 above and the hard link count for the file is back to 2. Now create a soft link to ~/temp/d1/smallFile, called ~/temp/d2/smallFile.soft. Display long listing of smallFile.soft and compare its attributes with that of smallFile. How would you confirm that smallFile and smallFile.soft are two different files? What do the sizes of the two files indicate? Show your session.

 

 

 

 

 

 

 

 

 

 

 

  1. Display contents of smallFile by using the pathname for the soft link to the file, smallFile.hard. You should be able to do this. Now, take away the read permission for smallFile for yourself and try displaying the file again. What happens? What do you conclude from the above exercise? Add the read permission for yourself on the file and try redisplaying it. You should be able to do this. Finally, make a backup copy of smallFile and delete the original (i.e., smallFile). Now try displaying its contents by using the pathname for smallFile.soft. What happens? Does it make sense to you? Explain.

 

 

 

 

 

 

 

 

 

 

 

 

 

  1. Log out.

 


 

 

horizontal rule

Back to CS140U Homepage
This page was last modified September 26, 2004
wmorales@pcc.edu