ubuntu - Difference between unlink and rm on unix -
whats real different between these 2 commands? why system call delete file called unlink
instead of delete
?
you need understand bit original unix file system understand important question.
unlike other operating systems of era (late 60s, 70s) unix did not store file name actual directory information (of file stored on disks.) instead, unix created separate "inode table" contain directory information, , identify actual file, , allowed separate text files directories of names , inodes. originally, directory files meant manipulated other files straight text files, using same tools (cat, cut, sed, etc.) shell programmers familiar day.
one important consequence of architectural decision single file have more 1 name! each occurrence of inode in particular directory file linking inode, , known. connect file name file's inode (the "actual" file,) "linked" it, , when deleted name directory "unlinked" it.
of course, unlinking file name did not automatically mean deleting / removing file disk, because file might still known other names in other directories. inode table includes link count keep track of how many names inode (a file) known by; linking name file adds 1 link count, , unlinking removes one. when link count drops down zero, file no longer referred in directory, presumed "unwanted," , can deleted.
for reason "deletion" of file name unlinks - hence name of system call - , there important ln command create additional link file (really, file's inode,) , let known way.
other, newer operating systems , file systems have emulate / respect behavior in order comply posix standard.
Comments
Post a Comment