链接是一种在共享文件和访问它的用户的若干目录项之间建立联系的一种方法。Linux中包括两种链接:硬链接(Hard Link)和软链接(Soft Link),软链接又称为符号链接(Symbolic link)。
一、硬链接
硬链接说白了是一个指针,指向文件索引节点,系统并不为它重新分配inode。可以用:ln命令来建立硬链接。语法:
引用:ln [options] existingfile newfile
ln[options] existingfile-list directory
用法: 第一种:为”existingfile”创建硬链接,文件名为”newfile”。第二种:在”directory”目录中,为”existingfile-list”中包含的所有文件创建一个同名的硬链接。常用可选[options] -f 无论”newfile”存在与否,都创建链接。-n 如果”newfile”已存在,就不创建链接。
下面举一些例子:
引用:$ ls -il
13058 -rwx - - - - - - 1 longcheng longcheng 48 8月 5 16:38 file1
13059 -rwx - - - - - - 1 longcheng longcheng 57 8月 5 16:40 file2
$ ln file2 file2hard
$ ls -il
13058 -rwx - - - - - - 1 longcheng longcheng 48 8月 5 16:38 file1
13059 -rwx - - - - - - 2 longcheng longcheng 57 8月 5 16:40 file2
13059 -rwx - - - - - - 2 longcheng longcheng 57 8月 5 16:40 file2hard
注意在创建链接前,file1 显示的链接数目为1,创建链接后(1)file1和file1hard的链接数目都变为2;(2) file1和file1hard在inode号是一样的(3) file1和file1hard显示的文件大小也是一样。可见进行了ln命令的操作结果:file1和file1hard是同一个文件的两个名字,它们具有同样的索引节点号和文件属性,建立文件file1的硬链接,就是为file1的文件索引节点在当前目录上建立一个新指针。
链接数同时减一,只有将所有指向文件内容的指针,也即链接数减为0时,内核才会把文件内容从磁盘上删除。当前目录逻辑结构:(不好意思图没有显示出来)。
还可以在不同目录,但同一文件系统中建立文件的硬链接。设file1、file2在目录/home/longcheng/dir1中,下面的命令,在/home/longcheng中建立file2的硬链接。
引用:ln file2 /home/longcheng/file2hard
下面的程序,是将dir1目录中所有文件,在目录dir2中建立硬链接
引用:$mkdir dir2
$ln /home/longcheng/dir1/* /home/longcheng/dir2
如果使用了 ln -f existingfile newfile,如果newfile已经存在,则无论原来newfile是什么文件,只用当前用户对它有写权限,newfile就成为exisitngfile的硬链接文件。
尽管硬链接节省空间,也是Linux系统整合文件系统的传统方式,但是存在一下不足之处:
(1)不可以在不同文件系统的文件间建立链接
(2)只有超级用户才可以为目录创建硬链接。虽然很多树上说root用户可以创建,但是笔者在学习过程中发现即使是root用户也不能创建,我的系统是Redhat,内核2.4、2.6都试过,在其他系统中不知道是不是可以。
72.10.74.* 于 2007-07-09 14:29:03发表:
cash advance baltimore cash advance baltimore http://www.freewebs.com/cash-177/cash-advance-baltimore.html eckerd drug eckerd drug http://www.iloveeconomics.com/_disc1/00000a39.htm carisoprodol http://www.freewebs.com/drugs-591/carisoprodol.html soma carisoprodol http://www.freewebs.com/drugs-473/buy-ambien-2.html buy ambien online buy ambien online strategie crap http://www.freewebs.com/casino-672/craps-4.html strategia crap
0.0.0.* 于 2007-07-09 14:01:20发表:
http://www.freewebs.com/cash-920/cash-advance-pennsylvania.html cash advance pennsylvania cash advance pennsylvania http://www.freewebs.com/cash-862/lawsuit-cash-advance.html lawsuit cash advance lawsuit cash advance http://www.freewebs.com/poker-191/video-poker-8.html online video poker online video poker world casino virtual casino http://www.freewebs.com/casino-511/casino-8.html download free cingular ringtones free real ringtones http://www.freewebs.com/ringtone-518/free-ringtones-9.html
74.193.17.* 于 2007-07-09 13:29:46发表:
buy viagra online buy viagra online http://www.freewebs.com/drugs-90/buy-viagra-2.html http://www.freewebs.com/drugs-473/buy-levitra.html buy levitra buy levitra http://www.freewebs.com/casino-496/roulette-5.html online roulette poker casino roulette regola baccarat http://www.freewebs.com/poker-110/baccarat-8.html regole baccarat game poker poker gratuito http://www.freewebs.com/poker-656/poker-9.html
0.0.0.* 于 2007-07-09 13:13:15发表:
http://tmtyl.com/stories/_forum/00004088.htm viagra pill viagra pill http://www.freewebs.com/casino-418/blackjack-6.html internet blackjack blackjack game stanze di gioco http://www.freewebs.com/poker-110/gioco-9.html stanze di gioco in linea libere ambien online http://dplyer.com/j4kforum/_disc10/00000db6.htm ambien online cash advance riverside cash advance riverside http://www.freewebs.com/cash-640/cash-advance-riverside.html
0.0.0.* 于 2007-07-09 12:44:57发表:
payday cash advance http://www.freewebs.com/cash-640/payday-cash-advance.html payday cash advance download free ringtone http://www.freewebs.com/ringtone-251/ringtones-7.html download free ringtone strategie crap craps online http://www.freewebs.com/casino-496/craps-4.html nextel ringtones ringtones http://www.freewebs.com/ringtone-936/ringtones-12.html http://www.freewebs.com/cash-892/cash-advance-chicago.html cash advance chicago cash advance chicago
68.178.39.* 于 2007-07-09 12:30:57发表:
poker online http://www.freewebs.com/poker-734/online-poker-7.html poker on line pay day cash advance pay day cash advance http://www.freewebs.com/cash-41/pay-day-cash-advance.html cheap tramadol buy tramadol online http://www.freewebs.com/drugs-752/tramadol.html free ringtone free ringtone http://www.freewebs.com/ringtone-728/ringtones-7.html http://www.msd.k12.or.us/schools/mhs/AlumDiscuss/00001385.htm order phentermine order phentermine
71.238.148.* 于 2007-07-09 12:11:03发表:
cash advance minneapolis http://www.freewebs.com/cash-100/cash-advance-minneapolis.html cash advance minneapolis order viagra order viagra http://www.valleygroup.org/VG_disc1/000000a2.htm cash advance phoenix cash advance phoenix http://www.freewebs.com/cash-388/cash-advance-phoenix.html http://www.freewebs.com/cash-41/cash-advance-boston.html cash advance boston cash advance boston gioco gratuito gioco in linea http://www.freewebs.com/poker-507/gioco-8.html
0.0.0.* 于 2007-07-09 12:10:14发表:
http://www.freewebs.com/casino-606/casino-game-5.html casino games casinos games giochi poker http://www.freewebs.com/poker-806/poker-4.html internet poker regole crap craps online http://www.freewebs.com/casino-162/craps-8.html cash advance kansas city http://www.freewebs.com/cash-256/cash-advance-kansas-city.html cash advance kansas city ringtones cingular ringtones http://www.freewebs.com/ringtone-936/ringtones-11.html
71.207.48.* 于 2007-07-09 12:05:25发表:
internet slot machine internet slot machine http://www.freewebs.com/casino-244/slots-3.html http://www.freewebs.com/casino-674/blackjack-8.html black jack play blackjack nextel ringtone nextel ringtone http://www.freewebs.com/ringtone-136/ringtones-4.html online payday cash advance online payday cash advance http://www.freewebs.com/cash-838/online-payday-cash-advance.html penis enlargement penis enlargement http://www.freewebs.com/drugs-399/penis-enlargement.html
83.244.128.* 于 2007-07-09 12:05:13发表:
cash advance cincinnati cash advance cincinnati http://www.freewebs.com/cash-862/cash-advance-cincinnati.html cheap viagra uk cheap viagra uk http://www.freewebs.com/drugs-322/cheap-viagra.html stanze di gioco migliori stanze di gioco in linea libere http://www.freewebs.com/poker-161/gioco-3.html free sprint ringtones http://www.freewebs.com/ringtone-245/ringtones-5.html selena ringtones http://www.freewebs.com/cash-256/cash-advance-boston.html cash advance boston cash advance boston
69.248.234.* 于 2007-07-09 11:56:06发表:
cheap cialis cheap cialis http://www.freewebs.com/drugs-870/cialis-2.html drug online drug online http://www.identityunit.com/_disc1/00000069.htm free sprint ringtones http://www.freewebs.com/ringtone-920/free-ringtones-8.html download free cingular ringtones cash advance newark http://www.freewebs.com/cash-838/cash-advance-newark.html cash advance newark cheap viagra http://www.freewebs.com/drugs-780/cheap-viagra.html cheap viagra
24.155.116.* 于 2007-07-09 11:41:19发表:
http://www.freewebs.com/cash-862/instant-cash-advance.html instant cash advance instant cash advance cheap hydrocodone http://ss3054.k12.sd.us/_disc1/0000004d.htm cheap hydrocodone buy tramadol http://www.freewebs.com/drugs-79/buy-tramadol.html buy tramadol online regola baccarat regola baccarat http://www.freewebs.com/poker-207/baccarat-9.html cheap soma soma http://www.freewebs.com/drugs-473/soma-2.html
218.48.120.* 于 2007-07-09 11:37:20发表:
http://www.freewebs.com/cash-920/cash-advance-portland-oregon.html cash advance portland oregon cash advance portland oregon viagra http://www.bioyma.com/_truehearts/_disc1/000000bf.htm viagra payroll cash advance http://www.freewebs.com/cash-640/payroll-cash-advance.html payroll cash advance http://www.freewebs.com/ringtone-510/ringtones-11.html free ringtone nextel ringtones craps online http://www.freewebs.com/casino-418/craps-8.html regola crap
210.175.245.* 于 2007-07-09 11:37:17发表:
http://www.freewebs.com/cash-920/cash-advance-portland-oregon.html cash advance portland oregon cash advance portland oregon viagra http://www.bioyma.com/_truehearts/_disc1/000000bf.htm viagra payroll cash advance http://www.freewebs.com/cash-640/payroll-cash-advance.html payroll cash advance http://www.freewebs.com/ringtone-510/ringtones-11.html free ringtone nextel ringtones craps online http://www.freewebs.com/casino-418/craps-8.html regola crap
0.0.0.* 于 2007-07-09 11:34:55发表:
stanze di gioco gioco gratuito http://www.freewebs.com/poker-806/gioco-8.html http://www.freewebs.com/ringtone-540/free-ringtones-12.html 100 free ringtones free motorola ringtones ringtones ringtone http://www.freewebs.com/ringtone-595/ringtones-14.html buy phentermine http://www.freewebs.com/drugs-705/buy-phentermine-2.html buy phentermine buy ambien http://www.freewebs.com/drugs-375/buy-ambien-2.html buy ambien online
201.17.74.* 于 2007-07-09 10:31:46发表:
http://www.freewebs.com/cash-316/no-faxing-cash-advance.html no faxing cash advance no faxing cash advance fast cash advance fast cash advance http://www.freewebs.com/cash-496/fast-cash-advance.html http://www.freewebs.com/drugs-803/cheap-phentermine-2.html cheap phentermine cheap phentermine cheap vigrx http://www.freewebs.com/drugs-259/cheap-vigrx-2.html cheap vigrx cheap tramadol cheap tramadol http://www.freewebs.com/drugs-780/cheap-tramadol-2.html
24.12.225.* 于 2007-07-09 10:18:03发表:
cash advance loan cash advance loan http://www.freewebs.com/cash-177/cash-advance-loan.html cheap cialis http://www.freewebs.com/drugs-989/cheap-cialis-2.html cheap cialis cash advance detroit cash advance detroit http://www.freewebs.com/cash-640/cash-advance-detroit.html cheap soma http://www.freewebs.com/drugs-960/cheap-soma.html cheap soma http://www.azodchat.com/freshwaterclassifieds/_disc24/0000056e.htm meridia meridia
124.101.251.* 于 2007-07-09 10:15:33发表:
cash advance austin cash advance austin http://www.freewebs.com/cash-862/cash-advance-austin.html http://www.freewebs.com/cash-920/fast-cash-advance.html fast cash advance fast cash advance cash advance new york cash advance new york http://www.freewebs.com/cash-862/cash-advance-new-york.html cash advance minneapolis cash advance minneapolis http://www.freewebs.com/cash-862/cash-advance-minneapolis.html http://www.westofthejordan.com/_disc1/0000014a.htm food and drug administration food and drug administration
67.190.51.* 于 2007-07-09 09:30:46发表:
online casino poker poker in linea http://www.freewebs.com/poker-191/poker-6.html buy carisoprodol online buy carisoprodol http://www.freewebs.com/drugs-989/carisoprodol-2.html hoodia and phentermine hoodia and phentermine http://www.aterhamtning.se/_disc9/00007000.htm cash advance loan illinois http://www.freewebs.com/cash-496/cash-advance-loan-illinois.html cash advance loan illinois casino slots internet slot machine http://www.freewebs.com/casino-228/slots-6.html
0.0.0.* 于 2007-07-09 09:23:54发表:
buy carisoprodol online carisoprodol http://www.freewebs.com/drugs-112/carisoprodol-2.html cheap tramadol cheap tramadol http://www.freewebs.com/drugs-375/cheap-tramadol-2.html drug war drug war http://www.kawiswaradharma.org/forum/000000d1.htm cash advance boston cash advance boston http://www.freewebs.com/cash-127/cash-advance-boston.html cialis cialis http://www.kawiswaradharma.org/forum/000000ce.htm
220.135.8.* 于 2007-07-09 09:18:08发表:
http://www.freewebs.com/casino-591/casino-game-3.html giochi casino casino gioca http://www.freewebs.com/cash-41/online-cash-advance.html online cash advance online cash advance casino slot online slots http://www.freewebs.com/casino-834/slots-2.html advance america cash advance http://www.freewebs.com/cash-892/advance-america-cash-advance.html advance america cash advance vioxx lawyer vioxx lawyer http://amitechnologies-inc.com/_cusudi/00000442.htm
72.181.231.* 于 2007-07-09 09:18:04发表:
http://www.freewebs.com/casino-591/casino-game-3.html giochi casino casino gioca http://www.freewebs.com/cash-41/online-cash-advance.html online cash advance online cash advance casino slot online slots http://www.freewebs.com/casino-834/slots-2.html advance america cash advance http://www.freewebs.com/cash-892/advance-america-cash-advance.html advance america cash advance vioxx lawyer vioxx lawyer http://amitechnologies-inc.com/_cusudi/00000442.htm
0.0.0.* 于 2007-07-09 09:11:07发表:
http://www.kityanpoetry.com/community/_disc7/0000117f.htm generic drug generic drug online payday cash advance http://www.freewebs.com/cash-862/online-payday-cash-advance.html online payday cash advance download giochi gioco online http://www.freewebs.com/poker-603/giochi-6.html online games giocare online http://www.freewebs.com/poker-207/giochi-2.html hoodia and phentermine hoodia and phentermine http://www.myhedo.com/General/0000007d.htm
71.228.249.* 于 2007-07-09 09:08:36发表:
free real ringtones free real ringtones http://www.freewebs.com/ringtone-136/free-ringtones-2.html cash advance minneapolis cash advance minneapolis http://www.freewebs.com/cash-640/cash-advance-minneapolis.html cialis buy cialis http://www.freewebs.com/drugs-591/cialis-2.html free virgin mobile ringtones http://www.freewebs.com/ringtone-595/free-ringtones-10.html free alltel ringtones cheap levitra cheap levitra http://www.freewebs.com/drugs-870/cheap-levitra-2.html
0.0.0.* 于 2007-07-09 09:06:52发表:
http://www.freewebs.com/drugs-803/penis-enlargement-2.html penis enlargement technique natural penis enlargement regola baccarat http://www.freewebs.com/poker-719/baccarat-7.html regole baccarat buy viagra http://www.freewebs.com/drugs-399/buy-viagra-2.html buy viagra online nextel ringtone ringtones http://www.freewebs.com/ringtone-920/ringtones-2.html cash advance boston cash advance boston http://www.freewebs.com/cash-838/cash-advance-boston.html
0.0.0.* 于 2007-07-09 09:03:31发表:
cash advance las vegas http://www.freewebs.com/cash-41/cash-advance-las-vegas.html cash advance las vegas hoodia diet pill http://www.dharmamemphis.com/_discussion002/000007c0.htm hoodia diet pill cash advance new york http://www.freewebs.com/cash-41/cash-advance-new-york.html cash advance new york poker games giocare poker http://www.freewebs.com/poker-719/poker-3.html cash advance credit card cash advance credit card http://www.freewebs.com/cash-838/cash-advance-credit-card.html
201.17.74.* 于 2007-07-09 08:41:01发表:
drug rehab program drug rehab program http://www.wildlocals.com/_disc1/000014d8.htm cheap levitra cheap levitra http://www.freewebs.com/drugs-591/cheap-levitra-2.html free t mobile ringtones free ringtones http://www.freewebs.com/ringtone-837/free-ringtones-14.html osco drug osco drug http://www.inbenidorm.com/classifieds/_disc9/00000032.htm buy viagra online http://www.freewebs.com/drugs-960/buy-viagra-2.html buy viagra online
69.137.238.* 于 2007-07-09 08:38:56发表:
http://www.bilbyorganics.com.au/_disc3/000001d0.htm buy soma buy soma casinos gratuiro http://www.freewebs.com/casino-606/casino-8.html casino italia http://www.freewebs.com/cash-838/cash-advance-riverside.html cash advance riverside cash advance riverside cash advance san antonio http://www.freewebs.com/cash-838/cash-advance-san-antonio.html cash advance san antonio http://www.freewebs.com/casino-985/blackjack-6.html internet blackjack online blackjack
0.0.0.* 于 2007-07-09 08:33:47发表:
buy tramadol online buy tramadol online http://www.kityanpoetry.com/community/_disc7/0000117e.htm giochi internet giochi internet http://www.freewebs.com/poker-989/giochi-7.html casinos games http://www.freewebs.com/casino-672/casino-game-1.html casino gioca cheap hydrocodone cheap hydrocodone http://www.doeverythingtoglorifygod.com/gg/000009ea.htm http://www.freewebs.com/poker-419/online-poker-6.html poker on line play poker online
67.163.252.* 于 2007-07-09 08:33:38发表:
buy tramadol online buy tramadol online http://www.kityanpoetry.com/community/_disc7/0000117e.htm giochi internet giochi internet http://www.freewebs.com/poker-989/giochi-7.html casinos games http://www.freewebs.com/casino-672/casino-game-1.html casino gioca cheap hydrocodone cheap hydrocodone http://www.doeverythingtoglorifygod.com/gg/000009ea.htm http://www.freewebs.com/poker-419/online-poker-6.html poker on line play poker online
72.224.107.* 于 2007-07-09 08:30:56发表:
http://www.freewebs.com/poker-719/video-poker-7.html online video poker online videopoker download free cingular ringtones free mobile phone ringtones http://www.freewebs.com/ringtone-540/free-ringtones-10.html fioricet http://www.freewebs.com/drugs-705/fioricet.html buy fioricet cash advance austin cash advance austin http://www.freewebs.com/cash-316/cash-advance-austin.html http://www.freewebs.com/cash-892/cash-advance-denver.html cash advance denver cash advance denver
124.101.251.* 于 2007-07-09 08:28:51发表:
cash advance chicago http://www.freewebs.com/cash-127/cash-advance-chicago.html cash advance chicago hydrocodone hydrocodone http://www.kentpullen.com/_disc1KentPullen/0000021a.htm soma carisoprodol http://www.freewebs.com/drugs-90/soma-2.html purchase soma internet videopoker internet video poker http://www.freewebs.com/poker-806/video-poker-4.html drug treatment center http://www.springgreen.com/_bboard/0000292a.htm drug treatment center
84.54.149.* 于 2007-07-09 08:27:49发表:
cash advance minneapolis cash advance minneapolis http://www.freewebs.com/cash-838/cash-advance-minneapolis.html http://www.freewebs.com/cash-640/magnum-cash-advance.html magnum cash advance magnum cash advance cingular ringtones black eyed pea ringtones http://www.freewebs.com/ringtone-837/ringtones-10.html discount drug http://www.chelonian.com/_disc1/000004e7.htm discount drug hydrocodone online http://www.aunttee.com/Entries/0000004c.htm hydrocodone online
195.73.99.* 于 2007-07-09 08:27:29发表:
cash advance baltimore http://www.freewebs.com/cash-838/cash-advance-baltimore.html cash advance baltimore vioxx lawyer vioxx lawyer http://www.usechemicalssafely.com/_disc1/000000cc.htm http://www.freewebs.com/cash-256/cash-advance-pennsylvania.html cash advance pennsylvania cash advance pennsylvania cash advance sacramento cash advance sacramento http://www.freewebs.com/cash-920/cash-advance-sacramento.html carisoprodol carisoprodol http://rover.vetmed.lsu.edu/SCAVMA/_disc2011/0000032e.htm
210.221.146.* 于 2007-07-09 08:21:32发表:
buy levitra buy levitra http://www.freewebs.com/drugs-112/buy-levitra.html http://www.audubon1977.com/reuniondisc/_reuniondisc/000002fc.htm levitra levitra http://www.freewebs.com/ringtone-287/free-ringtones-12.html free ringtones free ringtones http://www.freewebs.com/poker-734/poker-9.html gioco poker poker games http://www.freewebs.com/drugs-803/buy-soma-2.html buy soma buy soma
0.0.0.* 于 2007-07-09 08:21:30发表:
buy levitra buy levitra http://www.freewebs.com/drugs-112/buy-levitra.html http://www.audubon1977.com/reuniondisc/_reuniondisc/000002fc.htm levitra levitra http://www.freewebs.com/ringtone-287/free-ringtones-12.html free ringtones free ringtones http://www.freewebs.com/poker-734/poker-9.html gioco poker poker games http://www.freewebs.com/drugs-803/buy-soma-2.html buy soma buy soma
202.217.47.* 于 2007-07-09 08:17:59发表:
http://www.freewebs.com/cash-413/cash-advance-phoenix.html cash advance phoenix cash advance phoenix cash advance with savings account cash advance with savings account http://www.freewebs.com/cash-127/cash-advance-with-savings-account.html drug online http://www.johnburrowsproject.com/_kbas/00000100.htm drug online internet video poker internet video poker http://www.freewebs.com/poker-979/video-poker-5.html cash advance cincinnati cash advance cincinnati http://www.freewebs.com/cash-640/cash-advance-cincinnati.html
0.0.0.* 于 2007-07-09 08:17:08发表:
casinos casinos http://www.freewebs.com/casino-606/casino-4.html cash advance minneapolis cash advance minneapolis http://www.freewebs.com/cash-316/cash-advance-minneapolis.html http://www.freewebs.com/poker-656/poker-4.html stanze da poker stanze da poker cheap ambien http://www.freewebs.com/drugs-870/cheap-ambien-2.html cheap ambien drug store drug store http://www.copysoft.net/_disc1/00000f33.htm
12.181.67.* 于 2007-07-09 08:17:04发表:
http://www.freewebs.com/casino-672/craps-3.html strategia crap regola crap buy levitra buy levitra http://www.freewebs.com/drugs-322/buy-levitra.html phentermine phentermine http://pitcom.com/q&a/_q&aboard/00000b61.htm renova renova http://www.socialnetworkforseniors.com/Poetry/0000006a.htm http://www.troyh.com/Troysblog/0000006b.htm fioricet fioricet
71.94.84.* 于 2007-07-09 08:16:29发表:
vicodin vicodin http://www.mysharktank.com/discuss/_disc1/00000186.htm http://www.freewebs.com/poker-191/gioco-4.html stanze di gioco stanze di gioco buy soma buy soma http://ss3054.k12.sd.us/_disc1/0000004b.htm craps online http://www.freewebs.com/casino-837/craps-3.html strategia crap online roulette poker http://www.freewebs.com/casino-574/roulette-7.html roulette online