Skriptimine 2017: Difference between revisions

From ICO wiki
Jump to navigationJump to search
No edit summary
No edit summary
Line 130: Line 130:
|http://www.skrenta.com/rt/man/chgrp.1.html
|http://www.skrenta.com/rt/man/chgrp.1.html
|chgrp root /tmp/skript/myscript.sh
|chgrp root /tmp/skript/myscript.sh
 
|-
|whoami
|print effective userID
|http://www.skrenta.com/rt/man/whoami.1.html
|whoami
|-
|pwd
|print name of current/working directory
|http://www.skrenta.com/rt/man/pwd.1.html
|pwd
|}
|}



Revision as of 09:18, 6 February 2017

Hindamiskriteeriumid

Arvestuse saamiseks peab tudeng esitama järgmised tööd:

2 kodutööd
3+3 hinnangut teiste kodutöödele
Kaitstud praktikumide tööd
2 kontrolltööd

Labori keskkond

https://elab.itcollege.ee/users/sign_in

Labs -> Skriptimine 2017
Kasutaja: student
Parool: student

Praktikumide ülesanded

Ülesanne 1

Looge skript, mis jagaks etteantud grupile uue kausta

[sudo] ./jaga.sh KAUST GRUPP <JAGATUD KAUST>

Skript teeb järgnevat:

  • paigaldab samba (kui vaja)
  • loob kausta KAUST (kui vaja)
  • loob grupi GRUPP (kui vaja)
  • lisab grupile sobivad read smb.conf faili ja teeb failiserveri teenusele reload'i

Failiserveri loeng

Veebiserveri loeng

Mõistlik on konfiguratsioonist eelnevalt koopia teha ja muudatused koopiasse sisse viia. Koopiat testitakse testparm korraldusega ja kopeeritakse alles seejäral fail üle.

Ülesanne 2

Linuxi käsud

Käsk Funktsioon Man link Näidis
cd Change Directory http://www.skrenta.com/rt/man/cd.1.html cd /var/log
ls list directory contents http://www.skrenta.com/rt/man/ls.1.html ls -lah /var/log
ps report process status http://www.skrenta.com/rt/man/ps.1.html ps -ef
grep print lines matching a pattern http://www.skrenta.com/rt/man/grep.1.html grep -R 'error' /var/log/*
tail output the last parts of file http://www.skrenta.com/rt/man/tail.1.html tail -f /var/log/syslog
cat concatenate files and print on the standard output http://www.skrenta.com/rt/man/cat.1.html cat /var/log/syslog
man format and display the on-line manual pages http://www.skrenta.com/rt/man/man.1.html man man
su run a shell with substitute user and group IDs http://www.skrenta.com/rt/man/su.1.html su - root
cp copy files and directories http://www.skrenta.com/rt/man/cp.1.html cp /var/log/syslog /tmp/tmp_syslog
mv move (rename) files/directories http://www.skrenta.com/rt/man/mv.1.html mv /var/log/syslog.5 /arhiiv
rm remove files or directories http://www.skrenta.com/rt/man/rm.1.html rm /tmp/tmp_syslog
sed Stream editor http://www.skrenta.com/rt/man/sed.1.html sed -ie 's/mida/millega/g' /tmp/tmp_syslog
mkdir make directories http://www.skrenta.com/rt/man/mkdir.1.html mkdir /tmp/skript
chmod change file access premissions http://www.skrenta.com/rt/man/chmod.1.html chmod 700 /tmp/skript/myscript.sh
chown change file owner or group http://www.skrenta.com/rt/man/chown.1.html chown student:student /tmp/skript/myscript.sh
chgrp Change group ownership http://www.skrenta.com/rt/man/chgrp.1.html chgrp root /tmp/skript/myscript.sh
whoami print effective userID http://www.skrenta.com/rt/man/whoami.1.html whoami
pwd print name of current/working directory http://www.skrenta.com/rt/man/pwd.1.html pwd

Bash-i info

If lause moodustamine

if [ Funktsioon ] then
tee midagi
fi
http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_07_01.html

Exit koodid

Viimase käivitatud käsu exit koodi leiate muutujast $?
Juhul kui käsk õnnestus on exitkood 0
Juhul kui käsu käivitamisel tekkis tõrke on exit kood 0'ist erinev