Work6 REMARKS -Mε υπολογισμό χρόνου επίλυσης [vkiosses@it.teithe.gr] #!/bin/bash Imerominia=`date +%d-%m-%y` nb=`cat $arxeio wc -l` "**********" -n "The $arxeio is very important-" -n "Simera exoyme: $Imerominia-" -n "has $nb lines-" "skelos a-" "Psaxno gia ena symmathiti moy sto $arxeio-" cat $arxeio egrep -i --color 'Rigoutsou Leonarda' "skelos b-" "Den bgazei kapoio apotelesma-" cat $arxeio egrep -i --color '^[[:alpha:]]+:[^x]' # ΣΩΣΤΑ όλα έχουν x, ΑΛΛΑ # egrep -i --color '^[[:alpha:]]+:[x]' wc l δίνει 1648 και όχι 1695 γραμμές. "skelos c-" cat $arxeio egrep -i --color '^[^:]*:[^:]*:[^:]*:[[:digit:]]{3}:' "skelos d-" cat $arxeio egrep -i --color '^[^:]*:[^:]*:[^:]*:[^:]*:[^[:alpha:]]*:' wc -l "skelos e-" cat $arxeio egrep -i --color -v '^([^:]*):[^:]*:[^:]*:[^:]*:[^:]*:[^:]*\1' "My spent time was:1 Hour" μπορείς να βλέπεις τα αποτελέσματα ανά σελίδα με more, εγώ σου έβαλα sleep 3. #!/bin/bash t3user="kdeligia" "a.tin emfanizo me $t3user" "b.i maska einai 0022" umask 042 "c.kai ta tria bimata mazi" cd /tmp ; touch ergasia6askisi2 chmod g+rw ergasia6askisi2 #Ρωτά αν με την μάσκα 042,ο t3user βλέπει και γράφει? umask 022 "My spent time was:20 minutes" Την 2 η άσκηση δεν τη βάζω στο ~vassik/work, (μιας και έχει αλλαγές δικαιωμάτων).
[lrigouts@it.teithe.gr] simera=`date +%d-%m-%y` nb=`cat $arxeio wc -l` "**********" -n "The $arxeio is very important. " -n "Simera exoume $simera" -n " has $nb lines" #a erotima cat $arxeio egrep -i --color 'Vasileiadou' #b erotima #den emfanizei kapoio apotelesma cat $arxeio egrep -i --color '^[[:alpha:]]+:[^x]' #κύττα πιο πάνω vkiosses #c erotima cat $arxeio egrep -i --color '^[^:]*:[^:]*:[^:]*:[[:digit:]]{3}:' #d erotima cat $arxeio egrep -i --color '^[^:]*:[^:]*:[^:]*:[^:]*:[^[:alpha:]]*:' wc -l #e erotima cat /etc/passwd egrep -i --color -v '^([^:]*):[^:]*:[^:]*:[^:]*:[^:]*:[^:]*\1' "my spent time was : 1:10 lepta" #a erotima t3user="viosses" export t3user #gia na do tin timi patao $t3user #b erotima umask #0022 einai i arxiki mas umask 042 #tin ekana se 042 #c erotima cd /tmp touch rigoutsouleonarda chmod g+rw #ΟΧΙ κύττα πιο πάνω vkiosses umask 022 "my spent time was : 30 lepta"
[imanousi@it.teithe.gr] #Lab 6 : Ex 1 #username: imanousi #scriptfilename: passfind doc="/etc/passwd" date=`date +%d-%m-%y` nc=`cat $doc wc -l` "*********************" -n "The $doc uses black force" " huehuehue" "kidding" -n "Today $date, the file $doc nas $nc lines" #a. classmate stalking cat $doc egrep -i --color 'ktoumpid' #b. no :x: cat $doc egrep -i --color '^[^:]*:[^x]:' #c. 3 digits in groupid cat $doc egrep -i --color '^[^:]*:[^:]:[^:]*:[0-9]{3}:' #d. no name/comment cat $doc egrep -ic --color '^[^:]*:[^:]*:[^:]*:[^:]*::' wc l #e. username only once -ζητά να μην το εχει στο home dir θέλει option #π.χ.εδώ τοχει #imanousi:x:2507:1066:manousi Ilektra:/home/student/x1516/imanousi:/bin/bash #ενώ εδώ δεν το έχει #daemon:x:1:1:daemon:/usr/sbin:/bin/sh "No idea" "My spent time was: 40+ leptas" #wow... computer must have been really slow... # Lab 6: Ex 2 #username: imanousi #a. orismos metavlitis me onoma symmathiti # t3user="ktoumpid" #b. h maska dhmiourgias twn arxeiwn mou einai 022 # kai fainetai me thn entolh --> umask. # gia allagh xrhsimopoioume thn entolh --> umask 042 #c. dhmiourgoume ena adeio arxeio ston fakelo /tmp # me thn entolh --> touch emptyfile /tmp # ekteloume thn entolh --> ls -l # o t3user mporei na dei kai na grapsei to arxeio # -rw--w-r-- 1 imanousi x1516 0 Apr 3 20:28 emptyfile ΜΠΟΡΕΙ???
# giati anikei sto group # epanaferoume th maska sthn arxikh ths timh # me thn entolh --> umask 022 "a. orismos metavlitis" t3user="ktoumpid" "b. provolh maskas" umask " allagh maskas se 042" umask 042 "c. dhmiourgia kenou arxeiou ston fakelo /tmp" touch emptyfile /tmp " epanafora maskas" umask 022 "My spent time was: 25 leptas up down" [dstais@it.teithe.gr] simera=`date +%d-%m-%y` # κενό ανάμεσα εντολή και παράμετροι nb=`cat $arxeio wc -l` "*******************" -n "The $arxeio file is a very important file containing" " all users entries" -n "Today $simera, the file $arxeio" " has $nb lines" "a)student" egrep '^csotirio' /etc/passwd #μπορούσες να βάλειs και $arxeio αντί /etc/passwd "b) password is not x" egrep -c '^[^:]*:[^x]:' /etc/passwd #ΟΚ "c) 3char groupid" egrep -c '^[^:]*:[^:]*:[^:]*:...:' /etc/passwd #έτσι θαχεις και το :: # webadmin:x:81:33::/home/system/webadmin:/bin/false "d) no name " egrep -c '^[^:]*:[^:]*:[^:]*:[^:]*::' /etc/passwd "e) different username/homedir" egrep -c '^([^:]*):.*\1.*$' $arxeio # 1) με το.* δεν εξασφαλίζεις ότι # η επανάληψη θα γίνει στο 6 ο πεδίο και # 2) Θέλει όσα δεν επαναλαμβάνονται (με Option) my spend time was 20 min Bάζετε στα μηνύματα των διπλά εισαγωγικά τα ( ) είναι ειδικοί χαρακτήρες "a) " t3user="apipinik" t3user= $t3user
"b) " my mask is 755 change mask to 042 cdmod 042 # umask 042 "c) " cd /tmp # OXI η μάσκα είναι 022 (όσα αφαιρούνται) # και την βλέπεις με umask touch empty t3user can only read empty #OXI του το αφαιρεί change back mask chmod 755 # umask 022 my time spend was 15 minutes [ksianidi@it.teithe.gr] #Ergasia 6, Askisi 1 #δεν είδα το /tmp/empty σου document=$arxeio # αποφάσισε H document Η arxeio simera=`date +%d-%m-%y` nb=`cat $document wc -l` "**********************************" -n "The $arxeio is very important" -n "simera: $simera" -n " $document has $nb lines" "**********************************" a. cat $arxeio egrep -i --color 'aapostol' b. cat $arxeio egrep -i --color '^[^:]*:[^x]:' c. cat $arxeio egrep -i --color '^[^:]*:[^:]:[^:]*:[0-9]{3}:' d. cat $arxeio egrep -i --color '^[^:]*:[^:]*:[^:]*:[^:]*:[^[:alpha:]]*:' wc -l e. cat $arxeio egrep -i --color -v '^([^:]*):[^:]*:[^:]*:[^:]*:[^:]*:[^:]*\1' "My spent time was: 1+ Hour" #Ergasia 6, Askisi 2
a. t3user="aapostol" b. arxiki umask: 0022 umask 042 c. cd /tmp touch adeioarxeio #γραψε και τι γίνεται.. Μπορεί ο t3user να το δει και να το γράψει #δεν είδα το /tmp/adeioarxeio σου umask 022 " My spent time was : 20 lepta" [ckaripia@it.teithe.gr] #1st exercice of work6 #username: ckaripia #scriptfilename: passfind #orizw metavlites #result of date,to mera simera=`date +%d-%m-%y ` % Ανάποδα εισ/κά ` όταν σε μεταβλητη βάζω εκτέλεση εντολής #result of pipe, to nb nb=`cat $arxeio wc -l ` "***********" -n "the $arxeio file is a very important file containing " "all users entries " -n "Today $simera, the file $arxeio " "has $nb lines" # "1. Q..." #cat $arxeio egrep -i --color 'RE' 1. cat /etc/passwd egrep nropotos %μπορείς και εδώ να βάλεις cat $arxeio 2. cat /etc/passwd egrep '^[^:]*:[^x]:' 3. cat /etc/passwd egrep '^[^:]*:x:[0-9]*:[0-9]{3}:' 4. cat /etc/passwd egrep '^*:*:*:*::' wc -l % Mετράμε μόνο πλήθος δηλ. γραμμές 5. cat /etc/passwd egrep '^([^:]*):)x:[0-9]*:[0-9]*:.*:/.*\1' -v wc l %βγάζεις και άλλες γρ % ΟΜΑΔΑ % Λεει να μην επαναλαμβάνεται το Username στο homedir % Εσύ εκτός από τις 17 σωστές γραμμές βγάζεις και αυτές τις γρ: lp:x:7:7:lp:/var/spool/lpd:/bin/sh
backup:x:34:34:backup:/var/backups:/bin/sh irc:x:39:39:ircd:/var/run/ircd:/bin/sh postgres:x:115:117:postgresql administrator,,,:/var/lib/postgresql:/bin/bash freerad:x:116:118::/etc/freeradius:/bin/falsemessagebus:x:118:122::/var/run/dbus:/bin/false "my spent time was : 30-40 lepta " Βάζε και -color #2nd exercice of work6 #username: ckaripia t3useur=igougoul #h maska einai 022 # AΛΛΑΖΕΙΣ ΤΗΝ ΜΑΣΚΑ umask 042 # ΚΑΝΕΙΣ ΚΑΙ ΤΟ ΑΡΧΕΙΟ στο /tmp touch /tmp/arxeio #otan 8esoume thn maska se 042 tote afairite apo ta dikaiomata tis omadas to read #kai etsi kai den mporei na to diavasei.. ΝΑΙ, αν ο igougoul είναι στο ίδιο group # με σένα, Αλλά δεν είναι.. umask 022 "my spent time was "10 lepta" [npertsel@it.teithe.gr] #!/bin/bash #1st exercise of work6 #username: Pertselis Nikiforos (npertsel) #scriptfilename: passfind #orizw metavlites #result of date, to mera simera=`date +%d-%m-%y` #result of pipe, to nb nb=`cat $arxeio wc -l` "*********************" -n "The $arxeio file is a very important file containing" " all users entries" -n "Today $simera, the file $arxeio" "has $nb lines" "*********************" "1." cat $arxeio egrep -i --color 'ksianidi'
"2." cat $arxeio egrep -i --color '^*:[^x]:' #ΠΡΟΣΟΧΗ * σημαίνει επαναληψη του προηγ/νου #αλλά δεν έβαλες κάτι πριν, ΘΕΛΕΙ '^[^:]*:[^x]:' "3. cat $arxeio egrep -i --color '^[^:]*:[^:]*:[^:]*:[0-9]{3}:' #το ίδιο και εδώ "4." cat $arxeio egrep -ic --color '^[^:]*:[^:]*:[^:]*:[^:]*::' #το ίδιο και εδώ "5." cat $arxeio egrep -i -v -c '^([^:]*):x:[^:]*:[^:]*:[^:]*:/.*\1.*:' #το διόρθωσα, είχες και ένα πεδίο παραπάνω "My spent time was : ~40 lepta" #2st exercice of work6 #username: Nikiforos Pertselis npertsel #scriptfilename: Work6Arxeio2 t3user="kdeligia" $t3user um=`umask` "umask=" $um #H maska dimiourgias twn arxeiwn einai 0022 um2=`umask 042` "new umask=" $um2 #H nea maska einai 042 #O xrhsths me umask=022 eixe to dikaiwma read. #Otan allaksame tin umask=042 tote to read katargithike #ΝΑΙ γιατί είστε στο ίδιο group # "my spent time was ~15 lepta [aapostol@it.teithe.gr] #erg6ask1 document=$arxeio simera=`date +%d-%m-%y` nb=`cat $document wc -l` "**********************************" -n "The $arxeio is very important" -n "simera: $simera" -n " $document has $nb lines" "**********************************" "1 " # Αυτή η γραμμούλα είναι το pipe και περιμένει εντολή cat $arxeio egrep -i --color 'ksianidi' "2 "
cat $arxeio egrep -i --color '^[^:]*:[^x]:' "3 " cat $arxeio egrep -i --color '^[^:]*:[^:]*:[^:]*:[0-9]{3}:' #Αν και στο 2 ο πεδίο έχει 1 χαρακτήρα μόνο, το x "4 " cat $arxeio egrep -i --color '^[^:]*:[^:]*:[^:]*:[^:]*:[^[:alpha:]]*:' wc -l "5 " cat $arxeio egrep -i --color -v '^([^:]*):[^:]*:[^:]*:[^:]*:[^:]*:[^:]*\1' "My spent time was: 1:30 Hour" #aapostol #ΔΕΝ ΔΙΟΡΘΩΝΩ ΓΡΑΜΜΕΣ ΘΕΩΡΗΤΙΚΑ AYTO EINAI ΕΝΑ ΤΕΧΤ FILE #Erg6ask2 1 t3user="ksianidi" 2 arxiki umask: 0022 umask 042 3 cd /tmp o xristis mporei na to kanei read and write #είστε στο ίδιο group touch adeioarxeio #έκανες αρχείο στο /tmp? /tmp/adeioarxeio umask 022 " My spent time was : 30 lepta" [kdeligia@it.teithe.gr] #1st exercice of work6 #username: kdeligia #scriptfilename: passfind simera=`date +%d-%m-%y` nb=`cat $arxeio wc -l` "*******************" $arxeio $simera " has $nb lines" "1.1" cat $arxeio egrep -i --color 'npertsel' "1.2" cat $arxeio egrep -1 --color '^[^:]*:[^x]:' # ποτε το * μόνο του, δεν βγάζει γραμμές "1.3"
cat $arxeio egrep -1 --color '^[^:]*:[^:]*:[^:]*:[0-9]{3}:' "1.4" cat $arxeio egrep -i --color '^[^:]*:[^:]*:[^:]*:[^:]*:[^[:alpha:]]*:' wc -l "1.5" cat /etc/passwd egrep -i --color -v '^([^:]*):[^:]*:[^:]*:[^:]*:[^:]*:[^:]*\1' "2.1" t3user="ktoumpid" "2.2" #h maska dhmiourgias einai 022 umask 042 #o t3user afou einai sto idio group mporei mono na gracei sto arxeio #4=r 2=w 1=e #1st exercice of work6 #username:$user #scriptfilename: passfind #orizw metavlites #result of date, to mera simera=`date +%d-%m-%y` #Aνάποδα ` αυτάκια #result of pipe, to nb nb=`cat $arxeio wc l` #Aνάποδα ` "*******************" -n "The $arxeio file is a very important file containing" " all users entries" -n "Today $simera, the file $arxeio" " has $nb lines" #=======askisi 1============== 1. cat $arxeio egrep -i --color 'dstais' 2. cat $arxeio egrep -i --color '^[^:]*:[^x]:' 3. cat $arxeio egrep -i --color '^[^:]*:[^:]:[^:]*:[0-9]{3}:' 4. cat $arxeio egrep -ic --color '^[^:]*:[^:]*:[^:]*:[^:]*::' 5. cat $arxeio egrep -i --color '^([^:]*):([^:]*:){4}[^:]*\1' v #ή αν θες πιο μακρυνάρι cat $arxeio egrep -i --color '^([^:]*):x:[^:]*:[^:]*:[^:]*:[^:]*\1' v #Το \1 δηλώνει ότι θα επαναληφθεί ότι υπάρχει στην 1 η παρένθεση "my spent time was 40 minutes"
#============askisi 2======= 1. t3user="vzafeiri" 2. umask is 022 umask 042 3. touch /tmp/igougoulf oxi dn mporei na diabasei, giati eimaiste sto idio group kai ebgala to read allazwntas thn maska umask 022 "my spent time was 20 minutes" [apipinik@it.teithe.gr] #1st exercice of work6 #apipinik #scriptfilename: passfind #orizw metavlites #result of date, to mera simera=`date +%d-%m-$y` #result of pipe, to nb nb=`cat $arxeio wc -l` "***************************" -n "The $arxeio file is a very important file containing" " all users entries" -n "Today $simera, the file $arxeio" " has $nb lines" # "1.Question" cat $arxeio egrep -i --color 'kdeligia' # "2.Question" cat $arxeio egrep -i --color '^[^:]*:[^x]:' # "3.Question" cat $arxeio egrep -i --color '^[^:]*:[^:]:[^:]*:[0-9]{3}:' # "4.Question" cat $arxeio egrep -i --color '^[^:]*:[^:]*:[^:]*:[^:]*:[^[:alpha:]]*:' wc -l # "5.Question" cat $arxeio egrep -v -i --color '^([^:]*):[^:]*:[^:]*:[^:]*:[^:]*:[^:]*\1' "time: 40 lepta"