Professional Documents
Culture Documents
GuidetoUnix/Commands/FileSystemUtilitiesWikibooks,openbooksforanopenworld
GuidetoUnix/Commands/FileSystemUtilities
Contents
1 ls
2 mkdir
3 cd
4 pwd
5 chroot
6 cp
7 mv
8 rm
9 rmdir
10 shred
11 touch
12 df
13 ln
14 chown
15 chmod
ls
lsisautilityforlistingthefilesinadirectory.
Mostusedoptionsare:
a
allfiles(includefileswith.prefix)
l
longdetail(providefilestatistics)
t
orderbycreationtime
ls
LiStcontentsofdirectory
=1FreeBSDmanualpage(http://www.freebs
d.org/cgi/man.cgi?query=ls&sektion)
NetBSDmanualpage(http://netbsd.gw.com/c
gibin/mancgi?ls+1)
=1OpenBSDmanualpage(http://www.openb
sd.org/cgibin/man.cgi?query=ls&sektion)
u
sortbyaccesstime(orshowwhenlastaccessed
togetherwithl)
S
orderbysize
r
reverseorder
ls(http://www.gnu.org/software/coreutils/man
ual/html_node/coreutils_52.html)attheGNU
coreutilsmanual(http://www.gnu.org/softwa
re/coreutils/manual/coreutils.html)
F
markdirectorieswith/,executableswith*,symbolic
linkswith@,localsocketswith=,namedpipes
(FIFOs)with|
lsattheLinuxquestionswiki
Otheroptionsinclude:
Fxcolor
colorcodedlisting
https://en.wikibooks.org/wiki/Guide_to_Unix/Commands/File_System_Utilities
1/12
05/07/2016
GuidetoUnix/Commands/FileSystemUtilitiesWikibooks,openbooksforanopenworld
s
showfilesizes
h
"humanreadble"showfilesizesinkilobytesandmegabytes(hcanbeusedtogetherwithlors)
ls*st*:listfilesthatcontainstinname
ls>list:outputlisttofilenamed"list"
ls|more:fitlistingtoscreen
Examples
$ls
fishhello.txt
$lsl
rwrr1usernamegroupname0Apr1100:09fish
rwrr1usernamegroupname11Apr1100:10hello.txt
Severalsystemshaveanaliasllwhichdoesthesameaslsl:
$ll
rwrr1usernamegroupname0Apr1100:09fish
rwrr1usernamegroupname11Apr1100:10hello.txt
BecarefulwiththeFoption.Hereisoneexample:
$lsF/usr/X11R6/bin/X*
/usr/X11R6/bin/X@/usr/X11R6/bin/Xnest*/usr/X11R6/bin/Xprt*
/usr/X11R6/bin/Xmark*/usr/X11R6/bin/Xorg*/usr/X11R6/bin/Xvfb*
Wedonotknowyetifthereisasymboliclink"X"andanexecutable"Xmark"orif"X@"and"Xmark*"arejust
thenamesofnormalfiles.(Though"@"and"*"arenotmuchfoundinfilenames,theyarepossible.)Sowecheck
bydroppingtheF:
$ls/usr/X11R6/bin/X*
/usr/X11R6/bin/X/usr/X11R6/bin/Xnest/usr/X11R6/bin/Xprt
/usr/X11R6/bin/Xmark/usr/X11R6/bin/Xorg/usr/X11R6/bin/Xvfb
mkdir
mkdirisautilityforcreatingadirectory.
Examples
$mkdirnewdirectoryname
Thepoptionalsomakesparentdirectoriesasneeded.Insteadof:
$mkdirfoo
$cdfoo
$mkdirbar
https://en.wikibooks.org/wiki/Guide_to_Unix/Commands/File_System_Utilities
2/12
05/07/2016
GuidetoUnix/Commands/FileSystemUtilitiesWikibooks,openbooksforanopenworld
youcanjustdo:
$mkdirpfoo/bar
cd
cdchangesthecurrentdirectoryoftheshell.Thiscurrent
directorywillbeusedbyotherprogramslaunchedfromthe
shell.
Because"cd"changesthestateoftheshell,itisashellbuilt
incommand.Incontrast,mostcommandsareseparate
programswhichtheshellstarts.
cd
changeCurrentDirectory
cdattheLinuxquestionswiki
Examples
Changeto'foobar'directory:
$cdfoobar
Changetoyourhomedirectory,cdcommandusedwithoutanoptionwilldropyoubackintoyourhomedirectory.
$cd
~(tilde)storesthepathtoyourhomedirectory,thiscommandhassameeffectasthepreviousone.
$cd~
Changetoparentdirectory:
$cd..
Changetothepreviousdirectory:
$cd
Tips:
Bysetting"CDPATH"environmentvariableinyourshellyoucantakeadvantageofshellcommandcompletion
facility.
$echo$CDPATH
.:/usr/local:/usr/share/doc
Ifyouhavethe$CDPATHset,thenyoupress'TAB'keyandgetpossiblepathcompletions
https://en.wikibooks.org/wiki/Guide_to_Unix/Commands/File_System_Utilities
3/12
05/07/2016
GuidetoUnix/Commands/FileSystemUtilitiesWikibooks,openbooksforanopenworld
$cdbas[TAB]
baseconfig/basefiles/basepasswd/bash/bastille/
pwd
pwd(forPrintWorkingDirectory)showsthecurrent
directorythatyouarein.
Though"pwd"isoftenavailableasanexternalprogram
(like/bin/pwd),manyshellsofferanequivalentversionasa
shellbuiltincommand.Likeanyexternalcommand,"pwd"
wouldinheritthecurrentdirectoryfromtheshellorother
programthatstartsit.
Examples
$pwd
/home/username
Youcanchangethedirectory,youcanalso
$cd/usr
$pwd
/usr
pwd
PrintWorkingDirectory
=1FreeBSDmanualpage(http://www.freebs
d.org/cgi/man.cgi?query=pwd&sektion)
NetBSDmanualpage(http://netbsd.gw.com/c
gibin/mancgi?pwd+1)
=1OpenBSDmanualpage(http://www.openb
sd.org/cgibin/man.cgi?query=pwd&sektion)
pwd(http://www.gnu.org/software/coreutils/m
anual/html_node/coreutils_114.html)atthe
GNUcoreutilsmanual(http://www.gnu.org/s
oftware/coreutils/manual/coreutils.html)
pwdattheLinuxquestionswiki
Youcanalsouse"pwd"inscripts.Ifyouhaveenoughexperiencewithscripting,thenyouwouldknowthatthe
nextlinecomplainsifthecurrentdirectoryis/home/username.
$test"x$(pwd)"=x/home/username||echowrongdirectory
chroot
chrootchangestherootfilesystem.The"chroot"pageatthe
Linuxquestionswikiexplainswhyyoumightwanttodo
this.
Examples
Tochangetherootfilesystemso/mnt/usbdrive/becomes/
andfilesoutsideofitcannotbeseen:
#chroot/mnt/usbdrive/
Youmustberootuserto"chroot".Otheruserswouldbe
abletouse"chroot"togainroot(superuser)privileges,so
theiruseof"chroot"isdisallowed.
$chroot/mnt/usbdrive/
chroot:/mnt/usbdrive/:Operationnotpermitted
https://en.wikibooks.org/wiki/Guide_to_Unix/Commands/File_System_Utilities
chroot
CHangeROOTdirectory
=8FreeBSDmanualpage(http://www.freebs
d.org/cgi/man.cgi?query=chroot&sektion)
NetBSDmanualpage(http://netbsd.gw.com/c
gibin/mancgi?chroot+8)
=8OpenBSDmanualpage(http://www.openb
sd.org/cgibin/man.cgi?query=chroot&sektio
n)
chroot(http://www.gnu.org/software/coreutil
s/manual/html_node/coreutils_145.html)at
theGNUcoreutilsmanual(http://www.gnu.o
rg/software/coreutils/manual/coreutils.html)
4/12
05/07/2016
GuidetoUnix/Commands/FileSystemUtilitiesWikibooks,openbooksforanopenworld
chrootattheLinuxquestionswiki
cp
cpcopiesafile
Mostusedoptionsare:
r
copiesdirectories(recursively)
p
preservespermissions,ownership,andtimestamps
i
promptbeforeoverwrite
v
verbose,showfilenamesastheyarebeingcopied
Examples
Makesacopyoffile'debian'andcallit'Debian'(assuming'Debian'isnotalreadyadirectory)
$cpidebianDebian
Makesacopyoffile'debian'andputitat/tmp/debian
$cpidebian/tmp/debian
Sameasthepreviouscommand(thefilenamedefaultstobethesame).
$cpidebian/tmp
Makesacopyofdirectory'mydir'(andallitscontents)andputitat/tmp/mydir
$cpirmydir//tmp
Copymultiplefilestodirectory/tmp
$cpifoobarbaz/tmp
mv
mvmoveand/orrenamefiles
Examples
Renamefile'unix'to'Unix'(assuming"Unix"isnotadirectory)
$mviunixUnix
MovefileUnixfromyourhomedirectoryto/tmp.
$mvi~/Unix/tmp/Unix
Sameasthepreviouscommand(thefilenamedefaultstobethesame).
$mvi~/Unix/tmp
MovefileUnixfromyourhomedirectoryto/tmp,andrenameitto'unix'.
$mvi~/Unix/tmp/unix
https://en.wikibooks.org/wiki/Guide_to_Unix/Commands/File_System_Utilities
5/12
05/07/2016
GuidetoUnix/Commands/FileSystemUtilitiesWikibooks,openbooksforanopenworld
Movemultiplefilestodirectory/tmp
$mvifoobarbaz/tmp
rm
rmdeletesafilefromthefilesystem,likethe"del"
commandinDOS.
TheGNUlongoptions(likedirectory)areavailableon
Linux,butnotmostothersystems.
Someusefuloptionsare:
d,directory
unlinkFILE,evenifitisanemptydirectory(some
systemsletsuperuserunlinknonemptydirectories
too)
f,force
ignorenonexistentfiles,neverprompt
i,interactive
promptbeforeanyremoval
P
(*BSDonly)overwritefilebeforedeletion
r,R,recursive
removethecontentsofdirectoriesrecursively(the
forceoptionmustoftenbeusedtosuccessfullyrunrm
recursively)
v,verbose
(GNUonly)explainwhatisbeingdone
help
(GNUonly)displayhelpandexit
version
(GNUonly)outputversioninformationandexit
rm
ReMoveanddeletefiles
=1FreeBSDmanualpage(http://www.freebs
d.org/cgi/man.cgi?query=rm&sektion)
NetBSDmanualpage(http://netbsd.gw.com/c
gibin/mancgi?rm+1)
=1OpenBSDmanualpage(http://www.openb
sd.org/cgibin/man.cgi?query=rm&sektion)
rm(http://www.gnu.org/software/coreutils/ma
nual/html_node/coreutils_68.html)atthe
GNUcoreutilsmanual(http://www.gnu.org/s
oftware/coreutils/manual/coreutils.html)
rmattheLinuxquestionswiki
Examples:
Theusageof"rm"isconsideredpotentiallymoredangerousthanequivalentsinotheroperatingsystemsbecauseof
thewaytheshellparseswildcardsandnamesofspecialdirectoriesandinitsnonverboseactions.
Hereisaclassicexample.Insteadofdeletingfilesthatendwith.o("*.o")itdeletesallfilesinthedirectory("*")
andalsoafilecalled.o.Thereisanunwantedspacebetweentheasteriskandtheperiod.
$rm*.o
rm:cannotremove`.o':Nosuchfileordirectory
Toremoveafilewhosenamestartswitha`',forexample`foo',useoneofthesecommands:
$rmfoo
$rm./foo
https://en.wikibooks.org/wiki/Guide_to_Unix/Commands/File_System_Utilities
6/12
05/07/2016
GuidetoUnix/Commands/FileSystemUtilitiesWikibooks,openbooksforanopenworld
Itmightbeusefultocreateanaliassuchas"remove"whichmovesthefilestoalocal"trash"filesoyoucango
thereandrecoverfilesyouaccidentally"remove"d.
Securedeletionoffiles:
Notethatifyouusermtoremoveafile,itisusuallypossibletorecoverthecontentsofthatfilesincermdoesnot
removeitfromtheharddisk.Itsimplyremovesthefilesystemslinktoit.
On*BSDsystems,thePoptionoverwritesthedatawiththefilebeforeremovingit.
$rmPsecretfile
However,astheNetBSDmanualpage(http://netbsd.gw.com/cgibin/mancgi?rm+1)explainsit:
Recentresearchindicatesthatasmanyas35overwritepasseswithcarefullychosendatapatternsmaybe
necessarytoactuallypreventrecoveryofdatafromamagneticdisk.ThusthePoptionislikelyboth
insufficientforitsdesignpurposeandfartoocostlyfordefaultoperation.
Sowhileexaminingthedata(usingfsdbormakingadiskimage)willnotrevealthesecretdata,othermethods
(suchaslaboratoryexaminationofthedisk)willrevealthedata.Inshort,rmPdoesnotdeletedatasecurely.A
programthatattemptstodeletedatasecurelyisGNUshred,availableonLinux.But"shred"isnotalways
successfulinsecuredeletionreaditsentrybelow.
rmdir
rmdirisautilityfordeletingemptydirectories.
Examples
$rmdirdirectoryname
Ifthedirectoryisnotempty,thecorrectwaytoremovethedirectoryandallitscontentsrecursivelyistouse
$rmrdirectoryname
shred
shredoverwritesafilemultipletimeswithspecialdata
patternstomaketheoldcontentsofthefileunrecoverable
fromadisk,especiallyaharddisk.Thiscommandispartof
GNUcoreutils,soitisoftenonlyavailableonLinux
systems.
Notethatthisactuallyisineffectiveonmostfilesystems
becausetheycankeepoldcopiesofdata.Mostpopular
Linuxfilesystems(includingext3)keepsuchcopiesthrough
journaling.However,"shred"isveryusefulfordestroying
thedataonentirepartitionsordisks.
shred
Attempttosecurelydeletefiles
shred(http://www.gnu.org/software/coreutils/
manual/html_node/coreutils_69.html)atthe
GNUcoreutilsmanual(http://www.gnu.org/s
oftware/coreutils/manual/coreutils.html)
shredattheLinuxquestionswiki
Someusefuloptionsare:
https://en.wikibooks.org/wiki/Guide_to_Unix/Commands/File_System_Utilities
7/12
05/07/2016
GuidetoUnix/Commands/FileSystemUtilitiesWikibooks,openbooksforanopenworld
u,remove
unlinkthefileafterremovingit
NUMBER,nNUMBER,iterations=NUMBER
thenumberofiterationsofoverwritingthefiledefaultis25iterations
Examples:Removeandcompletelydestroysecretfilefromafilesystemthatoverwritesdatainplaceanddoesnot
usejournaling(forexample,theUFSfilesystemof*BSD).Forthelaststep,afterthedataisdestroyed,the"u"
optionunlinksthefilefromthefilesystem.
$shredusecretfile
Notethatifsecretfilehasmultiplehardlinks(withlnforexample),itwillcontinuetoexistwiththoseother
names,butwillcontainonlyrandomdata.
touch
touchletsyouchangethedateonafile.Canalsobeusedtocreateablankfile.
Examples
Thiswillchangetheaccessdateandtimeoffilenametothecurrenttime.Iffilenamedoesn'texistitwillcreatea
blankfile.
$touchfilename
df
dfreportstheamountoffreediskspaceavailableoneachpartition.
$df
Filesystem1KblocksUsedAvailableUse%Mountedon
/dev/md0576350820738052633524%/
/dev/md178819376137222886109329619%/home
/dev/md42307056443095721758905620%/usr
/dev/md257635081757404371332833%/var
/dev/md32877756334740239683213%/tmp
ReportsdiskusageinhumanreadableformatwithblocksizesinKilo,Mega,Gigabytes.
$dfh
FilesystemSizeUsedAvailUse%Mountedon
/dev/hda12.3G2.1G133M95%/
tmpfs61M8.0K61M1%/dev/shm
/dev/hda22.0G1.8G113M94%/usr
ln
lncreateslinksbetweenfiles.
https://en.wikibooks.org/wiki/Guide_to_Unix/Commands/File_System_Utilities
8/12
05/07/2016
GuidetoUnix/Commands/FileSystemUtilitiesWikibooks,openbooksforanopenworld
Symboliclinksarespecialfilesthatcontaintheabsoluteorrelativepathtoaseparatefile.Referencestothe
symboliclinkare"forwarded"tothefileit(thesymboliclink)pointsto.Thefiletowhichthereferenceis
forwardedisnot"aware"ofthelinkifthefilepointedtoismovedordeleted,thelinkwilljustpointtonothing
(nowarningsaregiven,norareanyattemptsmadeto"refresh"thelinktothefile'snewlocation).
InUnixallinformationaboutfilesowner,group,permissions,size,numberoflinks,locationondiskarestored
intheinode(withthenotableexceptionofthefilename).Thefilenameisstoredindirectories,whereinode
numbers(thewaytheOSreferstofiles)arepairedwithfilenames(textstringsthewaytheuserreferstofiles).
The"numberoflinks"entryintheinode,keepstrackofhowmanytimestheinodenumberhasthusbeenpaired
withanameinsomedirectory.
Whencreatinga(hard)linkwithln,the"source"fileisonlyusedtodeterminetheinodenumber.Anewinode
numbertofilenameentryisthenmadeinsomedirectoryusingthatinodenumber,andthe"numberoflinks"
counterisincremented.It'simportantthatthis(unlikeasymboliclink)isthesamefileineveryway...it'sjustthat
thefilecanbeaccessedbydifferentnamesand/orfromdifferentlocations.Movingordeletingthe"original"
sourcefilehasnoeffectontheotherlinks.Deletingoneofthefile'slinksonlyremovesitsentryfromthat
directory...it'sfirstwhenthelastlinkinanydirectoryisremoved,thatthefileisactuallydeletedfromthedisk.
Hardlinkscannot(unlikesymboliclinks)beusedtorefertoafileonanotherfilesystem,norcanhardlinks
usuallybeusedtolinktoadirectory.
Examples:
Tomakeasoft(symbolic)link"hello"tothefile"/home/alice/code/bin/world":
$lns/home/alice/code/bin/worldhello
Tomakea(hard)linkfromthefile"foo"tothefile"bar":
$lsl
total1
rwrr1rtmusers50Aug15foo
$lnfoobar
$lsl
total2
rwrr2rtmusers50Aug15foo
rwrr2rtmusers50Aug15bar
The1stnumberoflsl'slisting,showsthenumberof(hard)linksafilehasinotherwords,thenumberoftimes
it'sbeenenteredintosomedirectory.
chown
chownchangestheownerandgroupoffiles.Normally,
onlyrootisallowedtodothis,butifauserownsafile,then
thatusercanchangethegroup,butonlytogroups
containingthatuser.Onoldsystems,theabilityofusersto
givefilestootheruserscausedabuses,somostsystems
prohibitnonrootusersfromchangingtheowneroffiles.
Someusefuloptionsare:
R
https://en.wikibooks.org/wiki/Guide_to_Unix/Commands/File_System_Utilities
chown
CHangesOWNeroffile
=8FreeBSDmanualpage(http://www.freebs
d.org/cgi/man.cgi?query=chown&sektion)
NetBSDmanualpage(http://netbsd.gw.com/c
gibin/mancgi?chown+8)
=8OpenBSDmanualpage(http://www.openb
sd.org/cgibin/man.cgi?query=chown&sektio
9/12
05/07/2016
GuidetoUnix/Commands/FileSystemUtilitiesWikibooks,openbooksforanopenworld
recursivelychangeowner/grouponanentiredirectory
tree
n)
donotfollowsymboliclinksi.e.changesownerofthe
link,notthetargetfile
chown(http://www.gnu.org/software/coreutil
s/manual/html_node/coreutils_79.html)atthe
GNUcoreutilsmanual(http://www.gnu.org/s
oftware/coreutils/manual/coreutils.html)
h
f
indicatenoerrorsifchangefailed
Examples:
Rootchangestheownershipof"/etc/passwd"and
"/etc/shadow"touserroot,groupwheel:
chownattheLinuxquestionswiki
#chownroot:wheel/etc/passwd/etc/shadow
Thesame,butonlychangingtheowner:
#chownroot:/etc/{passwd,shadow}
Thesame,butonlychangingthegroup:
#chown:wheel/etc/{passwd,shadow}
Rootgiveseveryfilein"/etc/ssh",includingfilesinsubdirectories,touserroot,groupwheel:
#chownRroot:wheel/etc/ssh
Thesame,butexcludingfilesindirectories(andtheinvisiblefiles"/etc/ssh/.*"willalsobemissed):
#chownroot:wheel/etc/ssh/*
User"tux"changesthedirectory"/usr/local/src/xc"fromgroup"tux"togroup"wheel".Tuxisamemberofboth
groups.
$lsld/usr/local/src/xc
drwxrxrx11tuxtux512Sep3016:19/usr/local/src/xc
$chowntux:wheel/usr/local/src/xc
$lsld/usr/local/src/xc
drwxrxrx11tuxwheel512Sep3016:19/usr/local/src/xc
chmod
chmodchangespermissionsoffiles.Onemustbefamiliar
withUnixfilepermissionstounderstandthiscommand.
Therearethreepermissions:read("r"),write("w"),and
execute("x").Therearethreesetsofpermissions:forthe
owninguserofthefile("u"),forthegroupofthefile("g"),
andforotherusers("o").
https://en.wikibooks.org/wiki/Guide_to_Unix/Commands/File_System_Utilities
chmod
CHangesfileMODe
=1FreeBSDmanualpage(http://www.freebs
d.org/cgi/man.cgi?query=chmod&sektion)
NetBSDmanualpage(http://netbsd.gw.com/c
gibin/mancgi?chmod+1)
10/12
05/07/2016
GuidetoUnix/Commands/FileSystemUtilitiesWikibooks,openbooksforanopenworld
Forafile,"execute"meanstorunitasaprogram.Fora
directory,"execute"permissionisrequiredtouseanything
inthatdirectorytree,sodoinganythingwith
"/usr/share/doc/README"requiresexecutepermissionson
allof"/","/usr","/usr/share",and"/usr/share/doc".
Ifyouareinterestedinmoreadvancedtopicsliketheset
uid,setgid,stickybitsandoctalnumbers,tryreadingthe
FreeBSDmanualpageat
http://www.FreeBSD.org/cgi/man.cgi(type"chmod"inthe
formandsubmit).
=1OpenBSDmanualpage(http://www.openb
sd.org/cgibin/man.cgi?query=chmod&sektio
n)
chmod(http://www.gnu.org/software/coreutil
s/manual/html_node/coreutils_81.html)atthe
GNUcoreutilsmanual(http://www.gnu.org/s
oftware/coreutils/manual/coreutils.html)
chmodattheLinuxquestionswiki
Ausefuloptionis:
R
recursivelychangeorsetpermissionsonanentiredirectorytree
Examples:
Wewroteashellscriptcalled"configure".Wemakeitexecutable("+x")andthenexecuteitasacommand.
Usually,"+x"isthesameas"u+x"or"ug+x",dependingonthestatusofthefilemodecreationmask.
$chmod+xconfigure
$./configure
Allowtheowningusertorun"configure":
$chmodu+xconfigure
Denythegroupandotherusersfromrunning"configure":
$chmodgoxconfigure
Forallusersexcepttheowner("go"),disableallaccessto"~/mail"and"~/private"("rwx").Thisway,the
contentsareprivateandonlytheirowner(orroot)canaccessthem.
$chmodgorwx~/mail~/private
Notethatinthepreviousexample,"R"wasnotspecified.Bydisablingtheexecutebit("x"),allfilesinside
~/{mail,private}areprotectedeveniftheirgroupandotherreadbitsareenabled.Thus,simplymovingsomefile
frominside~/{mail,private}tosomepublicplacelike/tmpcanmakethefilesavailabletootherusersagain.
The"root"userwantstosetup/usr/local/srcsothatallusersingroup"wsrc"(including"tux")cancreatefiles
there.Rootwillcontinuetoownthedirectory.Thisisdonebychangingthegroupof/usr/local/srcto"wsrc"and
thenbygrantingtothegroup("g")theread,write,andexecutepermissions("+rwx").
#chown:wsrc/usr/local/src
#chmodg+rwx/usr/local/src
https://en.wikibooks.org/wiki/Guide_to_Unix/Commands/File_System_Utilities
11/12
05/07/2016
GuidetoUnix/Commands/FileSystemUtilitiesWikibooks,openbooksforanopenworld
AllUnixlikesystemsshouldallowalluserstocreatetemporaryfilesin"/tmp"and"/var/tmp".Thusrootgives
everyone("a",shortfor"ugo")allpermissions("+rwx")onthefiles.
#chmoda+rwx/tmp/var/tmp
Theproblemwiththeaboveisthatbecauseallusershavewriteaccessto/tmpand/var/tmp,everyusercandelete
andrenamefiles,evenonesnotcreatedbythem.Forexample,"tux"couldcreate"/tmp/socket.3908"andanother
usercoulddeleteitorrenameitto"/tmp/garbage",thusannoyingTux.Tokeeptemporaryfilessafe,weusethe
stickybitcalled"t".Thislimitsthedeletionandrenamingoffilesin/tmptoroot,theownerof/tmp(alsoroot),and
theownerofthefile(Tuxfor"/tmp/socket.3908").Itdoesthesamefor/var/tmp.Sowhatweshoulddois:
#chmoda+rwxt/tmp/var/tmp
Retrievedfrom"https://en.wikibooks.org/w/index.php?
title=Guide_to_Unix/Commands/File_System_Utilities&oldid=3017705"
Thispagewaslastmodifiedon20November2015,at23:24.
TextisavailableundertheCreativeCommonsAttributionShareAlikeLicense.additionaltermsmayapply.
Byusingthissite,youagreetotheTermsofUseandPrivacyPolicy.
https://en.wikibooks.org/wiki/Guide_to_Unix/Commands/File_System_Utilities
12/12