notes.tex 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. \documentclass{report}
  2. \usepackage[T1] {fontenc}
  3. \usepackage[italian]{babel}
  4. % Per i link nell'indice
  5. \usepackage{hyperref}
  6. \title{OpenLab Virtual 2021}
  7. \author{Matteo Savatteri}
  8. \begin{document}
  9. \maketitle
  10. \setcounter{page}{2}
  11. \tableofcontents
  12. \chapter{GNU/Linux Intro, Tips \& Tricks}
  13. \section{Introduzione}
  14. \begin{itemize}
  15. \item Benvenuto e ringraziamenti ad admin e pubblico
  16. \item Chi sono?
  17. \item Cos'è LCM?
  18. \item Regole conferenza: come interagire
  19. \item Outline e obbiettivi conferenza:
  20. \begin{itemize}
  21. \item Storia di \texttt{GNU/Linux}
  22. \item \texttt{GNU/Linux} per un fisico
  23. \item \texttt{GNU/Linux}: nozioni e strumenti importanti
  24. \item Testimonianze ospiti + domande
  25. \end{itemize}
  26. \end{itemize}
  27. \section{Storia di \texttt{GNU/Linux}}
  28. \begin{itemize}
  29. \item \texttt{UNIX}
  30. \footnote{Video \emph{AT\&T Archives} introduzione a \texttt{UNIX} a
  31. \url{https://youtu.be/tc4ROCJYbm0}
  32. }
  33. (\emph{Uniplexed Information and Computing Service}, "\emph{eunuchs}"),
  34. '69, Ken Thompson, Dennis Ritchie, Brian Kernighan \& Co., Assembly:
  35. \begin{itemize}
  36. \item Filosofia di UNIX:
  37. \emph{
  38. "This is the Unix philosophy: Write programs that do one thing
  39. and do it well. Write programs to work together. Write programs
  40. to handle text streams, because that is a universal interface."
  41. }
  42. - Doug McIlroy
  43. \item AT\&T, Bell Labs
  44. \item '69-73, sviluppo del C, K.T. \& D.R. $\rightarrow$ Portabilità
  45. \item Distribuzione università (es. Berkeley, BSD) $\rightarrow$ Codice aperto
  46. \item '84 commercializzazione $\rightarrow$ Codice chiuso!
  47. \item Standard:
  48. \begin{itemize}
  49. \item '85 POSIX (Portable Operating System Interface for UNIX), IEEE
  50. \item '98 SUS (Single UNIX Specification), The Open Group
  51. \end{itemize}
  52. \end{itemize}
  53. \item GNU (\emph{GNU's Not UNIX}), '84, Richard Stallman:
  54. \begin{itemize}
  55. \item Sistema operativo Libero (cosa significa?)
  56. \footnote{Per approfondire vai a https://www.fsf.org/it}
  57. clone di \texttt{UNIX}
  58. \item '90 Sviluppo di tutte le componenti del sistema
  59. \item Esempi software GNU: \texttt{gcc}, \texttt{glibc}, \texttt{bash},
  60. \texttt{coreutils}, \texttt{GNOME}, etc.
  61. \item '90 inizia sviluppo \texttt{GNU Hurd}
  62. \end{itemize}
  63. \item Digressione su OS:
  64. \begin{itemize}
  65. \item OS = Insieme di programmi che consentono all'operatore
  66. di utilizzare un computer
  67. \item Kernel = Nucleo dell'OS deputato ad allocare le risorse
  68. della macchina e altri servizi agli altri programmi
  69. \end{itemize}
  70. \item \texttt{Linux}\footnote{Pronuncia del nome \texttt{Linux} a
  71. \url{https://mirrors.edge.kernel.org/pub/linux/kernel/SillySounds/}
  72. }
  73. , '91, Linus Torvalds:
  74. \begin{itemize}
  75. \item Progetto personale annunciato su
  76. \href{https://groups.google.com/g/comp.os.minix/c/dlNtH7RRrGA/m/SwRavCzVE7gJ}{com.os.minix}
  77. \item Kernel Libero (GNU GPLv2), Monolitico, Modulare, UNIX-like
  78. \item '92 \texttt{Linux} diventa kernel del sistema \texttt{GNU}
  79. \item Adozione in ambito commerciale
  80. \item Prima diffusione in supercomputer (
  81. \href{https://top500.org/statistics/list/}{Vedi TOP500 OS Family}
  82. )
  83. \item Poi leader in ambito server
  84. \footnote{Guarda ad esempio statistiche su web server a
  85. \url{https://w3techs.com/technologies/overview/operating_system}
  86. }
  87. (in particolare LAMP)
  88. \item 2000, Linux Foudation $\rightarrow$ LSB (\emph{Linux Standard Base})
  89. Standardizzazione OS che adottano kernel \texttt{Linux}
  90. (Da tempo \emph{standard de facto})
  91. \item Oggi diffuso in dispositivi mobili (\texttt{Android}), embedded
  92. (router board, wearables) e altre applicazioni (es. \emph{TESLA})
  93. \item Percentuale diffusione workstation, desktop, laptop e gaming
  94. (es. Valve Corporation, SteamOS) in crescita
  95. \end{itemize}
  96. \item Concetto ed esempi di distribuzione \texttt{GNU/Linux} (Ubuntu, Mint, Fedora, Arch, Gentoo, Debian,
  97. CentOS, RHEL, SUSE, LFS, OpenWRT, Raspbian); cosa distingue varie distro? $\rightarrow$
  98. \emph{package manager}, \emph{init system}, configuarzione kernel \texttt{Linux}, etc.
  99. \end{itemize}
  100. \section{\texttt{GNU/Linux} per un Fisico}
  101. Perhé un fisico dovrebbe conoscere ed utilizzare il sistema \texttt{GNU/Linux}?
  102. \begin{itemize}
  103. \item Cluster di computer e farm (es.
  104. \href{https://www.hpc.cineca.it/hardware/marconi}{MARCONI},
  105. \href{https://www.indaco.unimi.it/}{INDACO},
  106. \href{https://lcm.mi.infn.it/farm/}{LCM Farm}
  107. ) nel mondo sono quasi
  108. interamente costituite da reti di sistemi \texttt{GNU/Linux} (es. CentOS, RHEL, Debian)
  109. \item Codice libero = adattabilità, trasparenza, riproducibilità, no interessi
  110. \item Calcolo scientifico ha storia basata su sistemi UNIX-like da decadi
  111. $\rightarrow$ applicazioni vengono prevalentemente sviluppate su e per
  112. questa famiglia di sistemi
  113. \item Tutte le persone dovrebbero usare un OS Libero, per ragioni etiche
  114. \end{itemize}
  115. \section{Presentazioni ospiti}
  116. \begin{itemize}
  117. \item Ospiti: Zec, Sboz, Blue, Algebrato (?)
  118. \item 5 min a testa
  119. \item Domande
  120. \end{itemize}
  121. \section{Chiusura}
  122. \begin{itemize}
  123. \item Repo dell'\emph{OpenLab}, cosa trovate, licenza
  124. \item Contatti LCM: sito, gruppo community, mail
  125. \item Saluti
  126. \end{itemize}
  127. \chapter{CLI Essential and Shell Programming}
  128. \section{Nozioni e Strumenti}
  129. \subsection{Setup}
  130. \begin{itemize}
  131. \item Vedete il terminale?
  132. \item Il font è abbastanza grande?
  133. \item Vedete il puntatore?
  134. \item Non andare troppo veloce
  135. \item Spiega che tasti premi, se non vengono printati
  136. \item Non cancellare l'output del terminale
  137. \end{itemize}
  138. \subsection{Il concetto di \emph{Shell}}
  139. \begin{itemize}
  140. \item \emph{shell} è programma per computer che espone all'utente o ad
  141. altri programmi i servizi dell'OS
  142. \item Si chiama così perché è strato più esterno dell'OS
  143. \item Può essere GUI (es. \texttt{GNOME}, \texttt{KDE}) o \texttt{CLI}
  144. (es. \texttt{sh}, \texttt{ksh}, \texttt{bash}, \texttt{csh},
  145. \texttt{csh}, \texttt{COMMAND.COM})
  146. \item Nel caso di shell CLI $\rightarrow$ \emph{interprete dei comandi}
  147. \end{itemize}
  148. \subsection{\emph{Interprete dei Comandi} vs \emph{Emulatore di Terminale}}
  149. \begin{itemize}
  150. \item \emph{emulatore di terminale} = GUI che emula una \emph{telescrivente}
  151. \footnote{Video interessante di \emph{telescrivente} connessa a sistema
  152. \texttt{GNU/Linux}:
  153. \url{https://www.youtube.com/watch?v=9TGQ4pnVWSQ}
  154. }
  155. \begin{itemize}
  156. \item Programma \emph{master} che riceve e interpreta le stringhe
  157. digitate dall'utente alla tastiera, le mostra in una finestra
  158. grafica e le passa al programma \emph{slave}
  159. (es. \emph{interprete dei comandi})
  160. \item Riceve stringhe dal pogramma \emph{slave} e le mostra all'utente
  161. grazie ad una finestra grafica
  162. \item Esempi: \texttt{xterm}, \texttt{urxvt}, \texttt{st}
  163. \item Quando non è un GUI si chiama \emph{console virtuale}
  164. (es. le \texttt{Linux tty})
  165. \end{itemize}
  166. \item \emph{interprete dei comandi} = una shell di tipo CLI
  167. \begin{itemize}
  168. \item Programma \emph{slave} che riceve stringhe dal programma
  169. \emph{master}, le interpreta e chiede a OS di eseguire programmi
  170. corrispondenti
  171. \item Può passare stringhe al programma \emph{master} perché vengano
  172. mostrate a schermo
  173. \end{itemize}
  174. \end{itemize}
  175. \subsection{\texttt{bash}}
  176. \begin{itemize}
  177. \item Shell del progetto GNU
  178. \item \texttt{bash} = \emph{Bourne Again SHell} (Stephen Bourne)
  179. \item \`E interprete dei comandi e linguaggio di scripting
  180. \item Se chiamata come \texttt{sh} o con la flag \texttt{--posix}
  181. comportamento conforme al POSIX (\texttt{sh})
  182. \item Feature:
  183. \begin{itemize}
  184. \item Esecuzione di comandi $\rightarrow$ Se no slash: ricerca
  185. $\rightarrow$ funzioni, builtin, \texttt{PATH} (\texttt{hash})
  186. $\rightarrow$ Esecuzione con assegnazione argomenti
  187. \item Shell scripts
  188. \item Enviroment (\texttt{export})
  189. \item Simple commands $\rightarrow$ \emph{``A simple command is a sequence of optional
  190. variable assignments followed by blank-separated words and redirections,
  191. and terminated by a control operator.''}
  192. \item Pipeline $\rightarrow$ \texttt{|}, \texttt{|\&}, \textbf{in subshell}
  193. \item Liste di comandi $\rightarrow$ \texttt{;}, \texttt{\&}, \texttt{\&\&}, \texttt{||}
  194. \item Compound commands $\rightarrow$ \texttt{(list)}, \texttt{\{ list; \}}, \texttt{((expression))},
  195. \texttt{if}, \texttt{for} (due tipi), \texttt{while}, \texttt{until}, \texttt{case}
  196. \item Shell functions $\rightarrow$ \texttt{fname () compound-command [redirection]}
  197. \item Coprocesses $\rightarrow$ \texttt{coproc [NAME] command [redirections]}
  198. \item Commenti $\rightarrow$ \texttt{\#}
  199. \item Quoting
  200. \item Parametri $\rightarrow$ \emph{``A parameter is an entity that stores values.''},
  201. \emph{``A variable is a parameter denoted by a name.''},
  202. definizione, valutazione, parametri speciali (\texttt{*}, \texttt{@}, \texttt{\#}, \texttt{?},
  203. \texttt{-},\texttt{\$},\texttt{!} (job), \texttt{0})
  204. e variabili speciali (in particolare \texttt{PATH}), namerefs (\texttt{declare -n ref=VAR}),
  205. \texttt{declare} builtin
  206. \item Array $\rightarrow$ \texttt{name=(value1 ... valuen)}
  207. \item Espansione $\rightarrow$ brace expansion, tilde expansion,
  208. parameter and variable expansion, command substitution, arithmetic expansion,
  209. word splitting, and pathname expansion
  210. \item Redirezione $\rightarrow$ \texttt{>}, \texttt{>>}, \texttt{<}, nomi file spaciali,
  211. \emph{Here Documents} \texttt{[n]<<[-]word ... delim}, \emph{Here Strings}
  212. \texttt{[n] < < < word}, duplicating file descriptors \texttt{[n]>\&word} (analogo
  213. per input, moving file descriptors \texttt{[n]>\&digit-} (analogo input),
  214. opening file descriptors for reading and writing \texttt{[n]<>word}.
  215. \item \texttt{history}
  216. \item Tab completion
  217. \item Job control
  218. \item Builtins (Vedi man page)
  219. \end{itemize}
  220. \end{itemize}
  221. \subsection{Programmi Applicativi di \texttt{UNIX}}
  222. \subsubsection{Il Comando Più Importante dell'Universo}
  223. Comando \texttt{man} è più importante universo! \texttt{man man man}!
  224. Vedi anche \texttt{apropos} o \texttt{man -k}.
  225. Regole per documentarsi:
  226. \begin{itemize}
  227. \item Cercare nelle \emph{man page}, info, \texttt{--help} e solo infine sul web
  228. \item Cercare \emph{in lingua inglese} $\rightarrow$ \`E la lingua di internet
  229. e dell'informatica
  230. \item Cercare sempre dalla documentazione ufficiale $\rightarrow$ Meglio diffidare
  231. di guide e blog, se possibile.
  232. (\emph{Chi l'ha scritto, è chi meglio ti può consigliare})
  233. \item Vai a fondo finché il tempo a tua disposizione te lo permette
  234. \end{itemize}
  235. \subsubsection{File System}
  236. \begin{itemize}
  237. \item Digressione su VFS: radice, nodi, file regolari, file speciali (?)
  238. \item \texttt{pwd}
  239. \item \texttt{touch} $\rightarrow$ Puoi introdurre qui, \texttt{:}
  240. \item \texttt{cd} $\rightarrow$ No argomento, \texttt{-}
  241. \item \texttt{ls} $\rightarrow$ \texttt{-l}, \texttt{-a}, \texttt{-t}, \texttt{-r}
  242. \item \texttt{cat} $\rightarrow$ \texttt{-et}
  243. \item \texttt{cp} $\rightarrow$ \texttt{-r}, \texttt{dir/.}, \texttt{-}
  244. \item \texttt{mv} $\rightarrow$ \texttt{-i}
  245. \item \texttt{unlink}
  246. \item \texttt{rm} $\rightarrow$ \texttt{-r}, \texttt{-i}, \texttt{-f}
  247. \item \texttt{mkdir} $\rightarrow$ \texttt{-p}
  248. \item \texttt{file} $\rightarrow$ \texttt{-l}
  249. \item \texttt{df} $\rightarrow$ \texttt{-a}, \texttt{-i}, \texttt{-h}
  250. \item \texttt{du} $\rightarrow$ \texttt{-a}, \texttt{-h}, \texttt{s}
  251. \item \texttt{find} $\rightarrow$ \texttt{--name}, \texttt{--iname}, combinazione
  252. con \texttt{xargs}
  253. \item \texttt{cmp} $\rightarrow$ \texttt{diff}, \texttt{diff3}
  254. \item \texttt{dd}
  255. \item \texttt{ln} $\rightarrow$ \texttt{-s}
  256. \item \texttt{readlink}
  257. \end{itemize}
  258. \subsubsection{Text Processing}
  259. \begin{itemize}
  260. \item \texttt{cut} $\rightarrow$ \texttt{-f}, \texttt{-d}
  261. \item \texttt{paste} $\rightarrow$ \texttt{-d}
  262. \item \texttt{head} $\rightarrow$ \texttt{-N}
  263. \item \texttt{tail} $\rightarrow$ \texttt{-N}, \texttt{-f}
  264. \item \texttt{sort} $\rightarrow$ \texttt{-h}, (\texttt{tsort})
  265. \item \texttt{wc} $\rightarrow$ \texttt{-l}
  266. \item \texttt{join} $\rightarrow$ ?
  267. \item \texttt{more}
  268. \item \texttt{less} $\rightarrow$ keybind \texttt{v}
  269. \item \texttt{sed} $\rightarrow$ \emph{Stream editor}, \texttt{-i},
  270. \texttt{s/pat1/pat2/g},
  271. \texttt{\{N\}d}
  272. \item \texttt{tr} $\rightarrow$ \texttt{-d}
  273. \item \texttt{uniq}
  274. \item \texttt{nl} $\rightarrow$ Numera linee file argomento
  275. \end{itemize}
  276. \subsubsection{Misc}
  277. \begin{itemize}
  278. \item \texttt{uname} $\rightarrow$ \texttt{-a}
  279. \item \texttt{date}
  280. \item \texttt{cal} $\rightarrow$ \texttt{-y}
  281. \item \texttt{bc}
  282. \item \texttt{split} $\rightarrow$ \texttt{-b} (bytes)
  283. \item \texttt{env}
  284. \item \texttt{grep} $\rightarrow$ \texttt{-c}, \texttt{-v}
  285. \item \texttt{id}, \texttt{whoami}, \texttt{who}, \texttt{logname}
  286. \item \texttt{od} $\rightarrow$ \texttt{-a}, \texttt{-x}
  287. \item \texttt{tty}
  288. \end{itemize}
  289. \subsubsection{Shell Porgramming}
  290. \begin{itemize}
  291. \item \texttt{echo} $\rightarrow$ \texttt{-e}, \texttt{-n}
  292. \item \texttt{sleep}
  293. \item \texttt{tee} $\rightarrow$ \texttt{-a}
  294. \item \texttt{command}
  295. \item \texttt{true}
  296. \item \texttt{false}
  297. \end{itemize}
  298. \section{Chiusura}
  299. \begin{itemize}
  300. \item Repo dell'\emph{OpenLab}, cosa trovate, licenza
  301. \item Contatti LCM: sito, gruppo community, mail
  302. \item Saluti
  303. \end{itemize}
  304. \end{document}