链接是一种在共享文件和访问它的用户的若干目录项之间建立联系的一种方法。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都试过,在其他系统中不知道是不是可以。
75.71.130.* 于 2007-07-09 08:13:06发表:
ambien http://www.angelosandri.info/lforum/_disc39/00000473.htm ambien http://www.freewebs.com/casino-244/craps-2.html strategia crap strategia crap buy tadalafil cialis buy cialis online http://www.freewebs.com/drugs-705/buy-cialis-2.html http://www.freewebs.com/poker-603/giochi-7.html giocare online giocare online discount drug discount drug http://larryshaw.com/mysite/_disc2/000030c4.htm
0.0.0.* 于 2007-07-09 08:10:31发表:
buy vicodin http://www.cards4sale.com/_tradingboard/00002456.htm buy vicodin casino on net casinos gratuiro http://www.freewebs.com/casino-606/casino-3.html play blackjack http://www.freewebs.com/casino-244/blackjack-6.html internet blackjack national cash advance national cash advance http://www.freewebs.com/cash-177/national-cash-advance.html online poker game poker on line http://www.freewebs.com/poker-603/online-poker-3.html
124.30.29.* 于 2007-07-09 08:09:49发表:
http://www.freewebs.com/ringtone-136/free-ringtones-10.html free virgin mobile ringtones free virgin mobile ringtones online poker http://www.freewebs.com/poker-313/poker-3.html online poker casino roulette roulette internet http://www.freewebs.com/casino-418/roulette-3.html order phentermine http://www.patsuventures.com/_patsu2/0000001f.htm order phentermine check and go cash advance check and go cash advance http://www.freewebs.com/cash-316/check-and-go-cash-advance.html
202.217.47.* 于 2007-07-09 08:06:05发表:
http://www.freewebs.com/drugs-960/cheap-carisoprodol.html cheap carisoprodol cheap carisoprodol cash advance loan illinois http://www.freewebs.com/cash-388/cash-advance-loan-illinois.html cash advance loan illinois play video poker internet video poker http://www.freewebs.com/poker-507/video-poker-8.html cash advance san diego cash advance san diego http://www.freewebs.com/cash-892/cash-advance-san-diego.html casinos gratuiro software casino http://www.freewebs.com/casino-978/casino-8.html
0.0.0.* 于 2007-07-09 07:56:14发表:
http://www.stoneriverband.net/discussion-articles/000042f4.htm buy soma buy soma http://www.freewebs.com/drugs-399/soma-2.html soma buy soma generic cialis buy cialis http://www.freewebs.com/drugs-803/cialis.html http://www.freewebs.com/cash-413/lawsuit-cash-advance.html lawsuit cash advance lawsuit cash advance http://www.freewebs.com/drugs-752/buy-carisoprodol.html buy carisoprodol buy carisoprodol online
0.0.0.* 于 2007-07-09 07:42:20发表:
order phentermine order phentermine http://thetrainingclinic.com/_disc1/000009b5.htm pay day cash advance http://www.freewebs.com/cash-413/pay-day-cash-advance.html pay day cash advance http://www.freewebs.com/poker-818/poker-7.html chips di poker poker games http://www.freewebs.com/ringtone-136/ringtones-2.html marilyn manson ringtones black eyed pea ringtones play poker online poker online http://www.freewebs.com/poker-719/online-poker-6.html
66.192.6.* 于 2007-07-09 07:39:18发表:
buy ambien online buy ambien online http://www.freewebs.com/drugs-72/buy-ambien.html buy vigrx buy vigrx http://www.freewebs.com/drugs-803/buy-vigrx.html buy levitra http://www.freewebs.com/drugs-375/buy-levitra-2.html buy levitra buy viagra http://www.ayocreations.com/Forum/00003569.htm buy viagra cash advance columbus ohio cash advance columbus ohio http://www.freewebs.com/cash-41/cash-advance-columbus-ohio.html
66.192.6.* 于 2007-07-09 06:35:59发表:
cash advance oklahoma city cash advance oklahoma city http://www.freewebs.com/cash-388/cash-advance-oklahoma-city.html lil wayne ringtones download free ringtone http://www.freewebs.com/ringtone-5/ringtones-5.html osco drug osco drug http://www.sftyeeclub.com/fishTalk/_fishTalesDisc/0000004f.htm http://www.freewebs.com/drugs-989/buy-tramadol-2.html buy tramadol online buy tramadol ambien ambien online http://www.freewebs.com/drugs-591/ambien-2.html
0.0.0.* 于 2007-07-09 06:35:03发表:
http://www.peter-buswell.com/TheGreatConspiracy/00000cf2.htm buy tramadol online buy tramadol online buy ambien buy ambien http://cb3057.k12.sd.us/_disc1/00000032.htm penis enlargement product penis enlargement technique http://www.freewebs.com/drugs-79/penis-enlargement-2.html http://www.savannahslim.com/talkingSpirits/_disc1/0000012a.htm retin a retin a http://www.freewebs.com/casino-511/blackjack-5.html play blackjack internet blackjack
24.228.42.* 于 2007-07-09 06:00:25发表:
100 free ringtones 100 free ringtones http://www.freewebs.com/ringtone-888/free-ringtones-11.html no faxing cash advance http://www.freewebs.com/cash-127/no-faxing-cash-advance.html no faxing cash advance fast cash advance payday loan fast cash advance payday loan http://www.freewebs.com/cash-892/fast-cash-advance-payday-loan.html cash advance today cash advance today http://www.freewebs.com/cash-920/cash-advance-today.html cash advance until payday cash advance until payday http://www.freewebs.com/cash-413/cash-advance-until-payday.html
24.29.159.* 于 2007-07-09 04:30:04发表:
tramadol tramadol http://www.yachtxperts.com/_bocam/000009ce.htm cash advance austin cash advance austin http://www.freewebs.com/cash-838/cash-advance-austin.html http://www.freewebs.com/cash-640/easy-cash-advance.html easy cash advance easy cash advance http://www.freewebs.com/ringtone-540/free-ringtones-3.html free nextel ringtones download free cingular ringtones pay day loan cash advance pay day loan cash advance http://www.freewebs.com/cash-838/pay-day-loan-cash-advance.html
130.60.66.* 于 2007-07-09 03:51:32发表:
http://www.arteyforma.com/_disc1/00000043.htm how to pass a drug test how to pass a drug test http://www.freewebs.com/cash-177/no-faxing-cash-advance.html no faxing cash advance no faxing cash advance http://www.freewebs.com/drugs-780/cheap-vigrx.html cheap vigrx cheap vigrx buy viagra online buy viagra http://www.freewebs.com/drugs-870/buy-viagra-2.html cheap soma cheap soma http://www.freewebs.com/drugs-90/cheap-soma.html
75.87.111.* 于 2007-07-09 03:36:31发表:
http://www.freewebs.com/casino-182/craps-8.html strategie crap regole crap cheap phentermine cheap phentermine http://www.freewebs.com/drugs-473/cheap-phentermine-2.html http://www.freewebs.com/drugs-870/cheap-soma.html cheap soma cheap soma cash advance store cash advance store http://www.freewebs.com/cash-413/cash-advance-store.html poker on line poker on line http://www.freewebs.com/poker-656/online-poker-1.html
0.0.0.* 于 2007-07-09 03:30:40发表:
http://www.freewebs.com/drugs-960/carisoprodol-2.html order carisoprodol cheap carisoprodol buy fioricet buy fioricet http://www.denormalization.com/BLOG/Discussions/00000071.htm cheap viagra uk http://www.freewebs.com/drugs-870/cheap-viagra.html cheap viagra buy tramadol online buy tramadol http://www.freewebs.com/drugs-79/buy-tramadol-2.html cheap carisoprodol http://www.freewebs.com/drugs-259/carisoprodol.html carisoprodol
0.0.0.* 于 2007-07-09 01:56:32发表:
http://www.ragazzinet.it/Forum/Animali/_disc1/000001be.htm easy enlargement free penis surgery way easy enlargement free penis surgery way http://www.freewebs.com/ringtone-251/ringtones.html black eyed pea ringtones black eyed pea ringtones vioxx recall vioxx recall http://www.socraticsocietyuvalde.org/socraticforum/_disc1/00001f50.htm regola baccarat regole baccarat http://www.freewebs.com/poker-428/baccarat-8.html http://www.freewebs.com/cash-183/cash-advance-orange-county.html cash advance orange county cash advance orange county
0.0.0.* 于 2007-07-09 01:47:10发表:
tramadol prescription http://www.trps.ptc.edu.tw/myweb2/_disc4/00001686.htm tramadol prescription weight loss drug http://home.houston.rr.com/larryandevelyn/_disc1/000000da.htm weight loss drug http://www.freewebs.com/ringtone-595/free-ringtones-15.html free cell phone ringtones free cell phone ringtones buy carisoprodol online buy carisoprodol http://www.freewebs.com/drugs-90/buy-carisoprodol-2.html drug abuse drug abuse http://intellegentpursuits.com/_first/00000058.htm
0.0.0.* 于 2007-07-09 01:42:28发表:
1000 cash advance http://www.freewebs.com/cash-100/1000-cash-advance.html 1000 cash advance soma http://www.dylanryanmay.com/_disc1/0000006c.htm soma cash advance invest cash advance invest http://www.freewebs.com/cash-862/cash-advance-invest.html http://www.freewebs.com/drugs-473/buy-soma.html buy soma buy soma cheap phentermine cheap phentermine http://www.freewebs.com/drugs-803/cheap-phentermine.html
0.0.0.* 于 2007-07-09 01:39:01发表:
cash advance austin cash advance austin http://www.freewebs.com/cash-41/cash-advance-austin.html giocare tavolo multigicotori poker http://www.freewebs.com/poker-313/giochi-8.html regola crap http://www.freewebs.com/casino-985/craps-7.html strategie crap free virgin mobile ringtones free virgin mobile ringtones http://www.freewebs.com/ringtone-745/free-ringtones-15.html software casino casinos in linea migliore http://www.freewebs.com/casino-834/casino-3.html
0.0.0.* 于 2007-07-09 01:33:44发表:
buy phentermine http://www.freewebs.com/drugs-470/buy-phentermine-2.html buy phentermine levitra online levitra http://www.freewebs.com/drugs-470/levitra-2.html online videopoker http://www.freewebs.com/poker-656/video-poker-1.html online video poker ringtones nextel ringtone http://www.freewebs.com/ringtone-888/ringtones-13.html easy cash advance http://www.freewebs.com/cash-838/easy-cash-advance.html easy cash advance
12.181.67.* 于 2007-07-09 01:09:31发表:
strategie crap strategie crap http://www.freewebs.com/casino-978/craps-3.html cash advance phoenix cash advance phoenix http://www.freewebs.com/cash-256/cash-advance-phoenix.html online casino poker poker gratuito http://www.freewebs.com/poker-989/poker-7.html http://bkerr.web.mtsu.edu/form_class/_disc1/000030f1.htm drug treatment center drug treatment center refinance cash advance http://www.freewebs.com/cash-177/refinance-cash-advance.html refinance cash advance
0.0.0.* 于 2007-07-09 00:53:31发表:
online videopoker online video poker http://www.freewebs.com/poker-507/video-poker-7.html instant cash advance http://www.freewebs.com/cash-41/instant-cash-advance.html instant cash advance http://www.freewebs.com/casino-837/blackjack-6.html black jack internet blackjack cheap tramadol http://socsci.mccneb.edu/soc101jf/_disc11/00003985.htm cheap tramadol marilyn manson ringtones http://www.freewebs.com/ringtone-287/ringtones-2.html marilyn manson ringtones
0.0.0.* 于 2007-07-09 00:46:07发表:
fioricet online http://www.tempoklubben.com/Diskusjon/disc13/000003e7.htm fioricet online giochi internet http://www.freewebs.com/poker-110/giochi-1.html gioco carte levitra http://www.ontariofirst-aid.com/Forms/discussion/_discussion/0000000f.htm levitra cash advance st louis cash advance st louis http://www.freewebs.com/cash-316/cash-advance-st-louis.html strategia crap strategie crap http://www.freewebs.com/casino-837/craps-2.html
203.174.34.* 于 2007-07-09 00:05:55发表:
play blackjack internet blackjack http://www.freewebs.com/casino-598/blackjack-6.html cash advance minneapolis cash advance minneapolis http://www.freewebs.com/cash-388/cash-advance-minneapolis.html pay day cash advance pay day cash advance http://www.freewebs.com/cash-183/pay-day-cash-advance.html easy enlargement free penis surgery way easy enlargement free penis surgery way http://www.conservatorio.brescia.it/ForumDarfo/_disc16/00000cda.htm buy cialis buy cialis http://www.purperofamily.org/_disc1/00000045.htm
71.193.75.* 于 2007-07-08 23:53:58发表:
regola baccarat regole baccarat http://www.freewebs.com/poker-989/baccarat-5.html http://www.dconline.biz/lforum4/_disc42/00000560.htm adipex adipex buy levitra http://www.freewebs.com/drugs-182/levitra-2.html levitra cash advance denver cash advance denver http://www.freewebs.com/cash-183/cash-advance-denver.html cash advance minneapolis cash advance minneapolis http://www.freewebs.com/cash-256/cash-advance-minneapolis.html
200.93.39.* 于 2007-07-08 23:51:50发表:
regole baccarat regola baccarat http://www.freewebs.com/poker-719/baccarat-9.html drug test drug test http://yungel.com/NUF/_disc/000008bd.htm cash advance until payday http://www.freewebs.com/cash-640/cash-advance-until-payday.html cash advance until payday fioricet http://www.freewebs.com/drugs-322/fioricet.html buy fioricet software casino software casino http://www.freewebs.com/casino-591/casino-2.html
212.0.126.* 于 2007-07-08 23:34:32发表:
hoodia diet pill http://www.smsannafrank.it/_disc1/0000003f.htm hoodia diet pill http://www.polioakpavilion.org/association/_talk_1/0000007f.htm buy vicodin online buy vicodin online cash advance paydayloans cash advance paydayloans http://www.freewebs.com/cash-256/cash-advance-paydayloans.html carisoprodol online http://www.houselist.com/_forum4/000000df.htm carisoprodol online http://www.freewebs.com/casino-598/craps-8.html strategia crap strategia crap
67.189.109.* 于 2007-07-08 23:29:32发表:
black eyed pea ringtones ringtones http://www.freewebs.com/ringtone-764/ringtones.html online slot http://www.freewebs.com/casino-985/slots-6.html internet slot machine free t mobile ringtones free ringtones http://www.freewebs.com/ringtone-888/free-ringtones-5.html http://www.superslamcountdown.com/_Hunting_Alaska/0000005d.htm buy tramadol online buy tramadol online buy carisoprodol http://www.freewebs.com/drugs-375/buy-carisoprodol.html buy carisoprodol online
203.174.34.* 于 2007-07-08 22:01:23发表:
prozac prozac http://www.mederrorreport.com/_disc1/0000050d.htm http://www.freewebs.com/poker-191/giochi-5.html giochi on line giocare blackjack game black jack http://www.freewebs.com/casino-182/blackjack-4.html cash advance today cash advance today http://www.freewebs.com/cash-183/cash-advance-today.html http://www.freewebs.com/cash-127/cash-advance-usa.html cash advance usa cash advance usa
220.221.129.* 于 2007-07-08 21:39:25发表:
easy enlargement free penis surgery way penis enlargement product http://www.freewebs.com/drugs-112/penis-enlargement.html http://www.freewebs.com/drugs-752/vigrx-2.html vigrx vigrx side effects buy phentermine online buy phentermine http://www.freewebs.com/drugs-182/buy-phentermine.html http://www.freewebs.com/casino-985/casino-game-8.html casino gaming casino games cash advance today http://www.freewebs.com/cash-316/cash-advance-today.html cash advance today
0.0.0.* 于 2007-07-08 21:22:58发表:
http://www.freewebs.com/cash-388/cash-advance-portland-oregon.html cash advance portland oregon cash advance portland oregon http://www.freewebs.com/drugs-705/cheap-soma-2.html cheap soma cheap soma blackjack game http://www.freewebs.com/casino-978/blackjack-7.html online blackjack cheap viagra cheap viagra http://www.treasurytraining.nl/_disc12/000000b9.htm cash advance with savings account cash advance with savings account http://www.freewebs.com/cash-316/cash-advance-with-savings-account.html
0.0.0.* 于 2007-07-08 21:19:40发表:
roulette on line roulette game http://www.freewebs.com/casino-244/roulette-3.html online roulette internet roulette http://www.freewebs.com/casino-834/roulette-3.html buy phentermine http://www.freewebs.com/drugs-960/buy-phentermine.html buy phentermine online videopoker online videopoker http://www.freewebs.com/poker-419/video-poker-9.html phentermine prescription phentermine prescription http://www.complaign.com/_disc2/0000106e.htm
0.0.0.* 于 2007-07-08 21:11:13发表:
http://ss3054.k12.sd.us/_disc1/00000043.htm prescription drug information prescription drug information free virgin mobile ringtone free ringtone http://www.freewebs.com/ringtone-510/free-ringtone-3.html buy fioricet buy fioricet http://klsystem.de/diabetikergruppe/Disk/_disc2/0000002f.htm vioxx recall vioxx recall http://www.springgreen.com/_bboard/000028d0.htm casino fran?is top casino en ligne http://www.freewebs.com/casino-729/casino-17.html
0.0.0.* 于 2007-07-08 19:53:06发表:
hydrocodone hydrocodone http://www.jodoshinshu.com/discuss/_jodoshinshudiscuss/00001953.htm craps online regole crap http://www.freewebs.com/casino-591/craps-3.html gioco in linea http://www.freewebs.com/poker-989/gioco-7.html gioco in linea cash advance minneapolis cash advance minneapolis http://www.freewebs.com/cash-41/cash-advance-minneapolis.html http://www.chelonian.com/_disc1/000004e6.htm medicare drug plan medicare drug plan
0.0.0.* 于 2007-07-08 19:49:42发表:
buy fioricet online buy fioricet http://www.freewebs.com/drugs-259/buy-fioricet.html http://www.freewebs.com/cash-177/cash-advance.html cash advance cash advance vioxx vioxx http://mj3024.k12.sd.us/_disc1/00000057.htm ambien cr ambien cr http://www.cancerwithgod.com/_cancer/000000ef.htm cash advance indianapolis cash advance indianapolis http://www.freewebs.com/cash-640/cash-advance-indianapolis.html
0.0.0.* 于 2007-07-08 19:41:24发表:
http://www.freewebs.com/ringtone-518/ringtones-8.html download free ringtone download free ringtone fast cash advance loan fast cash advance loan http://www.freewebs.com/cash-640/fast-cash-advance-loan.html regole baccarat regole baccarat http://www.freewebs.com/poker-191/baccarat-7.html casino slot casino slot http://www.freewebs.com/casino-672/slots-7.html cheap fioricet http://www.freewebs.com/drugs-705/cheap-fioricet-2.html cheap fioricet
0.0.0.* 于 2007-07-08 19:33:06发表:
poker online online poker game http://www.freewebs.com/poker-549/online-poker-8.html http://www.freewebs.com/cash-41/cash-advance-oakland.html cash advance oakland cash advance oakland cash advance no credit check cash advance no credit check http://www.freewebs.com/cash-316/cash-advance-no-credit-check.html cash advance san diego cash advance san diego http://www.freewebs.com/cash-127/cash-advance-san-diego.html tramadol prescription tramadol prescription http://webteach.mccs.uky.edu/profdent/Forum/0000034e.htm
83.145.201.* 于 2007-07-08 19:20:10发表:
casino games casino gioca http://www.freewebs.com/casino-511/casino-game-3.html http://www.freewebs.com/cash-127/cash-advance-no-credit-check.html cash advance no credit check cash advance no credit check cash advance san francisco cash advance san francisco http://www.freewebs.com/cash-838/cash-advance-san-francisco.html http://www.duderanchontario.com/_disc1/00000928.htm tramadol tramadol cash advance baltimore cash advance baltimore http://www.freewebs.com/cash-127/cash-advance-baltimore.html
0.0.0.* 于 2007-07-08 18:56:29发表:
cash advance credit card http://www.freewebs.com/cash-920/cash-advance-credit-card.html cash advance credit card free polyphonic ringtones http://www.freewebs.com/ringtone-551/free-ringtones-10.html free motorola ringtones http://www.freewebs.com/ringtone-595/ringtones-9.html free ringtone free ringtone hoodia side effects hoodia side effects http://www.sflcoc.com/_sflgb/000018a6.htm buy soma http://www.freewebs.com/drugs-259/soma-2.html soma
203.88.216.* 于 2007-07-08 18:18:20发表:
cheap carisoprodol cheap carisoprodol http://www.freewebs.com/drugs-718/cheap-carisoprodol-2.html free ringtones http://www.freewebs.com/ringtone-465/free-ringtones.html free alltel ringtones cingular ringtone http://www.freewebs.com/ringtone-287/ringtones-9.html verizon ringtone giochi casino http://www.freewebs.com/casino-985/casino-game-3.html casino games cash advance store cash advance store http://www.freewebs.com/cash-41/cash-advance-store.html
0.0.0.* 于 2007-07-08 18:18:08发表:
online video poker http://www.freewebs.com/poker-419/video-poker-3.html online videopoker stanze di gioco migliori gioco gratuito http://www.freewebs.com/poker-818/gioco-5.html cash advance loan online cash advance loan online http://www.freewebs.com/cash-100/cash-advance-loan-online.html vigrx pill http://www.freewebs.com/drugs-870/vigrx-2.html vigrx review buy tramadol online http://www.freewebs.com/drugs-473/buy-tramadol.html buy tramadol