-
Notifications
You must be signed in to change notification settings - Fork 2
/
single-system-fundamentals.html
1287 lines (975 loc) · 41 KB
/
single-system-fundamentals.html
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
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Linux System Fundamentals — slides</title>
<link rel="stylesheet" href="static/basic.css" type="text/css" />
<link rel="stylesheet" href="static/styles.css" type="text/css" />
<link rel="stylesheet" href="static/single.css" type="text/css" />
<link rel="stylesheet" href="static/custom.css" type="text/css" />
<link rel="stylesheet" href="static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: './',
VERSION: '2015.07.01',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="static/jquery.js"></script>
<script type="text/javascript" src="static/underscore.js"></script>
<script type="text/javascript" src="static/doctools.js"></script>
<script type="text/javascript" src="static/common.js"></script>
<script type="text/javascript" src="static/slides.js"></script>
<script type="text/javascript" src="static/sync.js"></script>
<script type="text/javascript" src="static/controller.js"></script>
<script type="text/javascript" src="static/init.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="top" title="slides" href="index.html" />
<link rel="next" title="Winter Progress Report" href="sp.html" />
<link rel="prev" title="Sass: What it is, how it's used, and why it's so Syntactically Awesome" href="sass.html" />
</head>
<body>
<section
id="slide_container"
class='slides layout-regular'>
<article class="slide level-1" id="linux-system-fundamentals">
<h1>Linux System Fundamentals</h1>
</article>
<article class="slide level-2" id="today-s-agenda">
<h2>Today's Agenda</h2>
<ul>
<li><dl class="first docutils">
<dt>The Terminal & Shell</dt>
<dd><ul class="first last simple">
<li>Scripts, file paths, special characters</li>
</ul>
</dd>
</dl>
</li>
</ul>
<div class="figure align-right">
<img alt="images/Tux.png" src="images/Tux.png" />
</div>
<ul>
<li><dl class="first docutils">
<dt>Productivity tricks</dt>
<dd><ul class="first last simple">
<li>Getting help</li>
</ul>
</dd>
</dl>
</li>
<li><dl class="first docutils">
<dt>What are files?</dt>
<dd><ul class="first last simple">
<li>File permissions</li>
</ul>
</dd>
</dl>
</li>
<li><dl class="first docutils">
<dt>What are user accounts?</dt>
<dd><ul class="first last simple">
<li>User and group management</li>
</ul>
</dd>
</dl>
</li>
<li><dl class="first docutils">
<dt>What are packages?</dt>
<dd><ul class="first last simple">
<li>How to use package managers</li>
</ul>
</dd>
</dl>
</li>
</ul>
</article>
<article class="slide level-2" id="operating-systems">
<h2>Operating Systems</h2>
<ul class="simple">
<li>What is an OS</li>
<li>GNU/Linux, BSD, Windows, OS X, Plan 9</li>
<li>Different use cases - desktop, server, phone</li>
</ul>
</article>
<article class="slide level-2" id="the-terminal">
<h2>The Terminal</h2>
<div class="figure align-right">
<a class="reference internal image-reference" href="images/crashcart.jpg"><img alt="images/crashcart.jpg" src="images/crashcart.jpg" style="height: 100px;" /></a>
</div>
<ul>
<li><dl class="first docutils">
<dt>Used to mean the keyboard+monitor</dt>
<dd><ul class="first last simple">
<li>Now that's a crash cart</li>
</ul>
</dd>
</dl>
</li>
<li><p class="first">Terminal emulator</p>
</li>
<li><dl class="first docutils">
<dt>Shell: Use bash; others include csh, zsh, tsch</dt>
<dd><ul class="first last simple">
<li><code class="code docutils literal"><span class="pre">~/.bashrc</span></code></li>
</ul>
</dd>
</dl>
</li>
</ul>
<div class="figure align-right">
<a class="reference internal image-reference" href="images/televideo_terminal.jpg"><img alt="images/televideo_terminal.jpg" src="images/televideo_terminal.jpg" style="height: 100px;" /></a>
</div>
<div class="figure align-left">
<img alt="images/teletype_terminal.jpg" src="images/teletype_terminal.jpg" />
</div>
</article>
<article class="slide level-2" id="basic-shell-commands">
<h2>Basic Shell Commands</h2>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<table class="last docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name" colspan="2">Explain architecture:</th></tr>
<tr class="field-odd field"><td> </td><td class="field-body">built in commands vs. external binaries</td>
</tr>
<tr class="field-even field"><th class="field-name">Demo commands:</th><td class="field-body">Directory movement and file manipulation: Cd, pwd, ls, rm, mv, touch</td>
</tr>
<tr class="field-odd field"><th class="field-name">User info:</th><td class="field-body">id, whoami, w</td>
</tr>
<tr class="field-even field"><th class="field-name">Pipes:</th><td class="field-body">redirection (pipe.txt, redirect.txt)</td>
</tr>
<tr class="field-odd field"><th class="field-name" colspan="2">Special variables:</th></tr>
<tr class="field-odd field"><td> </td><td class="field-body">$?, $$ (pid.sh), !!, !*, !$</td>
</tr>
</tbody>
</table>
</div>
<div class="figure align-right">
<a class="reference internal image-reference" href="images/bash.png"><img alt="images/bash.png" src="images/bash.png" style="height: 75pc;" /></a>
</div>
<ul class="simple">
<li><code class="docutils literal"><span class="pre">ls</span></code>, <code class="docutils literal"><span class="pre">cd</span></code>, <code class="docutils literal"><span class="pre">cat</span></code>, <code class="docutils literal"><span class="pre">echo</span></code></li>
<li>invoke/call an installed program</li>
<li>get help: <code class="docutils literal"><span class="pre">man</span> <span class="pre"><program></span></code></li>
</ul>
<div class="highlight-default"><div class="highlight"><pre><span></span>test@x230 ~ $ tree
.
├── Documents
│ ├── Code
│ │ └── scripts
│ │ └── test.sh
│ ├── School
│ └── Work
└── Pictures
├── manatee.gif
└── turtle.png
6 directories, 5 files
</pre></div>
</div>
</article>
<article class="slide level-2" id="invoking-a-script">
<h2>Invoking a script</h2>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">Permissions discussed later.</p>
</div>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ ls -l
$ chmod +x <span class="nv">$filename</span>
$ ./<span class="nv">$filename</span>
</pre></div>
</div>
<p><strong>Arguments</strong> (or flags) are extra information that you pass to a script or
program when you call it. They tell it in more detail what you want to do.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ ls -a -l
$ ls -al
$ ls -si
$ ls --si
</pre></div>
</div>
</article>
<article class="slide level-2" id="file-paths">
<h2>File Paths</h2>
<ul class="simple">
<li><code class="docutils literal"><span class="pre">.</span></code> means current directory</li>
<li><code class="docutils literal"><span class="pre">..</span></code> means parent directory</li>
<li>Tilde (<code class="docutils literal"><span class="pre">~</span></code>) means your homedir (<code class="docutils literal"><span class="pre">/home/$username</span></code>)</li>
<li><code class="docutils literal"><span class="pre">/</span></code> separates directories (not <code class="docutils literal"><span class="pre">\</span></code>)</li>
<li><code class="docutils literal"><span class="pre">/</span></code> is root directory, so <code class="docutils literal"><span class="pre">~</span></code> expands to <code class="docutils literal"><span class="pre">/home/$username/</span></code></li>
<li>current path appears in your prompt: I'm logged in as the user test on the
machine named x230</li>
</ul>
<div class="highlight-bash"><div class="highlight"><pre><span></span>test@x230 ~ $ ls
Documents Pictures
test@x230 ~ $ <span class="nb">cd</span> Documents/
test@x230 ~/Documents $ ls
Code School Work
test@x230 ~/Documents $ <span class="nb">pwd</span>
/home/test/Documents
</pre></div>
</div>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">root directory is not to be confused with a home directory for the root
account</p>
</div>
</article>
<article class="slide level-2" id="special-characters">
<h2>Special Characters</h2>
<ul class="simple">
<li>escape with <code class="docutils literal"><span class="pre">\</span></code> to use them literally</li>
<li># means a comment</li>
<li>; allows multiple commands per line</li>
<li>!, ?, *, &&, &</li>
<li>Regular expressions - for matching patterns of text</li>
</ul>
<div class="figure align-center">
<a class="reference internal image-reference" href="images/xkcd_regex.png"><img alt="images/xkcd_regex.png" src="images/xkcd_regex.png" style="height: 50pc;" /></a>
</div>
</article>
<article class="slide level-2" id="type-less">
<h2>Type less</h2>
<ul>
<li><dl class="first docutils">
<dt>Reverse-i-search</dt>
<dd><ul class="first last simple">
<li>ctrl+r then type command</li>
</ul>
</dd>
</dl>
</li>
<li><dl class="first docutils">
<dt>aliases</dt>
<dd><ul class="first last simple">
<li><code class="docutils literal"><span class="pre">~/.bashrc</span></code></li>
</ul>
</dd>
</dl>
</li>
<li><p class="first">Tab completion</p>
</li>
</ul>
<div class="figure align-center">
<a class="reference internal image-reference" href="images/space_cadet_keyboard.gif"><img alt="images/space_cadet_keyboard.gif" src="images/space_cadet_keyboard.gif" style="height: 75pc;" /></a>
</div>
<p>Automation > Typing > Mouse</p>
</article>
<article class="slide level-2" id="help-get-me-out-of-here">
<h2>Help, get me out of here!</h2>
<div class="figure align-center">
<img alt="images/exit.jpg" src="images/exit.jpg" />
</div>
<ul>
<li><p class="first">ctrl+c kills or quits process</p>
</li>
<li><dl class="first docutils">
<dt>ctrl+d sends EOF (end-of-file), closes terminal</dt>
<dd><ul class="first last simple">
<li>also means logout</li>
</ul>
</dd>
</dl>
</li>
<li><p class="first">read what's on your screen; it'll help you</p>
</li>
</ul>
</article>
<article class="slide level-2" id="knowledge-check">
<h2>Knowledge Check</h2>
<div class="highlight-default"><div class="highlight"><pre><span></span>test@x230 ~ $ tree
.
├── Documents
│ ├── Code
│ │ └── scripts
│ │ └── test.sh
│ ├── School
│ └── Work
└── Pictures
├── manatee.gif
└── turtle.png
6 directories, 5 files
</pre></div>
</div>
<ul class="simple">
<li>What user am I logged in as?</li>
<li>What command did I just run?</li>
<li>What is my current directory when I run that command?</li>
</ul>
</article>
<article class="slide level-2" id="more-about-man-pages">
<h2>More about Man Pages</h2>
<ul>
<li><p class="first">the manual (rtfm):</p>
<div class="highlight-default"><div class="highlight"><pre><span></span>$ man <program>
$ man man
</pre></div>
</div>
</li>
<li><p class="first">use <code class="docutils literal"><span class="pre">/phrase</span></code> to search for <code class="docutils literal"><span class="pre">phrase</span></code> in the document; <code class="docutils literal"><span class="pre">n</span></code> for next match
and <code class="docutils literal"><span class="pre">N</span></code> for previous match</p>
</li>
<li><p class="first">else:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span>$ <program> --help
</pre></div>
</div>
</li>
</ul>
</article>
<article class="slide level-2" id="documentation">
<h2>Documentation</h2>
<p>Man pages, blogs you find by Googling, StackOverflow</p>
<div class="figure align-center">
<a class="reference internal image-reference" href="images/google.gif"><img alt="images/google.gif" src="images/google.gif" style="height: 50pc;" /></a>
</div>
<ul>
<li><dl class="first docutils">
<dt>Contribute to community</dt>
<dd><ul class="first last simple">
<li>Correct it if it's wrong</li>
<li>Remind them what newbies don't know</li>
<li>Write your own</li>
</ul>
</dd>
</dl>
</li>
<li><p class="first">For your future self as well</p>
</li>
<li><p class="first">Start now</p>
</li>
</ul>
</article>
<article class="slide level-2" id="asking-for-help">
<h2>Asking for help</h2>
<p>It's okay to ask.</p>
<ol class="arabic simple">
<li>What should be happening?</li>
<li>What's actually happening?</li>
<li>Google it</li>
<li>Skim the manuals of each component</li>
<li>Identify a friend, mentor, or IRC channel who could help</li>
<li>When they're not busy, give them a quick synopsis of points 1 and 2,
mentioning what possibilities you've ruled out by searching.</li>
</ol>
<p><strong>Contributions = expertise + time</strong></p>
<p>Don't waste experts' time, but do build your expertise.</p>
</article>
<article class="slide level-2" id="review">
<h2>Review</h2>
<ul>
<li><p class="first">What's Linux?</p>
</li>
<li><dl class="first docutils">
<dt>How do you open a terminal emulator?</dt>
<dd><ul class="first last simple">
<li>this varies between window managers</li>
</ul>
</dd>
</dl>
</li>
<li><p class="first">I have the script <code class="docutils literal"><span class="pre">test.py</span></code>. How do I run it?</p>
</li>
<li><p class="first">How do you list all the files in the current directory?</p>
</li>
<li><p class="first">Give 2 ways to change directory to your home directory.</p>
</li>
</ul>
</article>
<article class="slide level-2" id="what-are-users">
<h2>What are users?</h2>
<ul class="simple">
<li>You, right now</li>
</ul>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ whoami <span class="c1"># your username</span>
$ who <span class="c1"># who is logged in?</span>
$ w <span class="c1"># who is here and what are they doing?</span>
$ id <span class="c1"># user ID, group ID, and groups you're in</span>
</pre></div>
</div>
<ul class="simple">
<li>Not just people: Apache, Mailman, ntp</li>
</ul>
</article>
<article class="slide level-2" id="users-have">
<h2>Users have</h2>
<ul class="simple">
<li>Username</li>
<li>UID</li>
<li>Group</li>
<li>Shell</li>
<li>Usually (but not always) password</li>
<li>Usually (but not always) home directory</li>
</ul>
</article>
<article class="slide level-2" id="managing-users">
<h2>Managing users</h2>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ cat /etc/passwd
<span class="c1"># username:x:UID:GID:GECOS:homedir:shell</span>
$ useradd <span class="nv">$USER</span> <span class="c1"># vs adduser, the friendly Ubuntu version</span>
$ userdel <span class="nv">$USER</span>
$ passwd
</pre></div>
</div>
<div class="figure align-center">
<img alt="images/xkcd215.png" src="images/xkcd215.png" />
</div>
<div class="highlight-bash"><div class="highlight"><pre><span></span><span class="c1"># GECOS: full name, office number and building, office phone extension,</span>
<span class="c1"># home phone number (General Electric Comprehensive Operating System)</span>
$ chfn <span class="c1"># change GECOS information; only works sometimes</span>
$ finger <span class="c1"># tells you someone's GECOS info</span>
</pre></div>
</div>
</article>
<article class="slide level-2" id="passwords">
<h2>Passwords</h2>
<ul class="simple">
<li><code class="docutils literal"><span class="pre">/etc/shadow</span></code>, not <code class="docutils literal"><span class="pre">/etc/passwd</span></code></li>
</ul>
<div class="highlight-bash"><div class="highlight"><pre><span></span>test@x230 ~ $ ls -l /etc/ <span class="p">|</span> grep shadow
-rw-r----- <span class="m">1</span> root shadow <span class="m">1503</span> Nov <span class="m">12</span> 17:37 shadow
$ sudo su -
$ cat /etc/shadow
daemon:*:15630:0:99999:7:::
bin:*:15630:0:99999:7:::
sys:*:15630:0:99999:7:::
mail:*:15630:0:99999:7:::
<span class="c1"># name:hash:time last changed: min days between changes: max days</span>
<span class="c1"># between changes:days to wait before expiry or disabling:day of</span>
<span class="c1"># account expiry</span>
$ chage <span class="c1"># change when a user's password expires</span>
</pre></div>
</div>
</article>
<article class="slide level-2" id="root-superuser">
<h2>Root/Superuser</h2>
<ul class="simple">
<li>UID 0</li>
<li><code class="docutils literal"><span class="pre">sudo</span></code></li>
</ul>
<div class="figure align-center">
<img alt="images/xkcd149.png" src="images/xkcd149.png" />
</div>
</article>
<article class="slide level-2" id="acting-as-another-user">
<h2>Acting as another user</h2>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ su <span class="nv">$USER</span> <span class="c1"># become user, with THEIR password</span>
$ su <span class="c1"># become root, with root's password</span>
$ sudo su - <span class="c1"># use user password instead of root's</span>
$ sudo su <span class="nv">$USER</span> <span class="c1"># become $USER with your password</span>
</pre></div>
</div>
<div class="figure">
<a class="reference internal image-reference" href="images/xkcd_838.png"><img alt="images/xkcd_838.png" src="images/xkcd_838.png" style="height: 80pc;" /></a>
</div>
<dl class="docutils">
<dt>If someone has permissions errors:</dt>
<dd><ul class="first last simple">
<li>Check that they or their group owns the files</li>
<li>Check that they have the flag +x to execute</li>
</ul>
</dd>
</dl>
</article>
<article class="slide level-2" id="what-are-groups">
<h2>What are groups?</h2>
<ul class="simple">
<li>Manage permissions for groups of users</li>
</ul>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ groupadd
$ usermod
$ groupmod
$ cat /etc/group
root:x:0:
daemon:x:1:
bin:x:2:
sys:x:3:
adm:x:4:
tty:x:5:
<span class="c1"># group name:password or placeholder:GID:member,member,member</span>
</pre></div>
</div>
</article>
<article class="slide level-2" id="hands-on-users-and-groups">
<h2>Hands-On: Users and Groups</h2>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p>To give yourself sudo powers do the following:</p>
<ol class="arabic">
<li><p class="first">Add your user to the <code class="docutils literal"><span class="pre">wheel</span></code> group using <code class="docutils literal"><span class="pre">gpasswd</span></code>.</p>
</li>
<li><p class="first">As the root user, use <code class="docutils literal"><span class="pre">visudo</span></code> and uncomment this line:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">pcwheel</span> <span class="n">ALL</span><span class="o">=</span><span class="p">(</span><span class="n">ALL</span><span class="p">)</span> <span class="n">ALL</span>
</pre></div>
</div>
</li>
<li><p class="first">Save the file and now you should have sudo!</p>
</li>
</ol>
<p class="last"><em>We'll cover sudo in more depth at a later time.</em></p>
</div>
<ul class="simple">
<li>Create a user on your system for yourself, with your preferred username</li>
<li>Give your user sudo powers</li>
<li>Use su to get into your user account</li>
<li>Change your password</li>
<li>Create a directory called bootcamp in your home directory</li>
<li>Create a group called devops</li>
</ul>
</article>
<article class="slide level-2" id="what-are-files">
<h2>What are files?</h2>
<ul>
<li><p class="first">Nearly everything</p>
</li>
<li><dl class="first docutils">
<dt>Files have:</dt>
<dd><ul class="first last simple">
<li>Owner</li>
<li>Permissions</li>
<li>inode</li>
<li>Size</li>
<li>Filename</li>
</ul>
</dd>
</dl>
</li>
</ul>
<div class="highlight-bash"><div class="highlight"><pre><span></span>test@x230 ~ $ ls -il
total 8
<span class="m">2884381</span> drwxrwxr-x <span class="m">5</span> <span class="nb">test</span> <span class="nb">test</span> <span class="m">4096</span> Nov <span class="m">6</span> 11:46 Documents
<span class="m">2629156</span> -rw-rw-r-- <span class="m">1</span> <span class="nb">test</span> <span class="nb">test</span> <span class="m">0</span> Nov <span class="m">13</span> 14:09 file.txt
<span class="m">2884382</span> drwxrwxr-x <span class="m">2</span> <span class="nb">test</span> <span class="nb">test</span> <span class="m">4096</span> Nov <span class="m">6</span> 13:22 Pictures
</pre></div>
</div>
</article>
<article class="slide level-2" id="file-extensions">
<h2>File extensions</h2>
<ul>
<li><p class="first"><code class="docutils literal"><span class="pre">.jpg</span></code>, <code class="docutils literal"><span class="pre">.txt</span></code>, <code class="docutils literal"><span class="pre">.doc</span></code></p>
</li>
<li><dl class="first docutils">
<dt>Really more of a recommendation</dt>
<dd><ul class="first last simple">
<li>File contains information about its encoding</li>
</ul>
</dd>
</dl>
</li>
</ul>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ file <span class="nv">$FILENAME</span> <span class="c1"># tells you about the filetype</span>
test@x230 ~ $ file file.txt
file.txt: ASCII text
test@x230 ~ $ file squirrel.jpg
squirrel.jpg: JPEG image data, JFIF standard 1.01
</pre></div>
</div>
</article>
<article class="slide level-2" id="ls-l">
<h2>ls -l</h2>
<ul class="simple">
<li>First bit: type</li>
<li>Next 3: user</li>
<li>Next 3: group</li>
<li>Next 3: world</li>
<li>user & group</li>
</ul>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ ls -l
drwxrwxr-x <span class="m">5</span> <span class="nb">test</span> <span class="nb">test</span> <span class="m">4096</span> Nov <span class="m">6</span> 11:46 Documents
-rw-rw-r-- <span class="m">1</span> <span class="nb">test</span> <span class="nb">test</span> <span class="m">0</span> Nov <span class="m">13</span> 14:09 file.txt
drwxrwxr-x <span class="m">2</span> <span class="nb">test</span> <span class="nb">test</span> <span class="m">4096</span> Nov <span class="m">6</span> 13:22 Pictures
</pre></div>
</div>
</article>
<article class="slide level-2" id="chmod-and-octal-permissions">
<h2>chmod and octal permissions</h2>
<div class="highlight-bash"><div class="highlight"><pre><span></span>+-----+--------+-------+
<span class="p">|</span> rwx <span class="p">|</span> Binary <span class="p">|</span> Octal <span class="p">|</span>
+-----+--------+-------+
<span class="p">|</span> --- <span class="p">|</span> <span class="m">000</span> <span class="p">|</span> <span class="m">0</span> <span class="p">|</span>
<span class="p">|</span> --x <span class="p">|</span> <span class="m">001</span> <span class="p">|</span> <span class="m">1</span> <span class="p">|</span>
<span class="p">|</span> -w- <span class="p">|</span> <span class="m">010</span> <span class="p">|</span> <span class="m">2</span> <span class="p">|</span>
<span class="p">|</span> -wx <span class="p">|</span> <span class="m">011</span> <span class="p">|</span> <span class="m">3</span> <span class="p">|</span>
<span class="p">|</span> r-- <span class="p">|</span> <span class="m">100</span> <span class="p">|</span> <span class="m">4</span> <span class="p">|</span>
<span class="p">|</span> r-x <span class="p">|</span> <span class="m">101</span> <span class="p">|</span> <span class="m">5</span> <span class="p">|</span>
<span class="p">|</span> rw- <span class="p">|</span> <span class="m">110</span> <span class="p">|</span> <span class="m">6</span> <span class="p">|</span>
<span class="p">|</span> rwx <span class="p">|</span> <span class="m">111</span> <span class="p">|</span> <span class="m">7</span> <span class="p">|</span>
+-----+--------+-------+
</pre></div>
</div>
<ul class="simple">
<li>u, g, o for user, group, other</li>
<li>-, +, = for remove, add, set</li>
<li>r, w, x for read, write, execute</li>
</ul>
</article>
<article class="slide level-2" id="chown-chgrp">
<h2>chown, chgrp</h2>
<p>user & group</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span><span class="c1"># Change the owner of myfile to "root".</span>
$ chown root myfile
<span class="c1"># Likewise, but also change its group to "staff".</span>
$ chown root:staff myfile
<span class="c1"># Change the owner of /mydir and subfiles to "root".</span>
$ chown -hR root /mydir
<span class="c1"># Make the group devops own the bootcamp dir</span>
$ chgrp -R devops /home/<span class="nv">$yourusername</span>/bootcamp
</pre></div>
</div>
</article>
<article class="slide level-2" id="types-of-files">
<h2>Types of files</h2>
<div class="highlight-bash"><div class="highlight"><pre><span></span>drwxrwxr-x <span class="m">5</span> <span class="nb">test</span> <span class="nb">test</span> <span class="m">4096</span> Nov <span class="m">6</span> 11:46 Documents
-rw-rw-r-- <span class="m">1</span> <span class="nb">test</span> <span class="nb">test</span> <span class="m">0</span> Nov <span class="m">13</span> 14:09 file.txt
drwxrwxr-x <span class="m">2</span> <span class="nb">test</span> <span class="nb">test</span> <span class="m">4096</span> Nov <span class="m">6</span> 13:22 Pictures
---------- ------- ------- -------- ------------ -------------
<span class="p">|</span> <span class="p">|</span> <span class="p">|</span> <span class="p">|</span> <span class="p">|</span> <span class="p">|</span>
<span class="p">|</span> <span class="p">|</span> <span class="p">|</span> <span class="p">|</span> <span class="p">|</span> File Name
<span class="p">|</span> <span class="p">|</span> <span class="p">|</span> <span class="p">|</span> +--- Modification Time
<span class="p">|</span> <span class="p">|</span> <span class="p">|</span> +------------- Size <span class="o">(</span>in bytes<span class="o">)</span>
<span class="p">|</span> <span class="p">|</span> +----------------------- Group
<span class="p">|</span> +-------------------------------- Owner
+---------------------------------------------- File Permissions
</pre></div>
</div>
<p><code class="docutils literal"><span class="pre">-</span></code> is a normal file</p>
<p><code class="docutils literal"><span class="pre">d</span></code> is a directory</p>
<p><code class="docutils literal"><span class="pre">b</span></code> is a block device</p>
</article>
<article class="slide level-2" id="hands-on-files-and-permissions">
<h2>Hands-On: Files and Permissions</h2>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ touch foo <span class="c1"># create empty file called foo</span>
</pre></div>
</div>
<ul class="simple">
<li>As root, create a file in /home/$yourusername/bootcamp</li>
<li>Who can do what to the file?</li>
<li>Make the devops group own the file</li>
<li>Make a file called allperms and give user, group, and world +rwx</li>
<li>Make more files and practice changing their permissions</li>
</ul>
</article>
<article class="slide level-2" id="package-management">
<h2>Package Management</h2>
<p><em>Take care of installation and removal of software</em></p>
<p><strong>Core Functionality:</strong>
* Install, Upgrade & uninstall packages easily
* Resolve package dependencies
* Install packages from a central repository
* Search for information on installed packages and files
* Pre-built binaries (usually)
* Find out which package provides a required library or file</p>
<p><strong>Popular Linux Package Managers</strong>
* .deb / APT + dpkg (used by Debian, Ubuntu, Linux Mint)
* .rpm / YUM + rpm (used by RedHat, CentOS, Fedora)</p>
</article>
<article class="slide level-2" id="language-specific-package-managers">
<h2>Language-specific Package Managers</h2>
<ul>
<li><p class="first">Languages sometimes have their own package management suite</p>
</li>
<li><p class="first">Can be useful for using newer versions of packages</p>
</li>
<li><dl class="first docutils">
<dt><strong>Examples</strong></dt>
<dd><ul class="first last simple">
<li>pip (Python)</li>
<li>rubygems (Ruby)</li>
<li>CPAN (Perl)</li>
<li>cabal (Haskell)</li>
<li>npm (NodeJS)</li>
<li><em>... and so on forever ...</em></li>
</ul>
</dd>
</dl>
</li>
</ul>
</article>
<article class="slide level-2" id="other-package-managers">
<h2>Other Package Managers</h2>
<p>They each fill a specific niche and have their own pros and cons.</p>
<ul class="simple">
<li>Portage (Gentoo) -- Source based package installer</li>
<li>pacman (Arch Linux)</li>
<li>ZYpp / Zypper (SUSE) -- Yet another RPM package manager</li>
<li>Nix -- Fancy functional/ transactional</li>
<li>brew (OS X)</li>
<li>chocolatey (Windows)</li>
</ul>
</article>
<article class="slide level-2" id="installing-from-source">
<h2>Installing from source</h2>
<ul class="simple">
<li>Download source tarball, run build scripts and install in a local directory.</li>
<li>RPM/DEB packages do this for you</li>
<li>Not for the faint of heart ... <strong>Not recommended!</strong></li>
<li>Using <code class="docutils literal"><span class="pre">grep</span></code> as an example</li>
</ul>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ wget http://mirrors.kernel.org/gnu/grep/grep-2.15.tar.xz
$ tar -Jxvf grep-2.15.tar.xz
$ <span class="nb">cd</span> grep-2.15
$ ./configure --prefix<span class="o">=</span><span class="nv">$HOME</span>/programs/
$ make
$ make install
</pre></div>
</div>
</article>
<article class="slide level-2" id="hands-on-package-management">
<h2>Hands-on: Package Management</h2>
<ul class="simple">
<li>Install the <code class="docutils literal"><span class="pre">git</span></code> package</li>
<li>Query the RPM/APT database for installed packages</li>
<li>List the files in an installed package</li>
<li>Remove the <code class="docutils literal"><span class="pre">git</span></code> package</li>
</ul>
</article>
<article class="slide level-2" id="id1">
<h2>Review</h2>
<ul>
<li><p class="first">read example output of ls -al</p>
</li>
<li><p class="first">read output of yum or aptitude search</p>
</li>
<li><dl class="first docutils">
<dt>install a package on their VM/partition (Vim, Git)</dt>
<dd><ul class="first last simple">
<li>explain what dependencies it also installed</li>
</ul>
</dd>
</dl>
</li>
</ul>
</article>
<article class="slide level-2" id="irc">
<h2>IRC</h2>
<div class="figure align-center">
<a class="reference internal image-reference" href="images/multiple_networks.gif"><img alt="images/multiple_networks.gif" src="images/multiple_networks.gif" style="height: 40pc;" /></a>
</div>
<ul class="simple">
<li>Internet Relay Chat</li>
<li>Very old (RFC 1459 May 1993)</li>
<li>Works on everything (no GUI needed)</li>
<li>The people you want to listen to are there</li>
<li>Oregon State ran one of the first servers ever!</li>