corso linux base6a6dd749d45b31800043-ac4a3725e61182359611c8fa3232924b.r91.cf3.rackc… ·...
TRANSCRIPT
![Page 1: Corso Linux Base6a6dd749d45b31800043-ac4a3725e61182359611c8fa3232924b.r91.cf3.rackc… · 2014-07-09 · GNU/Linux: concetti di base 15 • / Radice (root) • /rootHome dell'utente](https://reader030.vdocuments.pub/reader030/viewer/2022040514/5e6b08352d68bc7d7f3a0ee7/html5/thumbnails/1.jpg)
GNU/LinuxConcetti di base
![Page 2: Corso Linux Base6a6dd749d45b31800043-ac4a3725e61182359611c8fa3232924b.r91.cf3.rackc… · 2014-07-09 · GNU/Linux: concetti di base 15 • / Radice (root) • /rootHome dell'utente](https://reader030.vdocuments.pub/reader030/viewer/2022040514/5e6b08352d68bc7d7f3a0ee7/html5/thumbnails/2.jpg)
2GNU/Linux: concetti di base
Sommario
• GNU/Linux• Open Source e GPL• Login/Logout• Shell e comandi• Files• Stdin, stdout• Redirezione e pipe• Filesystem
![Page 3: Corso Linux Base6a6dd749d45b31800043-ac4a3725e61182359611c8fa3232924b.r91.cf3.rackc… · 2014-07-09 · GNU/Linux: concetti di base 15 • / Radice (root) • /rootHome dell'utente](https://reader030.vdocuments.pub/reader030/viewer/2022040514/5e6b08352d68bc7d7f3a0ee7/html5/thumbnails/3.jpg)
3GNU/Linux: concetti di base
Cos'è Linux
● Linux è basato su UNIX (filosofia, comandi, convenzioni)
● Linux Kernel (by Linus Torvalds) + GNU utilities
● Distribuzioni Linux (RedHat, NethServer, Ubuntu, Fedora, Slackware, ...)
![Page 4: Corso Linux Base6a6dd749d45b31800043-ac4a3725e61182359611c8fa3232924b.r91.cf3.rackc… · 2014-07-09 · GNU/Linux: concetti di base 15 • / Radice (root) • /rootHome dell'utente](https://reader030.vdocuments.pub/reader030/viewer/2022040514/5e6b08352d68bc7d7f3a0ee7/html5/thumbnails/4.jpg)
4GNU/Linux: concetti di base
Architettura UNIX
![Page 5: Corso Linux Base6a6dd749d45b31800043-ac4a3725e61182359611c8fa3232924b.r91.cf3.rackc… · 2014-07-09 · GNU/Linux: concetti di base 15 • / Radice (root) • /rootHome dell'utente](https://reader030.vdocuments.pub/reader030/viewer/2022040514/5e6b08352d68bc7d7f3a0ee7/html5/thumbnails/5.jpg)
5GNU/Linux: concetti di base
OpenSource e GPL
• Concetto di Software Open Source
• Licenze Open (GPL, MIT, BSD, …)
• GitHub
![Page 6: Corso Linux Base6a6dd749d45b31800043-ac4a3725e61182359611c8fa3232924b.r91.cf3.rackc… · 2014-07-09 · GNU/Linux: concetti di base 15 • / Radice (root) • /rootHome dell'utente](https://reader030.vdocuments.pub/reader030/viewer/2022040514/5e6b08352d68bc7d7f3a0ee7/html5/thumbnails/6.jpg)
6GNU/Linux: concetti di base
Login e Logout
• Login• Login grafico (X)• Shell
• Logout• exit• Ctrl+D
![Page 7: Corso Linux Base6a6dd749d45b31800043-ac4a3725e61182359611c8fa3232924b.r91.cf3.rackc… · 2014-07-09 · GNU/Linux: concetti di base 15 • / Radice (root) • /rootHome dell'utente](https://reader030.vdocuments.pub/reader030/viewer/2022040514/5e6b08352d68bc7d7f3a0ee7/html5/thumbnails/7.jpg)
7GNU/Linux: concetti di base
Shell
• Strumento veloce, flessibile e potente
• bash
• readline, history, scripting, wildcards
• manuale comandi (man)
![Page 8: Corso Linux Base6a6dd749d45b31800043-ac4a3725e61182359611c8fa3232924b.r91.cf3.rackc… · 2014-07-09 · GNU/Linux: concetti di base 15 • / Radice (root) • /rootHome dell'utente](https://reader030.vdocuments.pub/reader030/viewer/2022040514/5e6b08352d68bc7d7f3a0ee7/html5/thumbnails/8.jpg)
8GNU/Linux: concetti di base
Comandi
• Sono dei file eseguibili
• Possono accettare argomenti (es. echo Hello friend!)
• Case sensitive!
![Page 9: Corso Linux Base6a6dd749d45b31800043-ac4a3725e61182359611c8fa3232924b.r91.cf3.rackc… · 2014-07-09 · GNU/Linux: concetti di base 15 • / Radice (root) • /rootHome dell'utente](https://reader030.vdocuments.pub/reader030/viewer/2022040514/5e6b08352d68bc7d7f3a0ee7/html5/thumbnails/9.jpg)
9GNU/Linux: concetti di base
Alcuni comandi utili
• Cambiare la password ad un utente: passwd
• Diventare root: su -
• Chi sono? whoami, id
• Chi c'è? w, who, last
![Page 10: Corso Linux Base6a6dd749d45b31800043-ac4a3725e61182359611c8fa3232924b.r91.cf3.rackc… · 2014-07-09 · GNU/Linux: concetti di base 15 • / Radice (root) • /rootHome dell'utente](https://reader030.vdocuments.pub/reader030/viewer/2022040514/5e6b08352d68bc7d7f3a0ee7/html5/thumbnails/10.jpg)
10GNU/Linux: concetti di base
Tutto è un file
• In Linux è tutto un file (dispositivi, stdin, stdout, …)
• Possono contenere dati (testo, binari, …)
• Ogni file ha un nome ([A-z0-9-._])
• Alcuni comandi sui file: ls, ln, cp, mv
![Page 11: Corso Linux Base6a6dd749d45b31800043-ac4a3725e61182359611c8fa3232924b.r91.cf3.rackc… · 2014-07-09 · GNU/Linux: concetti di base 15 • / Radice (root) • /rootHome dell'utente](https://reader030.vdocuments.pub/reader030/viewer/2022040514/5e6b08352d68bc7d7f3a0ee7/html5/thumbnails/11.jpg)
11GNU/Linux: concetti di base
Stdin/out
• stdin <
• stdout >
• stderr 2>
![Page 12: Corso Linux Base6a6dd749d45b31800043-ac4a3725e61182359611c8fa3232924b.r91.cf3.rackc… · 2014-07-09 · GNU/Linux: concetti di base 15 • / Radice (root) • /rootHome dell'utente](https://reader030.vdocuments.pub/reader030/viewer/2022040514/5e6b08352d68bc7d7f3a0ee7/html5/thumbnails/12.jpg)
12GNU/Linux: concetti di base
Redirezione e pipe
• cat > lista_nomi
• cat lista_nomi > /dev/null
• ridirigere lo stdout sullo stdin: pipe• cat lista_nomi | grep giovanni
![Page 13: Corso Linux Base6a6dd749d45b31800043-ac4a3725e61182359611c8fa3232924b.r91.cf3.rackc… · 2014-07-09 · GNU/Linux: concetti di base 15 • / Radice (root) • /rootHome dell'utente](https://reader030.vdocuments.pub/reader030/viewer/2022040514/5e6b08352d68bc7d7f3a0ee7/html5/thumbnails/13.jpg)
13GNU/Linux: concetti di base
• ext2, ext3, ext4, …
• directory, file e link• device files (/dev)• special files (/proc)
• Journaling (ext3, ext4, NTFS, reiserFS, jfs, ...)
Filesystem
![Page 14: Corso Linux Base6a6dd749d45b31800043-ac4a3725e61182359611c8fa3232924b.r91.cf3.rackc… · 2014-07-09 · GNU/Linux: concetti di base 15 • / Radice (root) • /rootHome dell'utente](https://reader030.vdocuments.pub/reader030/viewer/2022040514/5e6b08352d68bc7d7f3a0ee7/html5/thumbnails/14.jpg)
14GNU/Linux: concetti di base
• fdisk -l /dev/sda
• pwd, cd, ls, mkdir, rmdir, rm
• Mount/unmount
• mkfs, fsck
• du, df
Comandi utili (filesystem)
![Page 15: Corso Linux Base6a6dd749d45b31800043-ac4a3725e61182359611c8fa3232924b.r91.cf3.rackc… · 2014-07-09 · GNU/Linux: concetti di base 15 • / Radice (root) • /rootHome dell'utente](https://reader030.vdocuments.pub/reader030/viewer/2022040514/5e6b08352d68bc7d7f3a0ee7/html5/thumbnails/15.jpg)
15GNU/Linux: concetti di base
• / Radice (root)
• /rootHome dell'utente root
• /boot immagini del kernel e file indispensabili al bootstrap
• /etc file di configurazione del sistema e dei programmi installati
• /home home degli utenti tranne root
• /usr binari, documentazione, librerie e sorgenti della maggior parte dei programmi
• /var informazioni dinamiche come log, pid file, directory di spool
• /proc File system virtuale contiene dati dinamici sul sistema e sui processi
• /dev file per la gestione dei device
• /sbincomandi e programmi riservati a root (anche /usr/sbin/ )
• /bin comandi e programmi base per tutti gli utenti (/usr/bin/ )
Struttura filesystem
![Page 16: Corso Linux Base6a6dd749d45b31800043-ac4a3725e61182359611c8fa3232924b.r91.cf3.rackc… · 2014-07-09 · GNU/Linux: concetti di base 15 • / Radice (root) • /rootHome dell'utente](https://reader030.vdocuments.pub/reader030/viewer/2022040514/5e6b08352d68bc7d7f3a0ee7/html5/thumbnails/16.jpg)
16GNU/Linux: concetti di base
Sommario
• Editor di testo• Utenti e permessi• Processi• Servizi e demoni• Schedulatore cron
![Page 17: Corso Linux Base6a6dd749d45b31800043-ac4a3725e61182359611c8fa3232924b.r91.cf3.rackc… · 2014-07-09 · GNU/Linux: concetti di base 15 • / Radice (root) • /rootHome dell'utente](https://reader030.vdocuments.pub/reader030/viewer/2022040514/5e6b08352d68bc7d7f3a0ee7/html5/thumbnails/17.jpg)
17GNU/Linux: concetti di base
• Editor di testo: vi, nano
Editor di testo
![Page 18: Corso Linux Base6a6dd749d45b31800043-ac4a3725e61182359611c8fa3232924b.r91.cf3.rackc… · 2014-07-09 · GNU/Linux: concetti di base 15 • / Radice (root) • /rootHome dell'utente](https://reader030.vdocuments.pub/reader030/viewer/2022040514/5e6b08352d68bc7d7f3a0ee7/html5/thumbnails/18.jpg)
18GNU/Linux: concetti di base
vi
• Creato per Unix nel 1976• Numerosi cloni • Veloce• Potente• Lo troviamo in tutti i sistemi• Vim• Non è semplice da usare
![Page 19: Corso Linux Base6a6dd749d45b31800043-ac4a3725e61182359611c8fa3232924b.r91.cf3.rackc… · 2014-07-09 · GNU/Linux: concetti di base 15 • / Radice (root) • /rootHome dell'utente](https://reader030.vdocuments.pub/reader030/viewer/2022040514/5e6b08352d68bc7d7f3a0ee7/html5/thumbnails/19.jpg)
19GNU/Linux: concetti di base
nano
• Semplice• Molto leggero• È presente in quasi tutti i sistemi
![Page 20: Corso Linux Base6a6dd749d45b31800043-ac4a3725e61182359611c8fa3232924b.r91.cf3.rackc… · 2014-07-09 · GNU/Linux: concetti di base 15 • / Radice (root) • /rootHome dell'utente](https://reader030.vdocuments.pub/reader030/viewer/2022040514/5e6b08352d68bc7d7f3a0ee7/html5/thumbnails/20.jpg)
20GNU/Linux: concetti di base
• Sistema multiutente• User• Group• Other
• Read• Write• Execute
UGO rwx
![Page 21: Corso Linux Base6a6dd749d45b31800043-ac4a3725e61182359611c8fa3232924b.r91.cf3.rackc… · 2014-07-09 · GNU/Linux: concetti di base 15 • / Radice (root) • /rootHome dell'utente](https://reader030.vdocuments.pub/reader030/viewer/2022040514/5e6b08352d68bc7d7f3a0ee7/html5/thumbnails/21.jpg)
21GNU/Linux: concetti di base
Utenti e permessi
• ls -l-rw-rw-r-- 1 test test 0 9 ott 12:54 test_file
Gruppo Utente
Permessi “Other” Permessi “Group” Permessi “User” Tipo di file
• Comandi: chown, chgrp, chmod
![Page 22: Corso Linux Base6a6dd749d45b31800043-ac4a3725e61182359611c8fa3232924b.r91.cf3.rackc… · 2014-07-09 · GNU/Linux: concetti di base 15 • / Radice (root) • /rootHome dell'utente](https://reader030.vdocuments.pub/reader030/viewer/2022040514/5e6b08352d68bc7d7f3a0ee7/html5/thumbnails/22.jpg)
22GNU/Linux: concetti di base
Processi
• Comando = processo• PID PPID• ps e top• kill, killall e segnali• priorità (da -20 a +19), nice, renice
![Page 23: Corso Linux Base6a6dd749d45b31800043-ac4a3725e61182359611c8fa3232924b.r91.cf3.rackc… · 2014-07-09 · GNU/Linux: concetti di base 15 • / Radice (root) • /rootHome dell'utente](https://reader030.vdocuments.pub/reader030/viewer/2022040514/5e6b08352d68bc7d7f3a0ee7/html5/thumbnails/23.jpg)
23GNU/Linux: concetti di base
Processi
init
ready running
zombie
terminated
sleeping
swapped
creazione terminazione
![Page 24: Corso Linux Base6a6dd749d45b31800043-ac4a3725e61182359611c8fa3232924b.r91.cf3.rackc… · 2014-07-09 · GNU/Linux: concetti di base 15 • / Radice (root) • /rootHome dell'utente](https://reader030.vdocuments.pub/reader030/viewer/2022040514/5e6b08352d68bc7d7f3a0ee7/html5/thumbnails/24.jpg)
24GNU/Linux: concetti di base
• Init è il primo processo che il kernel manda in esecuzione
• Avvia i demoni ed i servizi• I demoni eseguono compiti in
background, senza che l'utente debba preoccuparsene
• Non usano stdin/stdout/stderr
Servizi e demoni
![Page 25: Corso Linux Base6a6dd749d45b31800043-ac4a3725e61182359611c8fa3232924b.r91.cf3.rackc… · 2014-07-09 · GNU/Linux: concetti di base 15 • / Radice (root) • /rootHome dell'utente](https://reader030.vdocuments.pub/reader030/viewer/2022040514/5e6b08352d68bc7d7f3a0ee7/html5/thumbnails/25.jpg)
25GNU/Linux: concetti di base
• Servizi demoni tipici• Cron• Httpd• Asterisk• Dovecot• Ardad
Servizi e demoni
![Page 26: Corso Linux Base6a6dd749d45b31800043-ac4a3725e61182359611c8fa3232924b.r91.cf3.rackc… · 2014-07-09 · GNU/Linux: concetti di base 15 • / Radice (root) • /rootHome dell'utente](https://reader030.vdocuments.pub/reader030/viewer/2022040514/5e6b08352d68bc7d7f3a0ee7/html5/thumbnails/26.jpg)
26GNU/Linux: concetti di base
• Demone che lancia comandi in un momento specificato
• File di configurazione: /etc/crontab• cron.d un file per task, stessa sintassi• cron.daily, cron.monthly... crontab fa
eseguire a cron gli script in queste cartelle
Schedulatore cron
![Page 27: Corso Linux Base6a6dd749d45b31800043-ac4a3725e61182359611c8fa3232924b.r91.cf3.rackc… · 2014-07-09 · GNU/Linux: concetti di base 15 • / Radice (root) • /rootHome dell'utente](https://reader030.vdocuments.pub/reader030/viewer/2022040514/5e6b08352d68bc7d7f3a0ee7/html5/thumbnails/27.jpg)
27GNU/Linux: concetti di base
• 55 3 * * * root squid -k rotate comando
utente Giorno della settimana (0-7) mese (1 - 12) giorno del mese (1 - 31) Ore (0 – 23) minuti (0 - 59)
Schedulatore cron
![Page 28: Corso Linux Base6a6dd749d45b31800043-ac4a3725e61182359611c8fa3232924b.r91.cf3.rackc… · 2014-07-09 · GNU/Linux: concetti di base 15 • / Radice (root) • /rootHome dell'utente](https://reader030.vdocuments.pub/reader030/viewer/2022040514/5e6b08352d68bc7d7f3a0ee7/html5/thumbnails/28.jpg)
28GNU/Linux: concetti di base
Sommario 2
• Bash• Rete - tcpdump• Archivi• Distribuzione software• Log e troubleshooting
![Page 29: Corso Linux Base6a6dd749d45b31800043-ac4a3725e61182359611c8fa3232924b.r91.cf3.rackc… · 2014-07-09 · GNU/Linux: concetti di base 15 • / Radice (root) • /rootHome dell'utente](https://reader030.vdocuments.pub/reader030/viewer/2022040514/5e6b08352d68bc7d7f3a0ee7/html5/thumbnails/29.jpg)
29GNU/Linux: concetti di base
Bash
• History (CTRL-R, frecce su/giù)• TAB completion• Wildcard (*)
• ls /var/log/*.log
![Page 30: Corso Linux Base6a6dd749d45b31800043-ac4a3725e61182359611c8fa3232924b.r91.cf3.rackc… · 2014-07-09 · GNU/Linux: concetti di base 15 • / Radice (root) • /rootHome dell'utente](https://reader030.vdocuments.pub/reader030/viewer/2022040514/5e6b08352d68bc7d7f3a0ee7/html5/thumbnails/30.jpg)
30GNU/Linux: concetti di base
Rete
• Nomi:• ethX (es. eth0, eth1)• pppX, brX, ethX:Y
• Manipolazione interfacce:• File di configurazione• ifconfig
• Rotte:• route
![Page 31: Corso Linux Base6a6dd749d45b31800043-ac4a3725e61182359611c8fa3232924b.r91.cf3.rackc… · 2014-07-09 · GNU/Linux: concetti di base 15 • / Radice (root) • /rootHome dell'utente](https://reader030.vdocuments.pub/reader030/viewer/2022040514/5e6b08352d68bc7d7f3a0ee7/html5/thumbnails/31.jpg)
31GNU/Linux: concetti di base
Rete - Troubleshooting
• Raggiungibilità • ping• tracepath / traceroute• arp -an
• Risoluzione nomi• host• dig
![Page 32: Corso Linux Base6a6dd749d45b31800043-ac4a3725e61182359611c8fa3232924b.r91.cf3.rackc… · 2014-07-09 · GNU/Linux: concetti di base 15 • / Radice (root) • /rootHome dell'utente](https://reader030.vdocuments.pub/reader030/viewer/2022040514/5e6b08352d68bc7d7f3a0ee7/html5/thumbnails/32.jpg)
32GNU/Linux: concetti di base
Rete - Troubleshooting
• Pacchetti TCP/IP• tcpdump
• Connessioni e porte aperte• netstat• nc
![Page 33: Corso Linux Base6a6dd749d45b31800043-ac4a3725e61182359611c8fa3232924b.r91.cf3.rackc… · 2014-07-09 · GNU/Linux: concetti di base 15 • / Radice (root) • /rootHome dell'utente](https://reader030.vdocuments.pub/reader030/viewer/2022040514/5e6b08352d68bc7d7f3a0ee7/html5/thumbnails/33.jpg)
33GNU/Linux: concetti di base
Archivi di file
• Formati• zip• tar• tar.gz (tgz), tar.bz2 (tbz2)
• Comandi• tar cvzf file.tgz file1 file2• gzip file
![Page 34: Corso Linux Base6a6dd749d45b31800043-ac4a3725e61182359611c8fa3232924b.r91.cf3.rackc… · 2014-07-09 · GNU/Linux: concetti di base 15 • / Radice (root) • /rootHome dell'utente](https://reader030.vdocuments.pub/reader030/viewer/2022040514/5e6b08352d68bc7d7f3a0ee7/html5/thumbnails/34.jpg)
34GNU/Linux: concetti di base
Distribuzione software
• Pacchetti Linux:• RPM (Red Hat / CentOS)• DEB (Debain / Ubuntu)• Firmati digitalmente• Risoluzione dipendenze
• Repository • apt (Debian / Ubuntu)• yum (Red Hat / CentOS)
![Page 35: Corso Linux Base6a6dd749d45b31800043-ac4a3725e61182359611c8fa3232924b.r91.cf3.rackc… · 2014-07-09 · GNU/Linux: concetti di base 15 • / Radice (root) • /rootHome dell'utente](https://reader030.vdocuments.pub/reader030/viewer/2022040514/5e6b08352d68bc7d7f3a0ee7/html5/thumbnails/35.jpg)
35GNU/Linux: concetti di base
Log
• /var/log/messages• dmesg• Manipolazione file di testo
• cat• grep• less• tail• cut• sort• wc
![Page 36: Corso Linux Base6a6dd749d45b31800043-ac4a3725e61182359611c8fa3232924b.r91.cf3.rackc… · 2014-07-09 · GNU/Linux: concetti di base 15 • / Radice (root) • /rootHome dell'utente](https://reader030.vdocuments.pub/reader030/viewer/2022040514/5e6b08352d68bc7d7f3a0ee7/html5/thumbnails/36.jpg)
36GNU/Linux: concetti di base
Riferimenti
• Google• TLDP - http://www.tldp.org/
• ILS - http://www.linux.it/
• Appunti di informatica libera - http://a2.swlibero.org/
![Page 37: Corso Linux Base6a6dd749d45b31800043-ac4a3725e61182359611c8fa3232924b.r91.cf3.rackc… · 2014-07-09 · GNU/Linux: concetti di base 15 • / Radice (root) • /rootHome dell'utente](https://reader030.vdocuments.pub/reader030/viewer/2022040514/5e6b08352d68bc7d7f3a0ee7/html5/thumbnails/37.jpg)
37GNU/Linux: concetti di base
• Demone che lancia comandi in un momento specificato
• File di configurazione: /etc/crontab• cron.d un file per task, stessa sintassi• cron.daily, cron.monthly... crontab fa
eseguire a cron gli script in queste cartelle • 55 3 * * * root squid -k rotate
Schedulatore cron