Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
273 views6 pages

Linux - Assignment - Level 0 PDF

Explore the filesystem tree using cd, ls, pwd and cat. Can you identify what devices are available? can you identify your tty (terminal)device?

Uploaded by

AnkitPatel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
273 views6 pages

Linux - Assignment - Level 0 PDF

Explore the filesystem tree using cd, ls, pwd and cat. Can you identify what devices are available? can you identify your tty (terminal)device?

Uploaded by

AnkitPatel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

LinuxAssignment

Exercise:1
1.LogonaLinuxmachineEnteryourlogin(username)andpasswordatrelevant
prompts.
2.EnterthesecommandsattheUNIXprompt,andtrytointerprettheoutput.Ask
questionsanddon'tbeafraidtoexperiment(asanormaluseryoucannotdomuch
harm):
echohelloworld

passwd

date

hostname
arch

unamea

dmesg|more (youmayneedtopressqtoquit)
uptime

whoami
who
id
last

finger

top (youmayneedtopressqtoquit)
echo$SHELL
echo{con,pre}{sent,fer}{s,ed}
man"automaticdoor"
manls (youmayneedtopressqtoquit)
manwho (youmayneedtopressqtoquit)
whocantellmewhyigotdivorced
lost
clear
cal2000
cal91752 (doyounoticeanythingunusual?)
bcl (typequit orpressCtrldtoquit)
echo5+4|bcl
yesplease (youmayneedtopressCtrlctoquit)
timesleep5
history

Exercise:2
Trythefollowingcommandsequence:
cd
pwd
lsal
cd.
pwd(wheredidthatgetyou?)
cd..
pwd
lsal
cd..
pwd
lsal
cd..
pwd(whathappensnow)
cd/etc
lsal|more
catpasswd
cd
pwd
2. Continuetoexplorethefilesystemtreeusingcd,ls,pwdandcat.Lookin/bin,
/usr/bin,/sbin,/tmpand/boot.Whatdoyousee?
3. Explore/dev.Canyouidentifywhatdevicesareavailable?Whicharecharacter
orientedandwhichareblockoriented?Canyouidentifyyourtty
(terminal)device(typingwhoamimighthelp);whoistheownerofyourtty
(uselsl)?
4. Explore/proc.Displaythecontentsofthefilesinterrupts,devices,cpuinfo,
meminfoanduptimeusingcat.Canyouseewhywesay/procisapseudo
filesystemwhichallowsaccesstokerneldatastructures?
5. Changetothehomedirectoryofanotheruserdirectly,usingcd~username.
6. Changebackintoyourhomedirectory.
7. Makesubdirectoriescalledworkandplay.
8. Deletethesubdirectorycalledwork.
9. Copythefile/etc/passwdintoyourhomedirectory.
10. Moveitintothesubdirectoryplay.
11. Changeintosubdirectoryplayandcreateasymboliclinkcalledterminalthat
pointstoyourttydevice.Whathappensifyoutrytomakeahardlinktothetty
device?
12. Whatisthedifferencebetweenlistingthecontentsofdirectoryplaywithlsl
andlsL?
13. Createafilecalledhello.txtthatcontainsthewords"helloworld".Canyouuse
"cp"using"terminal"asthesourcefiletoachievethesameeffect?
14. Copyhello.txttoterminal.Whathappens?
15. Imagineyouwereworkingonasystemandsomeoneaccidentallydeletedthels
command(/bin/ls).Howcouldyougetalistofthefilesinthecurrentdirectory?

Tryit.
16. Howwouldyoucreateandthendeleteafilecalled"$SHELL"?Tryit.
17. Howwouldyoucreateandthendeleteafilethatbeginswiththesymbol#?
Tryit.
18. Howwouldyoucreateandthendeleteafilethatbeginswiththesymbol?Try
it.
19. Whatistheoutputofthecommand:echo{con,pre}{sent,fer}{s,ed}?Now,
fromyourhomedirectory,copy/etc/passwdand/etc/groupintoyourhome
directoryinonecommandgiventhatyoucanonlytype/etconce.
20. Stillinyourhomedirectory,copytheentiredirectoryplaytoadirectorycalled
work,preservingthesymboliclink.
21. Deletetheworkdirectoryanditscontentswithonecommand.Acceptno
complaintsorqueries.
22. Changeintoadirectorythatdoesnotbelongtoyouandtrytodeleteallthe
files(avoid/procor/dev,justincase!)
23. Experimentwiththeoptionsonthelscommand.Whatdothed,i,RandF
optionsdo?

Exercise:3
Describethreedifferentwaysofsettingthepermissionsonafileordirectorytorrr.
Createafileandseeifthisworks.

1. Teamupwithapartner.Copy/bin/shtoyourhomedirectory.Type"chmod+s
sh".Checkthepermissionsonshinthedirectorylisting.Nowaskyourpartnerto
changeintoyourhomedirectoryandruntheprogram./sh.Askthemtorunthe
idcommand.What'shappened?Yourpartnercantypeexittoreturntotheir
shell.
2. Whatwouldhappenifthesystemadministratorcreatedashfileinthisway?
Whyisitsometimesnecessaryforasystemadministratortousethisfeature
usingprogramsotherthansh?
3. Deleteshfromyourhomedirectory(oratleasttodoachmodssh).
4. Modifythepermissionsonyourhomedirectorytomakeitcompletelyprivate.
Checkthatyourpartnercan'taccessyourdirectory.Nowputthepermissions
backtohowtheywere.
5. Typeumask000andthencreateafilecalledworld.txtcontainingthewords
"helloworld".Lookatthepermissionsonthefile.What'shappened?Nowtype
umask022andcreateafilecalledworld2.txt.Whenmightthisfeaturebe
useful?
6. Createafilecalled"hello.txt"inyourhomedirectoryusingthecommandcatu
>hello.txt.Askyourpartnertochangeintoyourhomedirectoryandruntailf
hello.txt.Nowtypeseverallinesintohello.txt.Whatappearsonyourpartner's
screen?
7. Usefindtodisplaythenamesofallfilesinthe/homesubdirectorytree.Canyou
dothiswithoutdisplayingerrorsforfilesyoucan'tread?
8. Usefindtodisplaythenamesofallfilesinthesystemthatarebiggerthan1MB.
9. Usefindandfiletodisplayallfilesinthe/homesubdirectorytree,aswellasa
guessatwhatsortofafiletheyare.Dothisintwodifferentways.
10. Usegreptoisolatethelinein/etc/passwdthatcontainsyourlogindetails.
11. Usefindandgrepandsorttodisplayasortedlistofallfilesinthe/home
subdirectorytreethatcontainthewordhellosomewhereinsidethem.
12. Uselocatetofindallfilenamesthatcontainthewordemacs.Canyoucombine
thiswithgreptoavoiddisplayingallfilenamescontainingthewordlib?
13. Createafilecontainingsomelinesthatyouthinkwouldmatchtheregular
expression:(^[09]{1,5}[azAz]+$)|noneandsomelinesthatyouthink
wouldnotmatch.Useegreptoseeifyourintuitioniscorrect.
14. Archivethecontentsofyourhomedirectory(includinganysubdirectories)
usingtarandcpio.Compressthetararchivewithcompress,andthecpioarchive
withgzip.Nowextracttheircontents.
15. OnLinuxsystems,thefile/dev/urandomisaconstantlygeneratedrandom
streamofcharacters.Canyouusethisfilewithodtoprintoutarandomdecimal
number?
16. Typemount(withnoparameters)andtrytointerprettheoutput.

Exercise:4
Archivethecontentsofyourhomedirectoryusingtar.Compressthetarfilewithgzip.Now
uncompressandunarchivethe.tar.gzfileusingcat,tarandgzipononecommandline.

1. Usefindtocompilealistofalldirectoriesinthesystem,redirectingtheoutput
sothatthelistofdirectoriesendsupinafilecalleddirectories.txtandthelistof
errormessagesendsupinafilecallederrors.txt.
2. Trythecommandsleep5.Whatdoesthiscommanddo?
3. Runthecommandinthebackgroundusing&.
4. Runsleep15intheforeground,suspenditwithCtrlzandthenputitintothe
backgroundwithbg.Typejobs.Typeps.Bringthejobbackintotheforeground
withfg.
5. Runsleep15inthebackgroundusing&,andthenusekilltoterminatethe
processbyitsjobnumber.Repeat,exceptthistimekilltheprocessbyspecifying
itsPID.
6. Runsleep15inthebackgroundusing&,andthenusekilltosuspendthe
process.Usebgtocontinuerunningtheprocess.
7. Startupanumberofsleep60processesinthebackground,andterminatethem
allatthesametimeusingthepkillcommand.
8. Useps,wandtoptoshowallprocessesthatareexecuting.
9. UsepsaeHtodisplaytheprocesshierarchy.Lookfortheinitprocess.Seeifyou
canidentifyimportantsystemdaemons.Canyoualsoidentifyyourshellandits
subprocesses?
10. Combinepsfaewithgreptoshowallprocessesthatyouareexecuting,with
theexceptionofthepsfaeandgrepcommands.
11. Startasleep300processrunninginthebackground.Logofftheserver,andlog
backinagain.Listalltheprocessesthatyouarerunning.Whathappenedtoyour
sleepprocess?Nowrepeat,exceptthistimestartbyrunningnohupsleep300.
12. Multiplejobscanbeissuedfromthesamecommandlineusingtheoperators;,
&&and||.Trycombiningthecommandscatnonexistentandechohellousing
eachoftheseoperators.Reversetheorderofthecommandsandtryagain.What
aretherulesaboutwhenthecommandswillbeexecuted?
13. Whatdoesthexargscommanddo?Canyoucombineitwithfindandgrepto
findyetanotherwayofsearchingallfilesinthe/homesubdirectorytreeforthe
wordhello?
14. Whatdoesthecutcommanddo?Canyouuseittogetherwithwtoproducea
listofloginnamesandCPUtimescorrespondingtoeachactiveprocess?Canyou
now(allonthesamecommandline)usesortandheadortailtofindtheuser
whoseprocessisusingthemostCPU?

Exercise:5
1. Edityourcopyofthedocumentusingvi.
2. Gototheendofthedocumentandtypeinthefollowingparagraph:

3.
4.
5.
6.
7.
8.

Joinedthelibrary.GotCareoftheSkin,OriginoftheSpecies,andabookbya
womanmymotherisalwaysgoingonabout.ItiscalledPrideandPrejudice,by
awomancalledJaneAusten.Icouldtellthelibrarianwasimpressed.Perhaps
sheisanintellectuallikeme.Shedidn'tlookatmyspot,soperhapsitisgetting
smaller.
Correctthethreespellingerrorsinthefirstthreelinesofthefirstparagraph(one
errorperline)andremovetheextra"Geography"inthe3rdlineofthefirst
paragraph.
Addthewords"Abouttime!"totheendofthesecondparagraph.
Deletethesentence"Timeflieslikeanarrowbutfruitflieslikeabanana"and
reformtheparagraph.
Replacealloccurrencesof"is"with"was".
Swapthetwoparagraphs.
Savethefileandquit.

You might also like