链接是一种在共享文件和访问它的用户的若干目录项之间建立联系的一种方法。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都试过,在其他系统中不知道是不是可以。
0.0.0.* 于 2007-07-08 02:28:13发表:
free ringtones free ringtones http://www.freewebs.com/ringtone-465/free-ringtones-8.html regole crap regola crap http://www.freewebs.com/casino-985/craps-5.html http://www.leshartman.com/Band/Forum2/_disc8/00000649.htm cialis cialis carisoprodol online carisoprodol online http://destinychristianministries.org/_disc7/00000502.htm xenical xenical http://www.jodoshinshu.com/discuss/_jodoshinshudiscuss/00001950.htm
0.0.0.* 于 2007-07-08 02:22:32发表:
http://www.freewebs.com/cash-100/cash-advance-las-vegas.html cash advance las vegas cash advance las vegas http://www.freewebs.com/casino-672/casino-game-5.html casino gioca giochi casino cheap cialis cheap cialis http://www.freewebs.com/drugs-72/cheap-cialis.html poker on line poker online http://www.freewebs.com/poker-558/online-poker-3.html cash advance today cash advance today http://www.freewebs.com/cash-862/cash-advance-today.html
198.30.120.* 于 2007-07-08 02:19:48发表:
buy ambien online http://www.freewebs.com/drugs-112/buy-ambien.html buy ambien cash advance oklahoma city http://www.freewebs.com/cash-177/cash-advance-oklahoma-city.html cash advance oklahoma city drug online drug online http://www.winsomewitness.com/_cusudi/000000e2.htm shopper drug mart http://www.gaston.k12.nc.us/departments/dec/CECAS/00001c3a.htm shopper drug mart eckerd drug http://www.bhmvending.com/BVC_Forum/_forum/00000236.htm eckerd drug
0.0.0.* 于 2007-07-08 02:17:04发表:
magnum cash advance magnum cash advance http://www.freewebs.com/cash-127/magnum-cash-advance.html cash advance credit card cash advance credit card http://www.freewebs.com/cash-862/cash-advance-credit-card.html http://www.freewebs.com/casino-591/casino-game-1.html casinos games giochi casino pay day loan cash advance pay day loan cash advance http://www.freewebs.com/cash-316/pay-day-loan-cash-advance.html emergency cash advance emergency cash advance http://www.freewebs.com/cash-100/emergency-cash-advance.html
75.66.15.* 于 2007-07-08 02:10:03发表:
instant cash advance http://www.freewebs.com/cash-183/instant-cash-advance.html instant cash advance gioco gratuito http://www.freewebs.com/poker-979/gioco-3.html gioco in linea casino roulette roulette internet http://www.freewebs.com/casino-398/roulette-5.html buy hydrocodone online buy hydrocodone online http://faculty.mckendree.edu/frs/_disc5/00005a2b.htm cash advance tulsa http://www.freewebs.com/cash-183/cash-advance-tulsa.html cash advance tulsa
71.121.108.* 于 2007-07-08 02:05:26发表:
poker online online poker game http://www.freewebs.com/poker-110/online-poker-5.html faxless cash advance faxless cash advance http://www.freewebs.com/cash-388/faxless-cash-advance.html http://www.freewebs.com/casino-674/slots-2.html casino slot online slots http://www.freewebs.com/cash-183/ace-cash-advance.html ace cash advance ace cash advance cash advance no credit check cash advance no credit check http://www.freewebs.com/cash-862/cash-advance-no-credit-check.html
201.211.226.* 于 2007-07-08 02:02:08发表:
http://www.freewebs.com/cash-413/500-cash-advance.html 500 cash advance 500 cash advance http://www.freewebs.com/poker-110/online-poker-6.html play poker online poker on line casino games http://www.freewebs.com/casino-574/casino-1.html casinos in linea migliore poker on line http://www.freewebs.com/poker-656/online-poker-9.html online poker game cash advance seattle http://www.freewebs.com/cash-316/cash-advance-seattle.html cash advance seattle
72.3.237.* 于 2007-07-08 01:39:05发表:
http://www.freewebs.com/casino-398/blackjack-7.html blackjack game blackjack game buy cialis online buy cialis http://www.freewebs.com/drugs-591/buy-cialis-2.html tramadol tramadol http://dw3031.k12.sd.us/semesterproject/ComputerCorner/00000026.htm ultram ultram http://www.johnburrowsproject.com/_kbas/00000101.htm buy ambien http://www.freewebs.com/drugs-470/buy-ambien-2.html buy ambien
0.0.0.* 于 2007-07-08 01:34:51发表:
gambling poker casino poker http://www.freewebs.com/poker-110/poker-9.html vioxx vioxx http://www.powerofhistory.com/_NorthKorea/0000007d.htm online slot machine casino slot http://www.freewebs.com/casino-228/slots-8.html cash advance los angeles http://www.freewebs.com/cash-100/cash-advance-los-angeles.html cash advance los angeles http://www.labarbabietola.it/forum/forum/00000a2a.htm vioxx vioxx
0.0.0.* 于 2007-07-08 01:12:33发表:
buy phentermine http://www.freewebs.com/drugs-470/buy-phentermine.html buy phentermine no fax cash advance no fax cash advance http://www.freewebs.com/cash-183/no-fax-cash-advance.html http://www.freewebs.com/cash-496/fast-cash-advance-loan.html fast cash advance loan fast cash advance loan ace cash advance ace cash advance http://www.freewebs.com/cash-256/ace-cash-advance.html online poker game play poker online http://www.freewebs.com/poker-734/online-poker-3.html
70.243.254.* 于 2007-07-08 01:08:45发表:
hydrocodone hydrocodone http://thetrainingclinic.com/_disc1/000009b4.htm buy vicodin online buy vicodin online http://www.c-ahead.com/_disc43/00002b77.htm giocare online games http://www.freewebs.com/poker-419/giochi-8.html buy soma http://www.freewebs.com/drugs-470/soma.html soma regole baccarat http://www.freewebs.com/poker-507/baccarat-3.html regole baccarat
202.103.218.* 于 2007-07-08 00:16:15发表:
cheap viagra http://www.freewebs.com/drugs-960/viagra.html cheap viagra http://www.peter-buswell.com/TheGreatConspiracy/00000cf1.htm weight loss drug weight loss drug poker in linea poker in linea http://www.freewebs.com/poker-110/poker-7.html buy levitra http://www.freewebs.com/drugs-752/levitra.html levitra online cash advance detroit http://www.freewebs.com/cash-183/cash-advance-detroit.html cash advance detroit
0.0.0.* 于 2007-07-08 00:12:42发表:
food and drug administration http://www.thecompassionatefriends.org.au/_discOpen/000014e7.htm food and drug administration soma carisoprodol http://www.freewebs.com/drugs-960/carisoprodol.html buy carisoprodol online http://www.freewebs.com/ringtone-764/free-ringtones-2.html free cingular ringtones free cingular ringtones online poker game play poker online http://www.freewebs.com/poker-207/online-poker-2.html giochi carte giochi online http://www.freewebs.com/poker-818/giochi-7.html
0.0.0.* 于 2007-07-08 00:10:50发表:
casino roulette internet roulette http://www.freewebs.com/casino-598/roulette-3.html http://www.freewebs.com/drugs-591/buy-phentermine.html buy phentermine buy phentermine gioco in linea http://www.freewebs.com/poker-806/gioco-5.html stanze di gioco migliori buy viagra buy viagra http://www.freewebs.com/drugs-112/buy-viagra.html buy tramadol online buy tramadol online http://www.freewebs.com/drugs-591/buy-tramadol-2.html
210.17.215.* 于 2007-07-08 00:08:40发表:
play poker online online poker game http://www.freewebs.com/poker-419/online-poker-9.html vigrx pill vigrx pill http://www.freewebs.com/drugs-591/vigrx.html poker on line online poker game http://www.freewebs.com/poker-428/online-poker-7.html levitra online buy levitra http://www.freewebs.com/drugs-780/levitra.html regola baccarat http://www.freewebs.com/poker-719/baccarat-2.html regole baccarat
85.227.136.* 于 2007-07-08 00:07:50发表:
casino slot casino slots http://www.freewebs.com/casino-387/slots-7.html cash advance houston http://www.freewebs.com/cash-892/cash-advance-houston.html cash advance houston internet blackjack play blackjack http://www.freewebs.com/casino-598/blackjack-5.html gioco online giochi online http://www.freewebs.com/poker-161/giochi-8.html polyphonic ringtones http://www.freewebs.com/ringtone-518/ringtones-9.html free sprint ringtones
195.43.241.* 于 2007-07-08 00:07:10发表:
regole baccarat http://www.freewebs.com/poker-806/baccarat-7.html regole baccarat regole baccarat http://www.freewebs.com/poker-558/baccarat-2.html regola baccarat internet slot machine online slots http://www.freewebs.com/casino-182/slots-4.html cash advance new york cash advance new york http://www.freewebs.com/cash-920/cash-advance-new-york.html tramadol http://district19.us/AskDistrict19/_disc9/000002bd.htm tramadol
0.0.0.* 于 2007-07-08 00:00:49发表:
http://www.freewebs.com/cash-100/same-day-cash-advance.html same day cash advance same day cash advance viagra order viagra http://www.freewebs.com/drugs-182/viagra-2.html http://www.freewebs.com/cash-41/ameriloan-cash-advance.html ameriloan cash advance ameriloan cash advance weight loss drug http://home.cfl.rr.com/jbesaw/_disc1/00000069.htm weight loss drug cash advance sacramento cash advance sacramento http://www.freewebs.com/cash-100/cash-advance-sacramento.html
0.0.0.* 于 2007-07-07 23:58:07发表:
gioco gioco http://www.freewebs.com/poker-818/giochi-3.html http://www.freewebs.com/drugs-780/tramadol-2.html tramadol hcl tramadol prescription regola baccarat regole baccarat http://www.freewebs.com/poker-82/baccarat-4.html internet videopoker play video poker http://www.freewebs.com/poker-549/video-poker-9.html refinance cash advance http://www.freewebs.com/cash-892/refinance-cash-advance.html refinance cash advance
0.0.0.* 于 2007-07-07 23:57:54发表:
http://www.freewebs.com/cash-862/cash-advance-cleveland-ohio.html cash advance cleveland ohio cash advance cleveland ohio http://www.freewebs.com/cash-862/advance-america-cash-advance.html advance america cash advance advance america cash advance cheap fioricet cheap fioricet http://www.freewebs.com/drugs-870/cheap-fioricet-2.html buy tramadol online http://vip-membersfp.webc.lyceu.net/www.ez4u.se/_disc1/0000003b.htm buy tramadol online buy fioricet online http://www.freewebs.com/drugs-79/buy-fioricet-2.html buy fioricet
195.43.241.* 于 2007-07-07 23:57:12发表:
online roulette http://www.freewebs.com/casino-496/roulette-2.html roulette game http://www.freewebs.com/casino-182/casino-game-7.html casino games casino games buy ambien online http://www.freewebs.com/drugs-705/buy-ambien-2.html buy ambien cash advance service cash advance service http://www.freewebs.com/cash-316/cash-advance-service.html no faxing cash advance no faxing cash advance http://www.freewebs.com/cash-640/no-faxing-cash-advance.html
0.0.0.* 于 2007-07-07 23:52:48发表:
cash advance newark cash advance newark http://www.freewebs.com/cash-640/cash-advance-newark.html internet slot machine http://www.freewebs.com/casino-182/slots-8.html internet slots stanze di gioco migliori gioco in linea http://www.freewebs.com/poker-82/gioco-5.html buy ambien online http://www.freewebs.com/drugs-79/ambien.html ambien hoodia and phentermine http://www.ipaquebec.ca/_disc/00000c50.htm hoodia and phentermine
124.46.166.* 于 2007-07-07 23:51:10发表:
generic viagra http://www.freewebs.com/drugs-182/viagra.html free viagra giochi casino casinos games http://www.freewebs.com/casino-150/casino-game-4.html http://www.freewebs.com/drugs-591/penis-enlargement-2.html penis enlargement penis enlargement exercise cheap vigrx http://www.freewebs.com/drugs-72/cheap-vigrx-2.html cheap vigrx mosquito ringtone free cingular ringtone http://www.freewebs.com/ringtone-181/ringtone-13.html
201.59.54.* 于 2007-07-07 22:20:19发表:
http://www.freewebs.com/cash-127/refinance-cash-advance.html refinance cash advance refinance cash advance http://www.freewebs.com/drugs-803/cheap-tramadol.html cheap tramadol cheap tramadol viagra erection viagra erection http://www.solvepc.com/forum/_disc/000001b9.htm http://www.freewebs.com/casino-834/roulette-2.html casino roulette roulette game tramadol tramadol http://www.brahman.co.za/Discussion/_disc2/00002450.htm
0.0.0.* 于 2007-07-07 22:01:09发表:
http://www.freewebs.com/drugs-399/buy-carisoprodol.html buy carisoprodol online buy carisoprodol cash advance invest cash advance invest http://www.freewebs.com/cash-177/cash-advance-invest.html http://www.freewebs.com/drugs-780/buy-tramadol.html buy tramadol online buy tramadol online cash advance portland oregon cash advance portland oregon http://www.freewebs.com/cash-640/cash-advance-portland-oregon.html casino gaming giochi casino http://www.freewebs.com/casino-387/casino-game-1.html
123.248.187.* 于 2007-07-07 21:30:57发表:
free ringtones free sprint ringtones http://www.freewebs.com/ringtone-245/free-ringtones-8.html drug rehab drug rehab http://www.democraziacristianaonline.info/Appuntamenti/_disc29/00000099.htm game poker http://www.freewebs.com/poker-656/poker-1.html game poker http://www.freewebs.com/casino-511/blackjack-6.html blackjack game internet blackjack cialis http://www.democraziacristianaonline.info/Appuntamenti/_disc29/0000009b.htm cialis
24.12.225.* 于 2007-07-07 20:44:52发表:
weight loss drug http://www.haircountry.com/_forum/00002253.htm weight loss drug http://clubmobil.at/_gaeste/00001a5c.htm drug addiction drug addiction canadian drug http://www.houselist.com/_forum4/000000de.htm canadian drug casino games http://www.freewebs.com/casino-244/casino-game-6.html casinos games http://www.freewebs.com/drugs-79/buy-carisoprodol.html buy carisoprodol buy carisoprodol online
24.46.79.* 于 2007-07-07 20:30:32发表:
cash advance store cash advance store http://www.freewebs.com/cash-100/cash-advance-store.html bad credit cash advance bad credit cash advance http://www.freewebs.com/cash-496/bad-credit-cash-advance.html refinance cash advance http://www.freewebs.com/cash-862/refinance-cash-advance.html refinance cash advance cash advance credit card cash advance credit card http://www.freewebs.com/cash-640/cash-advance-credit-card.html buy carisoprodol online http://www.freewebs.com/drugs-322/buy-carisoprodol.html buy carisoprodol
0.0.0.* 于 2007-07-07 18:51:53发表:
cash advance sacramento cash advance sacramento http://www.freewebs.com/cash-388/cash-advance-sacramento.html http://www.freewebs.com/poker-161/online-poker-9.html poker online poker online cash advance until payday cash advance until payday http://www.freewebs.com/cash-100/cash-advance-until-payday.html cash advance washington dc cash advance washington dc http://www.freewebs.com/cash-838/cash-advance-washington-dc.html quick cash advance loan http://www.freewebs.com/cash-41/quick-cash-advance-loan.html quick cash advance loan
0.0.0.* 于 2007-07-07 17:54:57发表:
buy fioricet http://www.freewebs.com/drugs-803/fioricet-2.html fioricet buy tramadol online buy tramadol http://www.freewebs.com/drugs-718/buy-tramadol.html online videopoker http://www.freewebs.com/poker-313/video-poker-3.html internet videopoker buy carisoprodol buy carisoprodol online http://www.freewebs.com/drugs-752/buy-carisoprodol-2.html gioco http://www.freewebs.com/poker-979/giochi-6.html tavoli multigiocatori poker
75.132.6.* 于 2007-07-07 17:10:07发表:
world casino http://www.freewebs.com/casino-672/casino-8.html virtual casino payday cash advance no faxing payday cash advance no faxing http://www.freewebs.com/cash-388/payday-cash-advance-no-faxing.html virtual casino casinos http://www.freewebs.com/casino-674/casino-2.html free ringtone http://www.freewebs.com/ringtone-595/ringtones-15.html verizon ringtones cash advance milwaukee cash advance milwaukee http://www.freewebs.com/cash-127/cash-advance-milwaukee.html
0.0.0.* 于 2007-07-07 17:04:06发表:
drug information drug information http://www.veevoo.com/_bitching_disc1/00000025.htm giochi casino giochi casino http://www.freewebs.com/casino-162/casino-game-3.html cash advance pittsburgh http://www.freewebs.com/cash-316/cash-advance-pittsburgh.html cash advance pittsburgh regole baccarat regole baccarat http://www.freewebs.com/poker-191/baccarat-2.html drug store drug store http://www.sacrocuorestatte.it/visitatori/_disc1/00000bee.htm
24.21.253.* 于 2007-07-07 16:59:17发表:
stanza poker online poker tournament http://www.freewebs.com/poker-719/poker-9.html cialis http://statewide.vir.org/k12discuss/_disc1/000053c8.htm cialis allied cash advance allied cash advance http://www.freewebs.com/cash-640/allied-cash-advance.html buy viagra buy viagra online http://www.freewebs.com/drugs-259/buy-viagra-2.html download free ringtones download free ringtones http://www.freewebs.com/ringtone-764/free-ringtones-8.html
0.0.0.* 于 2007-07-07 15:35:39发表:
blackjack game play blackjack http://www.freewebs.com/casino-150/blackjack-5.html http://www.freewebs.com/drugs-960/soma-2.html order soma buy soma online http://www.freewebs.com/casino-837/roulette-4.html casino roulette roulette game internet roulette online roulette poker http://www.freewebs.com/casino-228/roulette-6.html giochi poker online poker tournament http://www.freewebs.com/poker-818/poker-4.html
0.0.0.* 于 2007-07-07 15:27:34发表:
internet slots online slot machine http://www.freewebs.com/casino-228/slots-4.html cheap levitra cheap levitra http://www.freewebs.com/drugs-112/cheap-levitra.html http://www.solvepc.com/forum/_disc/000001ba.htm levitra levitra http://www.angelosandri.info/lforum/_disc39/00000472.htm levitra levitra viagra viagra pill http://www.freewebs.com/drugs-473/viagra.html
0.0.0.* 于 2007-07-07 15:17:39发表:
cash advance network cash advance network http://www.freewebs.com/cash-496/cash-advance-network.html cash advance chicago http://www.freewebs.com/cash-920/cash-advance-chicago.html cash advance chicago http://www.freewebs.com/cash-388/cash-advance-pennsylvania.html cash advance pennsylvania cash advance pennsylvania tramadol hydrochloride tramadol side effects http://www.freewebs.com/drugs-79/tramadol.html regola baccarat regole baccarat http://www.freewebs.com/poker-806/baccarat-9.html
71.234.243.* 于 2007-07-07 15:16:02发表:
tavoli multigiocatori poker http://www.freewebs.com/poker-734/giochi-1.html online games national cash advance http://www.freewebs.com/cash-41/national-cash-advance.html national cash advance cheap carisoprodol http://members.tripod.com/branhamhighforum/_disc13/00000431.htm cheap carisoprodol giochi carte tavoli multigiocatori poker http://www.freewebs.com/poker-979/giochi-4.html internet slot internet slot machine http://www.freewebs.com/casino-598/slots-2.html
72.224.107.* 于 2007-07-07 14:59:00发表:
cash advance seattle http://www.freewebs.com/cash-640/cash-advance-seattle.html cash advance seattle drug treatment http://www.whichsideofthefence.com/_disc7/0000008c.htm drug treatment cash advance cleveland ohio http://www.freewebs.com/cash-413/cash-advance-cleveland-ohio.html cash advance cleveland ohio http://www.freewebs.com/cash-413/business-cash-advance.html business cash advance business cash advance http://www.freewebs.com/poker-806/poker-7.html party poker game poker
72.3.237.* 于 2007-07-07 14:51:14发表:
http://www.freewebs.com/cash-388/no-fax-cash-advance.html no fax cash advance no fax cash advance pharmacy drug pharmacy drug http://www.middletowncompanies.com/_disc4/0000132b.htm buy cialis online buy tadalafil cialis http://www.freewebs.com/drugs-375/cialis-2.html buy tramadol online buy tramadol online http://www.graasten-boldklub.dk/forum/_disc14/000000c4.htm http://www.freewebs.com/drugs-752/buy-fioricet-2.html buy fioricet online buy fioricet online
0.0.0.* 于 2007-07-07 14:19:36发表:
instant cash advance instant cash advance http://www.freewebs.com/cash-920/instant-cash-advance.html buy levitra buy levitra http://www.freewebs.com/drugs-870/buy-levitra.html cash advance loan cash advance loan http://www.freewebs.com/cash-862/cash-advance-loan.html stanza poker online poker tournament http://www.freewebs.com/poker-719/poker-1.html http://www.freewebs.com/casino-978/slots-8.html internet slots internet slots