You are on page 1of 2

shell card

<...>replacewithvalidname [...] listsoptionalparameters find<startdir>[option<parameter>] search the filesystem below <start dir> iname<file>searchesfor<file> type<type>searchesforfiletypes user <user> searches for files belongingto<user> mv<old><new> moveorrename<old>to<new> cp<file><new> copyfile<file>to<new> ln[sf]<file><link> createasecondnameforafile hardlink different names for same inode ssymboliclink fforce touch<file> setstheaccessdateandtimetonow rm[rf]<file> delete<file> rrecursive fforce df[h]<directory> informationaboutfilesystems hhumanreadable rsyncavzprogresssourcetarget sourceortargetmustbelocal sourceortarget[user@][host:]<dir> ddif=<infile>bs=<size>of=<outfile> bsblocksize filecontent less<file> more<file> letsyousrolltroughthecontentofa file. tail[nf] showsthelast10linesofafile nshowsthelastnlines fshowsthelast10linesandwaits forfurthercontent. cat<file> showsthecontentofafile file<file> analysescontentofafile grep[ivln]<expression><file> searchfor<expression>inafile. iignorecapital/normalspelling vshoweverythingexceptlineswith <expression> l showfilename nshowlinenumber user passwd[<user>] changepasswort the superuser root can also change thepasswordforotheruser. id[<user>] informationaboutuser who[ami] informationaboutloggedonusers. usefullcommands tar[ctxvf]<filelist> create/extractanarchive ccreate tshowcontent xextract vverbose f<file> top displayresourceusage iotop showstheI/Ousage lsl/proc/<PID>/fd/ shows which files are opened by <PID> Permission umask<permission> permission which will not be set whencreatingfileordirectory chmod[ugo=+rwx]<file> controls the basic accesspermission of<file> =setspermission +/grantsorretractpermission ugouser/group/other rwxread/write/execute process ps[efu] processinformation eeveryprocessonthesystem ffullinformation u <user> process information for a specificuser kill[19]<pid> killsaprocess 1theprocessgetsansignaltostop 9theprocesswillbekilled uname[an] informationaboutoperatingsystem nhostname a infos about version, architecture,... pgrep[lf]<pattern> searchforprocessidby<pattern> fsearch<stringalsoinparameters lprintcommandname

man<command> explanationforgivencommand apropos[s<nr>]<string> searchesforcommands Filesystem / startofthefilesystem ~ thehomedirectory . the directory in which the user is currentlyworking .. theparentdirectory pwd printsthecurrentworkingdirectory cd<directory> change position in the filesystem to <directory> withoutparameterbacktothehome directory file<file> infosaboutthecontentofafile ls[alitdr1]<name> liststhecontentofadirectory aall,includinghiddenfiles llistattributesofentries iinodenumbers tsortedbytime rreverseorder dinfosaboutthedirectoryandnot itscontent mkdir[pm]<directory> createdirectory pcreatemissingdirinapath msetaccesspermission

http://oelkers.de/tips/pocketCardShell.pdf licensedunderaCreativeCommonsAttribution3.0License 2012A.Oelkers

shell card
pkill<signal>[fl][U]<pattern> <signal>signaltobesendtoprocess UonlythisuserID/name administration useradd[d]<user> createanewuser<user> dwithhomedirectory passwd[<user>] changepassword the superuser may also change the passwordofotheruser. groupadd<group> createanewusergroup ping[c]<remotehost> beingalivecheckof<remotehost> c<count>numberofpingstosend arp[dsn] address resolution protocol information d<remotehost>deleteentryfrom s <remote host> <remote mac> insertentry nnonameresolution ifconfig[<eth0>[<ipaddress>]] interface information and manipulation netstat[an] printnetworkinformation aall ndonotresolvehostandportnames lsofi listopenconnection i4ipv4connection i:<port>connectionforthisport tracroute<remotehost> printroutetoremotehost tcpdump[vv] packetsniffer vvmoreinformation i<interface>for<interface> iptables[LFAI] maintainefilrewall Llistenetworkroules Fflushfirewall Aappendroule Iinsertroule shellbuildin positionalvariables $0 nameofscript $1$9 positionalparameters ${10} positionalparamters10 onward $# nrofpositionalparameters $* allpositionalparameters $? returnwalue [<expression>] testexpression == twostringsforequal != twostringsfornotequal -eq numericnotequal -ne numericnotequal -lt numericlessthan -gt numericgreaterthan -ge numericgreaterequal -le numericlessequal -f existsfile? -d existsdirectory? -s filecontainscontent if[<expression>] then <commands> [else] <commands> fi executescommandsdep.onexpr. case<variable>in <expression>)<commands>;; <expression>)<commands>;; *)<commands>;; esac executes commands when variablen contentequals<expression>. while[<expression>] do <commands> done repeatwhile<expression>istrue for<variablename>in<parameterlist> do <commands> done repeatforeveryparameteronce. function<name> { <commands> } definesafunction alias<name>=<command> definesaaliasforacommand read[p<string>]variablelist requestsinputfromuserandplaces itwordwiseinthevariables regularexpression . character [...] exactlyonecharinbrackets [^...] exactly one char not in bracket <re>*repeatedlythesamereg.expr. ^<re> reg.expr.atthebeginofline <re>$ reg.expressionatendofline \(<re>\)markreg.expression \nsubstitutemarkedreg.expr. & substitutefoundstring i/oredirection [0]<<file> redirectstdin.readfromfile [1]><file> redirectstdout.writetofile 2><file> redirectstderr.writetofile >>,2>> appendtofile | concatenate stdout of one commandtostdinofthenext command 2>&1 sendstderrtostdout $(<command>) commandsubstitution

usermod[acdgG]<group> modifytheuserattributes aappendgroups(onlywithG) cchangecomment dchangehomedirectory gsetprimarygroup GadditionalGroups mount t <fstype> <special device> <directory> mountingfilesystems mkfst<fstype><specialdevice> createfilesystemonspecialdevice cryptsetup[luksFormat|luksOpen] enrcpt/decryptfilesystem luksFormat<specialdevice> formatandencrypt<specialdev> luksOpen<specialdev><cryptdev> createscryptodevin/dev/mapper network

http://oelkers.de/tips/pocketCardShell.pdf licensedunderaCreativeCommonsAttribution3.0License 2012A.Oelkers