国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統(tǒng) > Unix > 正文

UNIX常用命令

2024-06-28 13:23:19
字體:
供稿:網(wǎng)友
UNIX常用命令

UNIX常用命令

UnixDevelopmentEnvironment

lTheBasicKnowleage

lTheGeneralCommand

lUnixShell

lMakeFile

TheBasicKnowledge

Unix/linuxsystemsaremulti-userandmulti-tasking

lHavemultipleusersonthesamesystem

lRunmultiplePRograms,seeminglysimultaneously

lMaintainpermissionsthatdeterminewhichusershaveaccesstowhickfilesandprograms

lRegulatetheamountofdiskspaceeachusercanuse

lStoreuser-specificsettingsin“hidden”file

LoggingIn

lWhenyoufirstconnecttooneoftheUnixcomputersyouwillseetheprompt:

lLogin:

Atthelogin:prompt,typeinyourusernamePassWord

Onceyouhavetypedinyourusernameyouwillbepromptedtotypeinyourpassword

InitializationFiles

WhenyoulogintheUnix/Linuxloginprogramfinally,startsupacommand“shell”

UsersdonotdealwiththeOperatingsystemdirectly.MostofyourinteractionwithaUnixsystemtakesplaceinashell,aprogramthatisruneverytimeyoulogin,anddisplaysthe“$”prompt.Theshellisknownascommandinterpreter,yougiveitcommands,anditrunsthem.

Shell

lSh

lBourneShell

lKsh

lKornShell

lCsh

lCshellbasedonClanguage

lBash

lBornAgainShell

lTcsh

lanotherversionofCshell

UsingtheSystem

Finallyyouareloggedin!Youwillseeapromptlikeoneofthefollowing:

$/#

Justwaitingfoyoutotypesomething.Wewilluser$toindicatethecomputer’s“ready”prompt.

Okey,let’stryasimplecommand.

ls

lsistheprogramtolistfilesinadirectory.Justplainlswon’tlisthiddenfiles(fileswhosenamesstartwith``.’’,like.login).Nowtrytyping:

ls-a

pwd(printworkingdirectory)

Tofindoutwhichdirectoryyouarein,type:

pwd

Thiswillshowyouthefullpathtoyourcurrentworkingdirectory,relativetotherootdirectory(/).

Rm(removefilesordirectories)

Thecommandrmfilewillremovethespecifiedfile.

Someusefuloptionsforrminclude

rm-i(interactivemode-youwillbepromptedtocomfirmfiledeletion)

rm-f(forceremove-overridesinteractivemodeandremovesfilewithoutaprompt)

rm-r(recursive-removethecontentsofdirectoriesrecursively)

cp(copyfilesanddirectories)

Tocopyafile,do:

cpoldfilenamenewfilename

Ortocopyafiletoanewdirectory,whilekeepingtheoldfilenamedo:

cpfilename/directoryname/

Toensureyourdon’toverwriteanyexistingfilesyoucanusethe‘-i’option:

cp-ioldfilenamenewfilename

Thiscommandwillpromptyoutoconfirmifthereisalreadyafilewiththenamenewfilename.

mv(movefiles)

Thiscommandallowsyoutorenameafileasin:

mvoldfilenamenewfilename

Ortomoveafiletoanewdirectory:

mvfilenamedirectoryname/

Aswithcp,itisagoodideatousethe‘-i’optionwithmv,soyoudon’tmistakenlyoverwriteyourexistingfiles.

Thespecialdirectory

Youmayhavenoticedwhenyoutypedls–athattherewerelistingsdot(.)anddot-dot(..).Theserepresentyourcurrentworkingdirectory(.)andit’sparentdirectory(..).

Forexample,typing

cd..

cd.

cp/vol/examples/tutorial/science.txt.

cd~willalwaysbringyoubacktoyourhomedirectory.

cd~/homeworkwillbringyoutothe‘homework’directory.

Thecharacter*iscalledawildcardandwillmatchagainstnoneofmorecharacter(s)inafileordirectoryname.

Forexample,ifyoutype

ls*h

Youshouldgetalistofallfilesanddirectoriesstartingwiththeletterh.

Similarlyifyoutype:

ls*.cpp

The?characterissimilartothe*character,exceptthat?willmatchexactlyonecharacter,Forexample:

ls?anwillmatch‘man’butnot‘stan’!

Displaythecontentsofafileonthescreen

clear(clearscreen)

Beforeyoustartthenextsection,youmayliketocleartheterminalwindowofthepreviouscommandssotheoutputofthefollowingcommandscanbeclearlyunderstood.

Attheprompt,type

clear

Thiswillclearalltextandleaveyouwiththe%promptatthetopofthewindow.

cat(concatenate)

Thecommandcatcanbeusedtodisplaythecontentsofafileonthescreen.Type:

catscience.txt

asyoucansee,thefileislongerthanthesizeofthewindow,soitscrollspastmakingitunreadable.

less

Thecommandlesswritesthecontentsofafilenotothescreenapageatatime,type:

lessscience.txt

Pressthe[space-bar]ifyouwanttoseeanotherpage,type[q]ifyouwanttoquitreading.

head

Theheadcommandwritesthefirsttenlinesofafiletothescreen.

Firstclearthescreenthentype

headscience.txt

tail

thetailcommandwritesthelasttenlinesofafiletothescreen.Clearthescreenandtype:

tailscience.txt

Searchingthecontentsofafile

Simplesearchingusingless

Usingless,youcansearchthoughatextfileforakeyword(pattern).Forexample,tosearchthroughscience.txtfortheword‘science’,type

lessscience.txt

Thenstillinless(i.e.don’tpress[q]toquit),typeaforwardslash[/]followedbythewordtosearch.

Asyoucansee,lessfindsandhighlightsthekeyword.Type[n]tosearchforthenextoccurrenceoftheword.

grep

          • <source id="psya1"></source>

              Itsearchesfilesforspecifiedwordsorpatterns.Firstclearthescreen,thentype

              grepsciencescience.txt

              Asyoucansee,grephasprintedouteachlinecontainingthewordscience.

              Trytyping

              grepSciencescience.txt

              Thegrepcommandsiscasesensitive;ItdistinguishesbetweenScienceandscience.

              Toignoreupper/lowercasedistinctions,usethe-ioption,i.e.Type

              grep-isciencescience.txt

              TosearchforapharSEOrpattern,youmustencloseitinsinglequotes.Forexampletosearchforspinningtop.Type

              發(fā)表評(píng)論 共有條評(píng)論
              用戶名: 密碼:
              驗(yàn)證碼: 匿名發(fā)表
              主站蜘蛛池模板: 维西| 德江县| 赤壁市| 甘洛县| 榆树市| 泸西县| 星子县| 民勤县| 岳阳市| 深泽县| 白银市| 洪泽县| 桃园市| 遂昌县| 涟水县| 奉化市| 乳山市| 桃江县| 射阳县| 定边县| 昭平县| 沭阳县| 高雄县| 景东| 中西区| 宜春市| 平罗县| 鹤山市| 志丹县| 盘山县| 缙云县| 澳门| 新宁县| 柞水县| 博白县| 德化县| 贵德县| 长宁区| 合江县| 保山市| 页游|