国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
              主站蜘蛛池模板: 定兴县| 师宗县| 北票市| 利辛县| 那曲县| 乌鲁木齐市| 科技| 巧家县| 景德镇市| 泊头市| 井陉县| 宜昌市| 台东县| 富阳市| 蒙阴县| 肇庆市| 湖北省| 武穴市| 南康市| 凌海市| 嘉兴市| 开鲁县| 双鸭山市| 金山区| 永靖县| 汝南县| 怀集县| 化州市| 乌苏市| 孟州市| 巧家县| 斗六市| 琼海市| 双峰县| 万宁市| 辽阳县| 勃利县| 中山市| 金阳县| 大埔区| 辽宁省|