Links

University of Wisconsin Madison

Computer Systems Lab CS1000

Wiscinfo
Wiscinfo
CS Home
CS Home
CSL
CSL
Feedback
CS1000
Feedback
Feedback

next up previous contents index
Next: Processes Up: UNIX Previous: UNIX

Links

   

Sometimes you need a file to exist in multiple directories. Instead of having multiple copies, which would waste disk space, you can create links to just one file. The standard link is a hard link. When a hard link is created, all links essentially become the same file. If you remove a file that is hard linked will only remove links until the last link is removed, then the file is actually removed. The file is only deleted once the last link is removed. The other type of link is the symbolic link, which is a pointer to where the file actually resides. If you remove a symbolic link, then only the symbolic link is removed, but if you remove the actual file, then the actual file will be removed, but all links will still point to the non-existent file. Symbolic links generally prove to be more useful.

vega1% ls -la

drwxr-xr-x 10 bucky        2048 Jan 16 17:18 private
drwxr-xr-x  4 bucky        2048 Jan 10 15:43 public
-rw-r-----  1 bucky       28676 Jan 16 13:35 prog1.c

vega1% ln prog1.c junk    

vega1% ln -s public/.plan .plan

vega1% ls -la

drwxr-xr-x 10 bucky        2048 Jan 16 17:18 private
drwxr-xr-x  4 bucky        2048 Jan 10 15:43 public
-rw-r-----  2 bucky       28676 Jan 16 13:35 prog1.c
-rw-r-----  2 bucky       28676 Jan 16 13:35 junk
lrwxr-xr-x  1 bucky          14 Jan 16 13:35 .plan -> ./public/.plan

 



Caitlin Howell
Thu Jan 16 20:24:40 CST 1997