-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBioInfPrep_Unix.tex
1521 lines (1248 loc) · 55.4 KB
/
BioInfPrep_Unix.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
\documentclass[aspectratio=1610]{beamer}
\usepackage[utf8]{inputenc}
\usepackage{inconsolata}
\usepackage[scaled]{beramono}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{tikz}
%\usepackage{tikzlings}
%\usepackage{tikzpeople}
\usepackage{pgfplots}
\usepackage{changepage}
\usepackage{environ}
\usepackage{listings}
\usepackage{mathabx}
\usepackage{csquotes}
\usepackage{savesym}
\savesymbol{checkmark}
\usepackage{dingbat}
\usetikzlibrary{positioning}
\usetikzlibrary{shapes.arrows}
\usetikzlibrary{matrix}
\usetikzlibrary{calc}
\usetikzlibrary{decorations.pathmorphing}
\usetheme{metropolis}
\setbeamercolor{alerted text}{fg=teal, bg=white}
\setbeamercolor{normal text}{bg=white}
\title{Bioinformatics Preparatory Course}
\subtitle{Basic Unix}
\author{Léon Kuchenbecker and Nantia Leonidou}
\date{April 7, 2021}
\newcommand\sepsym{\raisebox{.1em}{\tiny$\blacksquare$} }
\newcommand\curtitle{}
%\lstset{
% basicstyle=\color{white}\ttfamily,
% keywordstyle=\color{magenta}\ttfamily,
% stringstyle=\color{orange}\ttfamily,
% commentstyle=\color{blue}\ttfamily,
% morecomment=[l][\color{blue}]{\#},
% escapeinside={(*}{*)},
% belowskip=0mm,
% aboveskip=0mm,
%}
\tikzset{
codebox/.style={
line width=0mm,
text width=\linewidth-17.1pt,
fill=black,
%rounded corners=.5mm,
inner xsep=3mm,
inner ysep=0mm,
},
}
\newcommand{\footercomment}[1]{
\begin{tikzpicture}[overlay, remember picture]
\node [anchor=west, font=\scriptsize] at ($(current page.south west)+(1.5mm,4.70mm)$) {#1};
\end{tikzpicture}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\colorlet{keyboard}{gray}
\colorlet{stdout}{teal}
\colorlet{stderr}{orange}
\makeatletter
\newenvironment{shells}[1]{
\begin{tikzpicture}[codebox/.append style={text width=#1-18pt}]
\coordinate (code);
}{
\end{tikzpicture}
}
\lstnewenvironment{shellout}[1][keyboard]{%
\lstset{%
basicstyle=\color{white}\ttfamily\bfseries\small,
escapeinside={(*}{*)},
belowskip=0mm,
aboveskip=0mm,
}%
\node[codebox, below=0mm of code] (code) \bgroup
}%
{%
\egroup;
\draw [line width=2mm,#1] ($(code.north east)-(1mm,0mm)$) -- ($(code.south east)-(1mm,0mm)$)
($(code.north west)+(1mm,0mm)$) -- ($(code.south west)+(1mm,0mm)$);
}
\lstnewenvironment{shelloutsmall}[1][keyboard]{%
\lstset{%
basicstyle=\color{white}\ttfamily\bfseries\scriptsize,
escapeinside={(*}{*)},
belowskip=0mm,
aboveskip=0mm,
}%
\node[codebox, below=0mm of code] (code) \bgroup
}%
{%
\egroup;
\draw [line width=2mm,#1] ($(code.north east)-(1mm,0mm)$) -- ($(code.south east)-(1mm,0mm)$)
($(code.north west)+(1mm,0mm)$) -- ($(code.south west)+(1mm,0mm)$);
}
\makeatother
\newcommand\command[1]{\alert{\textbf{\texttt{#1}}}}
\begin{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}
\titlepage
\end{frame}
\begin{frame}{License and Contributors}
\begin{tikzpicture}[inner sep=0mm]
\node (a) {\includegraphics{by.pdf}};
\node [right=5mm of a] {Attribution 4.0 International (CC BY 4.0)};
\end{tikzpicture}
\medskip
\emph{Main Author}\\
Léon Kuchenbecker
\emph{Additional Contributors}\\
Alexander Seitz, Samuel Wein
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c]{Why bother with the shell?}
\begin{itemize}[<+->]\setlength\itemsep{1em}
\item The shell is extremely powerful
\begin{itemize}[<.->]
\item Searching, organizing, transferring large numbers of files
\item Exploring and manipulating plain text files
\item Can be programmed
\end{itemize}
\item The shell can be executed remotely
\begin{itemize}[<.->]
\item SSH (secure shell) interface to access a Unix-like system remotely
\item Standard to interact with larger computer infrastructures (e.g. a compute
server or cluster)
\end{itemize}
\item The majority of bioinformatics tools have a CLI
\begin{itemize}[<.->]
\item We work with a high number of large files
\item Crunching that data requires high compute power $\Rightarrow$ compute server,
cluster
\item Most file formats established in Bioinformatics are plain text
\end{itemize}
\end{itemize}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c,fragile]{Basic Usage}
\begin{itemize}
\item Enter a command and press the Return ($\dlsh$) key
\begin{shells}{\linewidth}
\begin{shellout}
(*$\mathdollar$*) ls (*$\dlsh$*)
\end{shellout}
\begin{shellout}[stdout]
Desktop Documents Exercise
\end{shellout}
\end{shells}
\item To get help on how to use a particular command, try
\begin{shells}{\linewidth}
\begin{shellout}
(*$\mathdollar$*) ls --help (*$\dlsh$*)
(*$\mathdollar$*) man ls (*$\dlsh$*)
\end{shellout}
\end{shells}
\item The basic command syntax often follows this structure:
\begin{shells}{\linewidth}
\begin{shellout}
COMMAND [OPTIONAL SWITCHES] [MANDATORY ARGUMENTS]
\end{shellout}
\end{shells}
\end{itemize}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c,fragile]{Basic Usage}
\begin{itemize}[<+->]
\item Often there are long (\verb|--|) and short (\verb|-|) versions of switches
\begin{shells}{\linewidth}
\begin{shellout}
(*$\mathdollar$*) ls (*$\dlsh$*)
\end{shellout}
\begin{shellout}[stdout]
Desktop Documents Exercise
\end{shellout}
\begin{shellout}
(*$\mathdollar$*) ls -r (*$\dlsh$*)
\end{shellout}
\begin{shellout}[stdout]
Exercise Documents Desktop
\end{shellout}
\begin{shellout}
(*$\mathdollar$*) ls --reverse (*$\dlsh$*)
\end{shellout}
\begin{shellout}[stdout]
Exercise Documents Desktop
\end{shellout}
\end{shells}
\item Multiple switches can be specified together
\begin{shells}{\linewidth}
\begin{shellout}
(*$\mathdollar$*) ls -F -r (*$\dlsh$*)
\end{shellout}
\begin{shellout}[stdout]
Exercise/ Documents/ Desktop/
\end{shellout}
\begin{shellout}
(*$\mathdollar$*) ls -Fr (*$\dlsh$*)
\end{shellout}
\begin{shellout}[stdout]
Exercise/ Documents/ Desktop/
\end{shellout}
\end{shells}
\end{itemize}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\renewcommand\curtitle{File systems}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c]
\Huge \curtitle
\end{frame}
\begin{frame}[c]{\curtitle}
A typical computer \alert{file system} is structured like a \alert{tree}
\medskip\centering\includegraphics[width=\linewidth]{filesystem.pdf}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c]{\curtitle}
\begin{itemize}[<+->]\setlength\itemsep{1em}
\item Every running computer program, i.e. every process, including the \alert{shell}, refers to one directory
inside the file system tree as its \alert{working directory}.
\item When using the \alert{shell}, one often says \enquote{I am in the directory xzy}.
\item The \alert{working directory} is not static, it can be changed throughout the runtime of a process.
\end{itemize}
\end{frame}
\begin{frame}[c]{\curtitle}
\begin{adjustwidth}{-2em}{-2em}
\begin{columns}
\begin{column}{0.32\textwidth}
\begin{tikzpicture}
\node [inner sep=0mm] (pic) {\includegraphics[height=\textheight, trim=0mm 0mm 208mm 0mm, clip]{filesystem.pdf}};
\visible<2->{
\node [fill=red,draw, circle, inner sep=0mm, text width=2.5mm, red] (root) at ($(pic.north west)+(3mm,-11.2mm)$) {};
\node [fill=red,draw, circle, inner sep=0mm, text width=2.5mm, red] (home) at ($(pic.north west)+(6.5mm,-35.4mm)$) {};
\node [fill=red,draw, circle, inner sep=0mm, text width=2.5mm, red] (bob) at ($(pic.north west)+(10mm,-42.3mm)$) {};
\node [rounded corners, draw=red, text width=20mm, minimum height=4mm, inner
sep=0mm, line width=1pt] (file) at ($(pic.north west)+(22mm, -49.5mm)$) {};
\draw [line width=2pt, red] (root) |- (home) |- (bob) |- (file);
}
\end{tikzpicture}
\end{column}
\begin{column}{0.70\textwidth}
\begin{itemize}[<+->]\setlength\itemsep{1em}
\item Every file or directory in the file system can be described by a \alert{path}
\item \alert{Absolute paths} start in the root directory, for example
\medskip\texttt{/home/bob/photo.png}
\item \alert{Relative paths} start in the current working directory, for example
\medskip\texttt{./bob/photo.png}
\medskip given that the current working directory is \texttt{/home}.
\item Every character sequence that does not start with a slash \alert{\texttt{/}} character
is interpreted as a relative path.
\end{itemize}
\end{column}
\end{columns}
\end{adjustwidth}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\renewcommand\curtitle{Working with the file system}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c]{\curtitle}
\begin{itemize}[<+->]
\setlength\itemsep{1em}
\item \command{pwd} \textbf{- print working directory}
Prints the current working directory
\item \command{ls} \textbf{- list}
Displays the contents of folders (directories)
\begin{itemize}[<.->]
\item \alert{\texttt{ls -l}} show details
\item \alert{\texttt{ls -lh}} human readable file sizes
\item \alert{\texttt{ls -a}} show hidden files and folders
\end{itemize}
\item \command{cd} \textbf{- change directory}
Changes the current working directory
\end{itemize}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c]{\curtitle}
\begin{itemize}[<+->]
\setlength\itemsep{1em}
\item \command{mkdir <path>} \textbf{- make directory}
Creates a new directory
\item \command{cp <source path> <destination path>} \textbf{- copy}
Copies files and folders. \textcolor{red}{\textbf{Overwriting targets cannot be
undone!}}
\begin{itemize}[<.->]
\item \command{cp -r} - recursive mode
Required to copy directories with their contents.
\end{itemize}
\item \command{mv <source path> <destination path>} \textbf{- move}
Move files and folders \textcolor{red}{\textbf{Overwriting targets cannot be undone!}}
\item \command{rmdir <path>} \textbf{- remove directory}
Removes directories, but only if they are empty. Safe to use.
\end{itemize}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c]{\curtitle}
\begin{itemize}[<+->]
\setlength\itemsep{1em}
\item \command{rm <path>} \textbf{- remove}
Remove files and folders. \textcolor{red}{\textbf{Removing cannot be undone!}}
\begin{itemize}[<.->]
\item \command{rm -r} - recursive mode
Required to remove directories with their contents.
\end{itemize}
\end{itemize}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c]
\Huge Getting started with plain text files
\end{frame}
\renewcommand\curtitle{Inspecting plain text files}
\begin{frame}[c]{\curtitle}
\begin{itemize}[<+->]
\setlength\itemsep{1em}
\item \command{more <path>}
Page through text one page at a time
\item \command{less <path>} \textbf{- the opposite of more}
More powerful than more, bidirectional, provides searching
\item \command{cat <path> [<path> ...]} \textbf{- concatenate}
Concatenates input files and prints them to the standard output (more on that later).
\end{itemize}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c]{\curtitle}
\begin{itemize}[<+->]
\setlength\itemsep{1em}
\item \command{head <path>}
Output the first $n$ lines of a plain text file.
\item \command{tail <path>}
Output the last $n$ lines of a plain text file.
\begin{itemize}[<.->]
\item \command{tail -f} - follow
Keeps printing new lines as the file grows.
\end{itemize}
\end{itemize}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\renewcommand\curtitle{Creating and editing plain text files}
\begin{frame}[c]{\curtitle}
\begin{itemize}[<+->]
\setlength\itemsep{1em}
\item A \alert{text editor} is a program used to edit plain text files
\item Well known graphical editors are \alert{Notepad} on Microsoft Windows and
\alert{TextEdit} on Apple macOS
\item \alert{Nano} is a text editor that does not require a graphical user interface but
works on the command line
\end{itemize}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c]{\curtitle}
\begin{itemize}[<+->]
\setlength\itemsep{1em}
\item \command{nano <path>}
Opens the file specified by path. Can be used on non-existing paths to create
new files.
\item \command{CTRL-O}
Saves the current file
\item \command{CTRL-X}
Exits nano
\end{itemize}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\renewcommand\curtitle{Keyboard shortcuts}
\begin{frame}[c]{\curtitle}
\begin{itemize}
\item \command{TAB}
Autocomplete the command line
\item \command{TAB - TAB}
Show possible completions if not unique
\item \command{ALT-b} and \command{ALT-f}
Move one word backward (or forward) in the current command line
\item \command{Pos1} or \command{Home}
Move to the beginning of the current command line
\item \command{End}
Move to the end of the current command line
\end{itemize}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c]{\curtitle}
\centering\includegraphics[width=\linewidth]{keyboard.png}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c]{\curtitle}
\begin{itemize}
\item \command{Arrow Up}
Browse the shell history backward in time
\item \command{Arrow Down}
Browse the shell history forward in time
\item \command{CTRL-R}
Search the shell history backward in time
\item \command{CTRL-C}
Interrupt the current program.
\end{itemize}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\renewcommand\curtitle{Process streams}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c]
\Huge \curtitle
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c]{\curtitle}
\begin{itemize}
\item Every \alert{process} has three input / output streams
\begin{itemize}
\item Standard input (stdin)
\item Standard output (stdout)
\item Standard error (stderr)
\end{itemize}
\end{itemize}
\pause
\centering
\begin{tikzpicture}
\node [rounded corners, fill=gray!50, minimum height=15mm, text width=30mm, align=center]
(proc)
{Process};
\node [draw, single arrow, fill=gray, anchor=east, text width=15mm] at ($(proc.west)+(4mm,0)$) {stdin};
\node [draw, single arrow, fill=teal, anchor=west, text width=15mm] at ($(proc.east)+(-4mm,6mm)$) {stdout};
\node [draw, single arrow, fill=orange, anchor=west, text width=15mm] at ($(proc.east)+(-4mm,-6mm)$) {stderr};
\end{tikzpicture}
\pause
\begin{itemize}
\item We have so far \alert{only worked with stdout}.
\end{itemize}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile, c]{\curtitle}
\begin{itemize}[<+->]
\setlength\itemsep{1em}
\item Normally, we cannot see the differente between \alert{stdout} and \textcolor{orange}{stderr}
\item This output is produced on \alert{stdout}
\begin{shells}{\linewidth}
\begin{shellout}
(*$\mathdollar$*) ls -l Exercise/data (*$\dlsh$*)
\end{shellout}
\begin{shellout}[stdout]
total 13960
-rw-r--r-- 1 vorkurs vorkurs 14293917 Mar 27 2018 clinvar_20180225.vcf.gz
\end{shellout}
\end{shells}
\item This output is produced on \textcolor{orange}{stderr}
\begin{shells}{\linewidth}
\begin{shellout}
(*$\mathdollar$*) ls -l doesnt.exist (*$\dlsh$*)
\end{shellout}
\begin{shellout}[stderr]
ls: cannot access 'doesnt.exist': No such file or directory
\end{shellout}
\end{shells}
\end{itemize}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c,fragile]{\curtitle}
\begin{itemize}[<+->]
\setlength\itemsep{1em}
\item We can redirect streams into files using the \command{>} character
\begin{shells}{\linewidth}
\begin{shellout}
(*$\mathdollar$*) ls -l Exercise/data 1>stdout.txt 2>stderr.txt (*$\dlsh$*)
\end{shellout}
\end{shells}
\begin{shells}{\linewidth}
\begin{shellout}
(*$\mathdollar$*) ls -l doesnt.exist 1>stdout.txt 2>stderr.txt (*$\dlsh$*)
\end{shellout}
\end{shells}
\item \command{1> <path>} redirects the \alert{standard output} into \command{<path>}
\item \command{2> <path>} redirects the \alert{standard error} into \command{<path>}
\item \command{> <path>} is short for \command{1> <path>}
\end{itemize}
\visible<+->{
Try the two examples above and check the contents of the two output files each time!
}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c]{\curtitle}
\begin{itemize}\setlength\itemsep{1em}
\item The \command{>} redirection \alert{overwrites} the target file!
\item Use \command{{>}>} to instead append the contents to the target file
\end{itemize}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c]{Warm up}
\begin{itemize}
\item [\leftpointright] Create a folder named \texttt{repetition}
\item [\leftpointright] Create a file in that folder named \texttt{repetition.txt}
\item [\leftpointright] Write the text \texttt{Hello World} into that file
\item [\leftpointright] Copy the file to a new file named \texttt{repetition2.txt}
\item [\leftpointright] Duplicate the content of the file \texttt{repetition2.txt} and write it to the file \texttt{repetition3.txt}
\item [\leftpointright] Print the content of the three files
\item [\leftpointright] Delete the file \texttt{repetition.txt}
\item [\leftpointright] Copy the folder \texttt{repetition} to the folder \texttt{repetition2} with all its contents
\item [\leftpointright] Rename the folder \texttt{repetition} to \texttt{repetition\_old}
\item [\leftpointright] Remove the contents of the folder \texttt{repetition\_old}
\item [\leftpointright] Remove the folder repetition\_old
\item [\leftpointright] Remove the folder \texttt{repetition2}
\end{itemize}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c]
\Huge Users, groups and permissions
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\renewcommand\curtitle{Users, groups and permissions}
\begin{frame}[c]{\curtitle}
\begin{itemize}[<+->]
\setlength\itemsep{1em}
\item File systems on Unix-like systems allow to configure access rights to users and groups
of users
\item A user can be a real person or just be an arbitrary logical entity
\item Groups are sets of users
\item Every file has a single \alert{owner} and is also associated with a single
\alert{group}
\end{itemize}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c,fragile]{\curtitle}
\begin{shells}{\linewidth}
\begin{shellout}
(*$\mathdollar$*) ls -l Exercise/data (*$\dlsh$*)
\end{shellout}
\begin{shellout}[stdout]
total 13960
-rw-r--r-- 1 vorkurs vorkurs 14293917 Mar 27 13:42 clinvar_20180225.vcf.gz
\end{shellout}
\node [anchor=west] (owner) at ($(code.south)-(10mm,15mm)$) {The file owner};
\draw ($(code.south)+(-35mm,-2mm)$) |- (owner.west);
\node [above=5mm of owner.north west, anchor=west] (group) {Group};
\draw ($(code.south)+(-20mm,-2mm)$) |- (group.west);
\end{shells}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c]{\curtitle}
\begin{itemize}[<+->]
\setlength\itemsep{1em}
\item A set of \alert{permissions} is associated with each file which determine who has what
type of access to the file
\item There are three access types:
\begin{itemize}[<.->]
\item \command{read}
\item \command{write}
\item \command{execute}
\end{itemize}
\item This triplet of permissions (\command{rwx}) is defined for three groups of users:
\begin{itemize}[<.->]
\item The owner
\item Members of the file's group
\item The rest of the world
\end{itemize}
\end{itemize}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c,fragile]{\curtitle}
\begin{shells}{\linewidth}
\begin{shellout}
(*$\mathdollar$*) ls -l Exercise/data (*$\dlsh$*)
\end{shellout}
\begin{shellout}[stdout]
total 13960
-rw-r--r-- 1 vorkurs vorkurs 14293917 Mar 27 13:42 clinvar_20180225.vcf.gz
\end{shellout}
\draw[line width=1pt] ($(code.south west)+(5.0mm,-2mm)$) -- +(0mm,-2mm) -| +(5.0mm,0);
\draw[line width=1pt] ($(code.south west)+(10.8mm,-2mm)$) -- +(0mm,-2mm) -| +(5mm,0);
\draw[line width=1pt] ($(code.south west)+(16.6mm,-2mm)$) -- +(0mm,-2mm) -| +(5mm,0);
\node (owner) at ($(code.south)+(0,-30mm)$) {The owner can read and write (\texttt{rw-})};
\node [above=8mm of owner.west, anchor=west] (group) {Members of the group \alert{vorkurs}
can read (\texttt{r--})};
\node [above=8mm of group.west, anchor=west] (rest) {Everyone else can also read
(\texttt{r--})};
\draw [line width=1pt] ($(code.south west)+(7.5mm,-6mm)$) |- (owner);
\draw [line width=1pt] ($(code.south west)+(13.3mm,-6mm)$) |- (group);
\draw [line width=1pt] ($(code.south west)+(19.1mm,-6mm)$) |- (rest);
\end{shells}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c]{\curtitle}
The interpretation of the permissions for \alert{directories} is slightly different
\begin{itemize}\setlength\itemsep{1em}
\item \command{read} determines whether the contents of a directory can be seen
\item \command{write} determines whether files can be created or deleted
\item \command{execute} determines whether a user can change (\command{cd}) into the
directory
\end{itemize}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c]{\curtitle}
\begin{itemize}[<+->]\setlength\itemsep{1em}
\item \command{chown [owner][:[group] <path>} \textbf{- change ownership}
Changes the ownership and / or group association of a file or directory. Only the
\alert{root} user is allowed to change the owner of a file.
\item \command{chmod <permissions> <path>} \textbf{- change file mode bits, aka permissions}
Changes the file permissions. Examples:
\begin{itemize}[<.->]
\item \command{chmod g+w <path>}
Add write permissions to the group
\item \command{chmod o-r <path>}
Remove read permissions for the rest of the world
\item Shortcuts:
(u)ser, (g)roup, (o)thers, (a)ll at once
(r)ead, (w)rite, e(x)ecute
\end{itemize}
\end{itemize}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c,fragile]{\curtitle}
\begin{shells}{\linewidth}
\begin{shellout}
(*$\mathdollar$*) ls -l Exercise/data (*$\dlsh$*)
\end{shellout}
\begin{shellout}[stdout]
total 13960
-rw-r--r-- 1 vorkurs vorkurs 14293917 Mar 27 13:42 clinvar_20180225.vcf.gz
\end{shellout}
\end{shells}
\pause
Add the \alert{write} permission to everyone:
\begin{shells}{\linewidth}
\begin{shellout}
(*$\mathdollar$*) chmod a+w Exercise/data/clinvar_20180225.vcf.gz (*$\dlsh$*)
(*$\mathdollar$*) ls -l Exercise/data (*$\dlsh$*)
\end{shellout}
\begin{shellout}[stdout]
total 13960
-rw-rw-rw- 1 vorkurs vorkurs 14293917 Mar 27 13:42 clinvar_20180225.vcf.gz
\end{shellout}
\end{shells}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c]{\curtitle}
\begin{itemize}[<+->]\setlength\itemsep{1em}
\item Permissions can also be specified numerically
\begin{itemize}[<.->]
\item 4: read (r)
\item 2: write (w)
\item 1: execute (x)
\end{itemize}
\item To combine permissions, the numbers are added
\item Three digits specify the permissions for all three groups (owner, group, rest of the
world) simultaneously:\medskip
\command{chmod 750 <path>}
\begin{itemize}[<.->]
\item 7=4+2+1: owner has all permissions (rwx)
\item 5=4+1: group members have read and execute permissions (rx)
\item 0: rest of the world has no permissions
\end{itemize}
\end{itemize}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\renewcommand\curtitle{Downloading data from the internet}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c]
\Huge \curtitle
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c]{\curtitle}
\begin{itemize}[<+->]\setlength\itemsep{1em}
\item \command{wget <url>}
Downloads a remote file. Supports HTTP(S) and FTP.
\begin{itemize}[<.->]
\item \command{wget -c} or \command{wget -{-}continue}
Continue downloading a file that was already partially downloaded
\end{itemize}
\item \command{wget} is installed on most Linux systems, but by default not on macOS
\item \command{curl -LO <url>}
\alert{curl} is another command line tool to download remote files, similar to wget.
\end{itemize}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c,fragile]{\curtitle}
Example \command{wget} invocation:
\begin{shells}{\linewidth}
\begin{shelloutsmall}
(*$\mathdollar$*) wget https://bioinfprep.github.io/assets/material.zip (*$\dlsh$*)
\end{shelloutsmall}
\begin{shelloutsmall}[stderr]
--2020-10-21 08:00:04-- https://bioinfprep.github.io/assets/material.zip
Resolving bioinfprep.github.io... 185.199.111.153, 185.199.110.153, 185.199.108.153, ...
Connecting to bioinfprep.github.io|185.199.111.153|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 10586 (10K) [application/zip]
Saving to: 'material.zip.3'
material.zip.3 100%[=============================================>] 10.34K --.-KB/s in 0.001s
2020-10-21 08:00:04 (13.8 MB/s) - 'material.zip.3' saved [10586/10586]
\end{shelloutsmall}
\end{shells}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c,fragile]{\curtitle}
Example \command{curl} invocation:
\begin{shells}{\linewidth}
\begin{shelloutsmall}
(*$\mathdollar$*) curl -LO https://bioinfprep.github.io/assets/material.zip (*$\dlsh$*)
\end{shelloutsmall}
\begin{shelloutsmall}[stderr]
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 10586 100 10586 0 0 57532 0 --:--:-- --:--:-- --:--:-- 57532
\end{shelloutsmall}
\end{shells}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\renewcommand\curtitle{File compression and file archives}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c]
\Huge \curtitle
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c]{\curtitle}
\begin{itemize}\setlength\itemsep{1em}
\item The most common compressed archive file formats are \alert{.tar.gz} and \alert{zip}
\item \alert{tar} is an archive format to reversibly combine multiple files into one file,
\alert{gz} (gzip) is a data compression tool
\item \alert{zip} is an \enquote{all in one} solution, i.e. does archiving and compression
\end{itemize}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\renewcommand\curtitle{ZIP file handling}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c,fragile]{\curtitle}
\begin{itemize}\setlength\itemsep{1em}
\item \command{unzip -l <path>}
Shows the contents of a zip file
\item \command{unzip <path>}
Unpacks the contents of a zip file
\item \command{zip -r <outputpath> <contentpath> [<contentpath> ...]}
Add content to a zip file recursively. Creates the zip file if it does not exist.
\end{itemize}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c,fragile]{\curtitle}
\begin{shells}{\linewidth}
\begin{shelloutsmall}
(*$\mathdollar$*) unzip -l material.zip (*$\dlsh$*)
\end{shelloutsmall}
\begin{shelloutsmall}[stdout]
Archive: material.zip
Length Date Time Name
--------- ---------- ----- ----
0 03-29-2017 09:36 material/
51 03-22-2017 10:59 material/test_file_1.txt
69 03-22-2017 10:59 material/test_file_2.txt
34753 03-22-2017 12:36 material/large.fasta
67 03-22-2017 12:39 material/small.fasta
595 03-28-2017 08:58 material/duplicated_file.txt
35 03-29-2017 09:29 material/my_diff_2.txt
46 03-29-2017 09:29 material/my_diff_1.txt
35 03-29-2017 09:34 material/my_sort_1.txt
557 03-29-2017 09:36 material/tmp.txt
557 03-29-2017 09:36 material/my_sort_2.txt
--------- -------
36765 11 files
\end{shelloutsmall}
\end{shells}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c,fragile]{\curtitle}
\begin{shells}{\linewidth}
\begin{shelloutsmall}
(*$\mathdollar$*) unzip material.zip (*$\dlsh$*)
\end{shelloutsmall}
\begin{shelloutsmall}[stdout]
Archive: material.zip
creating: material/
inflating: material/test_file_1.txt
inflating: material/test_file_2.txt
inflating: material/large.fasta
inflating: material/small.fasta
inflating: material/duplicated_file.txt
extracting: material/my_diff_2.txt
inflating: material/my_diff_1.txt
inflating: material/my_sort_1.txt
inflating: material/tmp.txt
inflating: material/my_sort_2.txt
\end{shelloutsmall}
\pause
\begin{shelloutsmall}
(*$\mathdollar$*) ls -F (*$\dlsh$*)
\end{shelloutsmall}
\begin{shelloutsmall}[stdout]
Desktop/ Documents/ Exercise/ material/ material.zip
\end{shelloutsmall}
\pause
\begin{shelloutsmall}
(*$\mathdollar$*) ls material (*$\dlsh$*)
\end{shelloutsmall}
\begin{shelloutsmall}[stdout]
duplicated_file.txt my_diff_1.txt my_sort_1.txt small.fasta test_file_2.txt
large.fasta my_diff_2.txt my_sort_2.txt test_file_1.txt tmp.txt
\end{shelloutsmall}
\end{shells}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c,fragile]{\curtitle}
\begin{shells}{\linewidth}
\begin{shelloutsmall}
(*$\mathdollar$*) zip -r new_material.zip material/ (*$\dlsh$*)
\end{shelloutsmall}
\begin{shelloutsmall}[stdout]
adding: material/ (stored 0%)
adding: material/my_diff_2.txt (stored 0%)
adding: material/test_file_2.txt (deflated 41%)
adding: material/duplicated_file.txt (deflated 92%)
adding: material/test_file_1.txt (deflated 63%)
adding: material/my_sort_1.txt (deflated 3%)
adding: material/small.fasta (deflated 45%)
adding: material/tmp.txt (deflated 52%)
adding: material/my_sort_2.txt (deflated 51%)
adding: material/my_diff_1.txt (deflated 4%)
adding: material/large.fasta (deflated 77%)
\end{shelloutsmall}
\end{shells}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\renewcommand\curtitle{GZIPed TAR file handling}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c]{\curtitle}
\begin{itemize}[<+->]\setlength\itemsep{1em}