-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasics.html
More file actions
2066 lines (1934 loc) · 87.2 KB
/
basics.html
File metadata and controls
2066 lines (1934 loc) · 87.2 KB
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 charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<title>Linux basics</title>
<style type="text/css">
/* Color Palette Based on Monokai
white : #fafafa
light grey : #efefef
grey : #75715e
dark grey : #272822
black : #191919
light blue : #66d9ef
blue : #1db4d0
lavender : #bf79db
magenta : #f92672
light green : #a6e22e
*/
/* Local Fonts */
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 300;
src: url('fonts/opensans/300.woff2') format('woff2'),
url('fonts/opensans/300.woff') format('woff');
}
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 400;
src: url('fonts/opensans/400.woff2') format('woff2'),
url('fonts/opensans/400.woff') format('woff');
}
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 600;
src: url('fonts/opensans/600.woff2') format('woff2'),
url('fonts/opensans/600.woff') format('woff');
}
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 700;
src: url('fonts/opensans/700.woff2') format('woff2'),
url('fonts/opensans/700.woff') format('woff');
}
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 800;
src: url('fonts/opensans/800.woff2') format('woff2'),
url('fonts/opensans/800.woff') format('woff');
}
@font-face {
font-family: 'Open Sans';
font-style: italic;
font-weight: 300;
src: url('fonts/opensans/300i.woff2') format('woff2'),
url('fonts/opensans/300i.woff') format('woff');
}
@font-face {
font-family: 'Open Sans';
font-style: italic;
font-weight: 400;
src: url('fonts/opensans/400i.woff2') format('woff2'),
url('fonts/opensans/400i.woff') format('woff');
}
@font-face {
font-family: 'Open Sans';
font-style: italic;
font-weight: 600;
src: url('fonts/opensans/600i.woff2') format('woff2'),
url('fonts/opensans/600i.woff') format('woff');
}
@font-face {
font-family: 'Open Sans';
font-style: italic;
font-weight: 700;
src: url('fonts/opensans/700i.woff2') format('woff2'),
url('fonts/opensans/700i.woff') format('woff');
}
@font-face {
font-family: 'Open Sans';
font-style: italic;
font-weight: 800;
src: url('fonts/opensans/800i.woff2') format('woff2'),
url('fonts/opensans/800i.woff') format('woff');
}
@font-face {
font-family: 'Merriweather';
font-style: normal;
font-weight: 400;
src: url('fonts/merriweather/400.woff2') format('woff2'),
url('fonts/merriweather/400.woff') format('woff');
}
@font-face {
font-family: 'Merriweather';
font-style: normal;
font-weight: 700;
src: url('fonts/merriweather/700.woff2') format('woff2'),
url('fonts/merriweather/700.woff') format('woff');
}
@font-face {
font-family: 'Merriweather';
font-style: normal;
font-weight: 900;
src: url('fonts/merriweather/900.woff2') format('woff2'),
url('fonts/merriweather/900.woff') format('woff');
}
@font-face {
font-family: 'Merriweather';
font-style: italic;
font-weight: 400;
src: url('fonts/merriweather/400i.woff2') format('woff2'),
url('fonts/merriweather/400i.woff') format('woff');
}
@font-face {
font-family: 'Merriweather';
font-style: italic;
font-weight: 700;
src: url('fonts/merriweather/700i.woff2') format('woff2'),
url('fonts/merriweather/700i.woff') format('woff');
}
@font-face {
font-family: 'Merriweather';
font-style: italic;
font-weight: 900;
src: url('fonts/merriweather/900i.woff2') format('woff2'),
url('fonts/merriweather/900i.woff') format('woff');
}
@font-face {
font-family: 'Fira Mono';
font-style: normal;
font-weight: 400;
src: url('fonts/fira/400.woff2') format('woff2'),
url('fonts/fira/400.woff') format('woff');
}
@font-face {
font-family: 'Fira Mono';
font-style: normal;
font-weight: 500;
src: url('fonts/fira/500.woff2') format('woff2'),
url('fonts/fira/500.woff') format('woff');
}
@font-face {
font-family: 'Fira Mono';
font-style: normal;
font-weight: 700;
src: url('fonts/fira/700.woff2') format('woff2'),
url('fonts/fira/700.woff') format('woff');
}
/* Theme Styles */
body {
font-family: 'Open Sans', sans-serif;
font-size: 100%;
color: #fafafa;
background-color: #191919;
}
/* Custom Slide Styles */
#slide-1 {
background: #222 url(wireball.png) center center no-repeat;
background-size: cover;
}
#slide-1 h1 {
text-shadow: 1px 2px 4px #191919;
}
#slide-1 p {
text-shadow: 1px 1px 1px #191919;
}
.center {
text-align: center;
}
img.badge {
height: 128px;
width: 128px !important;
border-radius: 50% !important;
}
/* Presentation Styles */
.slide {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
padding: 100px;
}
.slide-content {
height: 100%;
width: 100%;
padding: 0;
margin: 0 auto;
font-size: 200%;
font-weight: 200;
line-height: 1.375;
overflow: hidden;
}
.slide-content img {
width: 100%;
border-radius: 3px;
}
.controls {
position: absolute;
bottom: 10px;
left: 10px;
}
.arrow {
float: left;
height: 0;
width: 0;
margin-right: 15px;
border: 15px solid #272822;
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.prev {
border-top-color: transparent;
border-right-width: 25px;
border-bottom-color: transparent;
border-left-color: transparent;
border-left-width: 0;
}
.next {
border-top-color: transparent;
border-right-color: transparent;
border-right-width: 0;
border-bottom-color: transparent;
border-left-width: 25px;
}
.prev:hover {
border-right-color: #efefef;
cursor: pointer;
}
.next:hover {
border-left-color: #efefef;
cursor: pointer;
}
h1,
h2,
h3 {
font-family: 'Merriweather', serif;
}
h1 {
margin: 170px 0 0;
font-size: 300%;
text-align: center;
line-height: 1.2;
}
h2 {
margin: 5px 0;
font-size: 100%;
font-weight: 200;
text-align: center;
line-height: 1.2;
}
h3 {
margin: 0;
padding-bottom: 15px;
font-size: 140%;
line-height: 1.2;
border-bottom: 2px ridge #fafafa;
}
ul {
padding: 20px 0 0 60px;
font-weight: 200;
line-height: 1.375;
}
blockquote {
padding-left: 20px;
margin-left: 0;
background: #272822;
border-left: 5px solid #efefef;
border-radius: 0 3px 3px 0;
}
blockquote p {
padding: .5em;
color: #efefef;
}
.left {
float: left;
width: 48%;
}
.right {
float: right;
width: 48%;
}
.author h1 {
margin-bottom: 30px;
font-size: 170%;
font-weight: 200;
text-align: center;
}
.author h3 {
font-size: 95%;
font-weight: 100;
text-align: center;
border: none;
}
.author h3.twitter::before {
content: 'Twitter: ';
}
.author h3.github::before {
content: 'Github: ';
}
.author h3.email::before {
content: 'Email: ';
}
.author h3.url::before {
content: 'Web: ';
}
a {
text-decoration: none;
color: #66d9ef;
}
a:hover {
color: #66d9ef;
border-bottom: 1px solid #66d9ef;
}
hr {
border: 1px solid #efefef;
}
pre {
font-size: 75%;
line-height: 1.3;
}
table td,
table th {
padding-right: 3em;
text-align: left;
}
.progress {
position: fixed;
top: 0;
right: 0;
left: 0;
height: 3px;
}
.progress-bar {
height: 3px;
width: 0;
background-color: #a6e22e;
-webkit-transition: width .15s ease-out;
-moz-transition: width .15s ease-out;
-o-transition: width .15s ease-out;
transition: width .15s ease-out;
}
.hidden {
display: none;
}
/* Code Highlighting */
code {
padding: .1em .35em;
font-family: 'Fira Mono';
color: #fafafa;
background-color: #272822;
border-radius: 3px;
}
pre code {
display: block;
padding: .5em;
font-family: 'Fira Mono';
font-weight: 400;
overflow-y: hidden;
background: #272822;
}
pre .tag,
pre .tag .title,
pre .keyword,
pre .literal,
pre .change,
pre .winutils,
pre .flow,
pre .lisp .title,
pre .clojure .built_in,
pre .nginx .title,
pre .tex .special {
color: #f92672;
}
pre code {
color: #75715e;
}
pre code .constant {
color: #66d9ef;
}
pre .class .title {
color: #fafafa;
}
pre .attribute,
pre .symbol,
pre .symbol .string,
pre .value,
pre .regexp {
color: #bf79db;
}
pre .tag .value,
pre .string,
pre .subst,
pre .title,
pre .haskell .type,
pre .preprocessor,
pre .ruby .class .parent,
pre .built_in,
pre .sql .aggregate,
pre .django .template_tag,
pre .django .variable,
pre .smalltalk .class,
pre .javadoc,
pre .django .filter .argument,
pre .smalltalk .localvars,
pre .smalltalk .array,
pre .attr_selector,
pre .pseudo,
pre .addition,
pre .stream,
pre .envvar,
pre .apache .tag,
pre .apache .cbracket,
pre .tex .command,
pre .prompt {
color: #a6e22e;
}
pre .comment,
pre .java .annotation,
pre .python .decorator,
pre .template_comment,
pre .pi,
pre .doctype,
pre .deletion,
pre .shebang,
pre .apache .sqbracket,
pre .tex .formula {
color: #75715e;
}
pre .keyword,
pre .literal,
pre .css .id,
pre .phpdoc,
pre .title,
pre .haskell .type,
pre .vbscript .built_in,
pre .sql .aggregate,
pre .rsl .built_in,
pre .smalltalk .class,
pre .diff .header,
pre .chunk,
pre .winutils,
pre .bash .variable,
pre .apache .tag,
pre .tex .special,
pre .request,
pre .status {
/* font-weight: 600; */
}
pre .coffeescript .javascript,
pre .javascript .xml,
pre .tex .formula,
pre .xml .javascript,
pre .xml .vbscript,
pre .xml .css,
pre .xml .cdata {
opacity: .5;
}
/* Responsiveness */
@media (max-width: 850px) {
body {
font-size: 70%;
}
.slide-content {
width: auto;
}
img {
width: 100%;
border-radius: 3px;
}
h1 {
margin-top: 120px;
}
.prev,
.prev:hover {
border-right-color: rgba(135, 135, 135, .5);
}
.next,
.next:hover {
border-left-color: rgba(135, 135, 135, .5);
}
}
@media (max-width: 480px) {
body {
overflow: hidden;
font-size: 50%;
}
.slide-content {
height: 340px;
padding: 10px;
margin-top: 10px;
}
h1 {
margin-top: 50px;
}
ul {
padding-left: 25px;
}
}
@media print {
* {
-webkit-print-color-adjust: exact;
}
@page {
size: letter;
}
.hidden {
display: inline;
}
html {
height: 100%;
width: 100%;
overflow: visible;
}
body {
float: none !important;
padding: 0;
margin: 0 auto !important;
overflow: visible;
font-size: 52%;
background: none !important;
border: 0;
}
.progress,
.controls {
display: none;
}
.slide {
position: static;
}
.slide-content {
margin-top: 0;
margin-bottom: 40px;
height: 3.5in;
overflow: visible;
border: 1px solid #222;
}
.slide:nth-child(even) {
/* 2 slides per page */
page-break-before: always;
}
}
</style>
</head>
<body>
<div class="progress">
<div class="progress-bar"></div>
</div>
<div class="slide" id="slide-1">
<section class="slide-content"><h1 id="linux-basics">Linux basics</h1>
<h2 id="a-quick-look-at-some-common-linux-commands">A quick look at some common linux commands</h2>
</section>
</div>
<div class="slide hidden" id="slide-2">
<section class="slide-content"><h3 id="contents">Contents</h3>
<ul>
<li>Why?</li>
<li>Directory structure, file paths and files</li>
<li>Text manipulation</li>
<li>Advanced text manipulation</li>
<li>Connectivity</li>
<li>Advanced structure / file etc.</li>
<li>Process / user control / information</li>
<li>Help / recall</li>
<li>Environments</li>
<li>System</li>
</ul>
</section>
</div>
<div class="slide hidden" id="slide-3">
<section class="slide-content"><h3 id="why-">Why?</h3>
<p>There are many reasons that you might need to use the linux command line. The main one being that most of the servers that you will be interacting with do not have any other means of input. They run in a 'headless' state, where they normally don't have a keyboard, mouse or monitor plugged into them and the only way to interact is via 'ssh'. </p>
<p>This means we only have a text interface to them. But that's ok. We can do everything (and more) with just this interface.</p>
</section>
</div>
<div class="slide hidden" id="slide-4">
<section class="slide-content"><h3 id="directory-structure-file-paths-and-files">Directory structure, file paths and files</h3>
<p>To help demonstrate this, we will look at the commands being executed on the command line alongside a file explore showing a visual representation of what's happening. </p>
<p>So, start up a terminal on your local machine and also start up a file explorer on your local machine. Your terminal should start in your home directory. </p>
<p>By the end of these slides, you should be able to navigate around your home directory in the terminal and see the same locations/files in your file explorer.</p>
</section>
</div>
<div class="slide hidden" id="slide-5">
<section class="slide-content"><h3 id="directory-structure-file-paths-and-files">Directory structure, file paths and files</h3>
<h4 id="in-this-section-">In this section:</h4>
<ul>
<li><code>ls</code></li>
<li><code>pwd</code></li>
<li><code>cd</code></li>
<li>understanding paths</li>
<li><code>cp</code></li>
<li><code>mv</code></li>
<li><code>touch</code></li>
<li><code>rmdir</code></li>
<li><code>rm</code></li>
<li><code>mkdir</code></li>
<li><code>file</code></li>
<li>understanding wild cards</li>
</ul>
</section>
</div>
<div class="slide hidden" id="slide-6">
<section class="slide-content"><h3 id="directory-structure-file-paths-and-files-ls-l-i-s-t">Directory structure, file paths and files : <code>ls</code> - [L]i[s]t</h3>
<p>This is used to list the contents of a directory. You should have started in your home directory, so this should show you the contents of this. Any files will be listed by name here and should match those shown in your file explorer. The -l swtich will give extra info.</p>
<pre><code class="lang-bash">> ls
master.zip
mefffix_m3_test.actual
build_codes.log
</code></pre>
<pre><code class="lang-bash">> ls -l
-rw-rw-r--. 1 michaelr michaelr 402 Mar 27 19:51 build_codes.log
-rw-rw-r--. 1 michaelr michaelr 143335 Feb 16 11:45 master.zip
-rw-r--r--. 1 michaelr michaelr 176120 Dec 11 2014 mefffix_m3_test.actual
</code></pre>
</section>
</div>
<div class="slide hidden" id="slide-7">
<section class="slide-content"><h3 id="directory-structure-file-paths-and-files-pwd-p-rint-w-orking-d-irectory">Directory structure, file paths and files : <code>pwd</code> - [P]rint [W]orking [D]irectory</h3>
<p>Shows the directory you are currently executing commands in.</p>
<pre><code class="lang-bash">> <span class="hljs-built_in">pwd</span>
/home/mrobinson/git/training/linux/basics
</code></pre>
</section>
</div>
<div class="slide hidden" id="slide-8">
<section class="slide-content"><h3 id="directory-structure-file-paths-and-files-cd-c-hange-d-irectory">Directory structure, file paths and files : <code>cd</code> - [C]hange [D]irectory</h3>
<p>Changes to another directory </p>
<pre><code class="lang-bash">> <span class="hljs-built_in">cd</span> /home/mrobinson/git/training/
> <span class="hljs-built_in">pwd</span>
/home/mrobinson/git/training
</code></pre>
</section>
</div>
<div class="slide hidden" id="slide-9">
<section class="slide-content"><h3 id="directory-structure-file-paths-and-files-paths">Directory structure, file paths and files : Paths</h3>
<p>There are two types of paths. Relative and absolute. Relative paths are relative to the directory you are in.</p>
<pre><code class="lang-bash">> <span class="hljs-built_in">pwd</span>
/home/mrobinson
<span class="hljs-built_in">cd</span> git/training/
> <span class="hljs-built_in">pwd</span>
/home/mrobinson/git/training
</code></pre>
<p>Absolute paths are full paths from the very root of the file system and can be used no matter which directory you are in. </p>
<pre><code class="lang-bash">> <span class="hljs-built_in">pwd</span>
/home/mrobinson/
<span class="hljs-built_in">cd</span> /home/mrobinson/git/training/
> <span class="hljs-built_in">pwd</span>
/home/mrobinson/git/training
</code></pre>
<p>Lastly a "." indicates the current directory. Try <code>ls .</code> for example.</p>
</section>
</div>
<div class="slide hidden" id="slide-10">
<section class="slide-content"><h3 id="directory-structure-file-paths-and-files-cp-c-o-p-y">Directory structure, file paths and files : <code>cp</code> - [C]o[p]y</h3>
<p>Copy a file from one place to another. Full or relative paths can be used. </p>
<pre><code class="lang-bash">> cp /home/mrobinson/git/training/linux/README /home/mrobinson/git/training/DONTREADME
> ls
DONTREADME linux
</code></pre>
<pre><code class="lang-bash">> cp DONTREADME ICANTEVENREAD
> ls
DONTREADME ICANTEVENREAD linux
</code></pre>
</section>
</div>
<div class="slide hidden" id="slide-11">
<section class="slide-content"><h3 id="directory-structure-file-paths-and-files-mv-m-o-v-e">Directory structure, file paths and files : <code>mv</code> - [M]o[v]e</h3>
<p>This is used to move a file from one place to another. It is also used to rename files (as this is the same as moving the file to a different name, but keeping it's location the same). </p>
<pre><code class="lang-bash">mv DONTREADME /tmp/
> ls
ICANTEVENREAD linux
> ls /tmp/
basics.html
DONTREADME
tmux-947
</code></pre>
<pre><code class="lang-bash">> mv ICANTEVENREAD WoopWoopItsTheSoundOfThePolice
> ls
linux WoopWoopItsTheSoundOfThePolice
</code></pre>
</section>
</div>
<div class="slide hidden" id="slide-12">
<section class="slide-content"><h3 id="directory-structure-file-paths-and-files-mkdir-m-a-k-e-d-irectory">Directory structure, file paths and files : <code>mkdir</code> - [M]a[k]e [D]irectory</h3>
<p>This creates a new directory. If we use the -l swtich for ls, we can see it's directory by looking at the first character, which is a d. If you have colours enabled for your terminal you should also noticed that it's a different colour. </p>
<pre><code class="lang-bash">> mkdir SleepIsForTheWeak
> ls -l
total 16
drwxrwxr-x. 7 michaelr michaelr 1024 Jul 10 09:05 linux
drwxrwxr-x. 2 michaelr michaelr 80 Jul 10 10:40 SleepIsForTheWeak
-rw-rw-r--. 1 michaelr michaelr 1003 Jul 10 10:25 WoopWoopItsTheSoundOfThePolice
</code></pre>
</section>
</div>
<div class="slide hidden" id="slide-13">
<section class="slide-content"><h3 id="directory-structure-file-paths-and-files-rm-r-e-m-ove">Directory structure, file paths and files : <code>rm</code> - [R]e[m]ove</h3>
<p>This deletes files. Be careful, they can't be recovered. If you need to remove a directory you can use the -r (recursive) switch. Again, be careful, this will delete everything in the directory supplied. </p>
<pre><code class="lang-bash">> rm WoopWoopItsTheSoundOfThePolice
> ls
linux SleepIsForTheWeak
> rm SleepIsForTheWeak/
rm: cannot remove ‘SleepIsForTheWeak/’: Is a directory
> rm -r SleepIsForTheWeak/
> ls
linux
</code></pre>
</section>
</div>
<div class="slide hidden" id="slide-14">
<section class="slide-content"><h3 id="directory-structure-file-paths-and-files-file-return-the-type-of-file">Directory structure, file paths and files : <code>file</code> - Return the type of file</h3>
<p>This can be useful if you're not sure what a file is. It can identify many different file types and show some extra information on them. Files may not always have extensions you recognise or have an extension at all, this command ignores that. </p>
<pre><code class="lang-bash">> file linux/
linux/: directory
> file linux/basics.html
linux/basics.html: HTML document, UTF-8 Unicode text, with very long lines
> file linux/basics/basics.md
linux/basics/basics.md: UTF-8 Unicode text, with very long lines
> file /usr/bin/bash
/usr/bin/bash: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), <span class="hljs-keyword">for</span> GNU/Linux 2.6.32, BuildID[sha1]=0x7e60e3500525487556361588a7e2818807f5815a, stripped
</code></pre>
</section>
</div>
<div class="slide hidden" id="slide-15">
<section class="slide-content"><h3 id="directory-structure-file-paths-and-files-wild-cards">Directory structure, file paths and files : Wild cards</h3>
<p>A wildcard is a symbol used to replace or represent one or more characters. Wildcards are typically either an asterisk (*), which represents one or more characters or question mark (?), which represents a single character. This means the same command can be executed on many files at the same time. </p>
<pre><code class="lang-bash">> ls Q*
QuoteHandler.cc QuotePublisher.cc QuoteQualifier.cc QuoteSource.cc QuoteUpdate.cc
QuoteHandler.h QuotePublisher.h QuoteQualifier.h QuoteSource.h QuoteUpdate.h
</code></pre>
<pre><code class="lang-bash">> ls Q*.?
QuoteHandler.h QuotePublisher.h QuoteQualifier.h QuoteSource.h QuoteUpdate.h
</code></pre>
<pre><code class="lang-bash">> ls Q*.??
QuoteHandler.cc QuotePublisher.cc QuoteQualifier.cc QuoteSource.cc QuoteUpdate.cc
</code></pre>
</section>
</div>
<div class="slide hidden" id="slide-16">
<section class="slide-content"><h3 id="text-manipulation">Text manipulation</h3>
<p>This section will go into some basics on display, storing and redirecting output streams from programs. This allows you to 'pipe' or chain various commands together. </p>
<p>It will then show some examples of common commands that are used to manipulate this data, allowing you to ignore parts of it, search for specific things, subsitute text for other text or maybe split it all up into columns.</p>
</section>
</div>
<div class="slide hidden" id="slide-17">
<section class="slide-content"><h3 id="text-manipulation">Text manipulation</h3>
<h4 id="in-this-section">In this section</h4>
<ul>
<li>Input and output</li>
<li>Redirection</li>
<li>stdout, stdin and stderr</li>
<li><code>echo</code></li>
<li><code>cat</code></li>
<li><code>head</code></li>
<li><code>tail</code></li>
<li><code>less</code></li>
<li><code>cut</code></li>
<li><code>grep</code></li>
</ul>
</section>
</div>
<div class="slide hidden" id="slide-18">
<section class="slide-content"><h3 id="text-manipulation-input-and-output">Text manipulation : Input and output</h3>
<p>There are a few different places that programs can get and print data. The standard ones for communication between a keyboard, a program and a display are below, the reasons for the file descriptors will become apparent later:</p>
<ul>
<li>stdin - file descriptor 0<ul>
<li>Standard input, Unless redirected, standard input is expected from the keyboard which started the program.</li>
</ul>
</li>
<li>stdout - file descriptor 1<ul>
<li>Standard output, Unless redirected, standard output is the text terminal which initiated the program.</li>
</ul>
</li>
<li>stderr - file descriptor 2<ul>
<li>Standard error, The usual destination is the text terminal which started the program. It is acceptable, and normal, for standard output and standard error to be directed to the same destination.</li>
</ul>
</li>
</ul>
</section>
</div>
<div class="slide hidden" id="slide-19">
<section class="slide-content"><h3 id="text-manipulation-redirection">Text manipulation : Redirection</h3>
<p>Text can be redirected from a command to a file using the <code>></code> character, or into a command using <code><</code> and lastly append to a file using <code>>></code>. This can be used to redirect all the inputs and outputs from the last slide (this is where the file descriptor is used)</p>
<p>The next few slides will show examples of each</p>
</section>
</div>
<div class="slide hidden" id="slide-20">
<section class="slide-content"><h3 id="text-manipulation-redirection">Text manipulation : Redirection</h3>
<h4 id="stdout-to-file">stdout to file</h4>
<p>This will cause the ouput of a program to be written to a file.</p>
<pre><code class="lang-bash">ls -l > ls-l.txt
</code></pre>
<p>Here, a file called <code>ls-l.txt</code> will be created and it will contain what you would see on the screen if you type the command <code>ls -l</code> and execute it.</p>
<h4 id="stderr-to-file">stderr to file</h4>
<p>This will cause the stderr ouput of a program to be written to a file.</p>
<pre><code class="lang-bash">grep da * 2> grep-errors.txt
</code></pre>
<p>Here, a file called <code>grep-errors.txt</code> will be created and it will contain what you would see the stderr portion of the output of the <code>grep da *</code> command.</p>
</section>
</div>
<div class="slide hidden" id="slide-21">
<section class="slide-content"><h3 id="text-manipulation-redirection">Text manipulation : Redirection</h3>
<h4 id="stdout-to-stderr">stdout to stderr</h4>
<p>This will cause the stderr ouput of a program to be written to the same filedescriptor than stdout.</p>
<pre><code class="lang-bash">grep da * 1>&2
</code></pre>
<p>Here, the stdout portion of the command is sent to stderr, you may notice that in different ways.</p>
<h4 id="stderr-to-stdout">stderr to stdout</h4>
<p>This will cause the stderr ouput of a program to be written to the same filedescriptor than stdout.</p>
<pre><code class="lang-bash">grep * 2>&1
</code></pre>
<p>Here, the stderr portion of the command is sent to stdout, if you pipe to less, you'll see that lines that normally 'dissapear' (as they are written to stderr) are being kept now (because they're on stdout).</p>
</section>
</div>
<div class="slide hidden" id="slide-22">
<section class="slide-content"><h3 id="text-manipulation-redirection">Text manipulation : Redirection</h3>
<h4 id="stderr-and-stdout-to-file">stderr and stdout to file</h4>
<p>This will place every output of a program to a file. This is suitable sometimes for cron entries, if you want a command to pass in absolute silence. There are two ways, the first is the full version (note where the redirection is) and the second is the shorthand. </p>
<pre><code class="lang-bash">grep * > /dev/null 2>&1
</code></pre>
<pre><code class="lang-bash">grep * &> /dev/null
</code></pre>
<h4 id="stdin-from-file">stdin from file</h4>
<p>This is less common and I include it for completeness, though there are scenarios where it's useful. This will take the the contents of a file and use it in place of standard input. </p>
<pre><code class="lang-bash">cat < grep-errors.txt
</code></pre>
</section>
</div>
<div class="slide hidden" id="slide-23">
<section class="slide-content"><h3 id="text-manipulation-pipes">Text manipulation : Pipes</h3>
<p>Pipes let you use the output of a program as the input of another one</p>
<pre><code class="lang-bash">ls -l | grep error
</code></pre>
<p>Here, the following happens: first the command ls -l is executed, and it's output, instead of being printed, is sent (piped) to the grep program, which in turn, prints what it has to. In this example we would be better using wild cards <code>ls -l *error*</code>, but you will see as we go on what other commands can be chained together in this way.</p>
</section>
</div>
<div class="slide hidden" id="slide-24">
<section class="slide-content"><h3 id="text-manipulation-echo">Text manipulation : <code>echo</code></h3>
<p>Echo will take a string and output it back to standard out. This isn't particularly useful on command line alone, but can be when you start to write scripts. </p>
<pre><code class="lang-bash">> <span class="hljs-built_in">echo</span> <span class="hljs-string">"Work is the curse of the drinking classes"</span>
Work is the curse of the drinking classes
</code></pre>
<p>This can be redirected though if you wanted to create a file</p>
<pre><code class="lang-bash"><span class="hljs-built_in">echo</span> <span class="hljs-string">"Work is the curse of the drinking classes"</span> > quotes.txt
</code></pre>
<p>And appended to if required</p>
<pre><code class="lang-bash">> <span class="hljs-built_in">echo</span> <span class="hljs-string">"I love deadlines. I love the whooshing noise they make as they go by."</span> >> quotes.txt
</code></pre>
</section>
</div>
<div class="slide hidden" id="slide-25">
<section class="slide-content"><h3 id="text-manipulation-cat-con-cat-enate">Text manipulation : <code>cat</code> - con[cat]enate</h3>
<p>Cat, as you have already see, can be used to display the output of a file.</p>
<pre><code class="lang-bash">> cat quotes.txt
Work is the curse of the drinking classes
I love deadlines. I love the whooshing noise they make as they go by.
</code></pre>
<p>Multiple files can be passed to it to display several files one after another</p>
<pre><code class="lang-bash">cat grep-errors.txt quotes.txt
</code></pre>
</section>
</div>
<div class="slide hidden" id="slide-26">
<section class="slide-content"><h3 id="text-manipulation-head">Text manipulation : <code>head</code></h3>
<p>This is similar to cat in that it will display a file, however it will only display the first X lines. The default is 10, but can be changed with -X</p>
<pre><code class="lang-bash">> head -5 /etc/nsswitch.conf
<span class="hljs-comment">#</span>
<span class="hljs-comment"># /etc/nsswitch.conf</span>
<span class="hljs-comment">#</span>
<span class="hljs-comment"># An example Name Service Switch config file. This file should be</span>
<span class="hljs-comment"># sorted with the most-used services at the beginning.</span>
</code></pre>
<h3 id="text-manipulation-tail">Text manipulation : <code>tail</code></h3>
<p>Unsurprisingly tail does the opposite of head.</p>
</section>
</div>
<div class="slide hidden" id="slide-27">
<section class="slide-content"><h3 id="text-manipulation-less">Text manipulation : <code>less</code></h3>
<p>Less allows you to view the contents of a file and page through at will. Although this could be achieved with cat, less will allow you to scroll, search and page through the file. This could also be acheived with vim or another editor, though less will only load the part of the file you are currently viewing. This is useful if you are looking at a file that is very large as it takes a long time to load the whole thing into memory. </p>
<p>There are many commands beyond the standard invocation of it, if you want to view them all you can do <code>less --help</code>, otherwise the main useful ones are:</p>
<ul>
<li>Up arrow and down arrow - Scroll up and down a line</li>
<li>Page up and page down - Scroll up and down a full screen</li>
<li>/ and ? - Search forwards and backwards in the file</li>
<li>q - quit</li>
</ul>
</section>
</div>
<div class="slide hidden" id="slide-28">
<section class="slide-content"><h3 id="text-manipulation-cut">Text manipulation : <code>cut</code></h3>
<p>Cut allows you to extract portion of text from a file by selecting columns. There are a number of useful things you can do with it, though if you get too advanced you should probably be using awk instead. Here are two useful examples:</p>
<h4 id="select-column-of-characters-using-range">Select Column of Characters using Range</h4>
<pre><code class="lang-bash">> cut -c21-35 quotes.txt
the drinking c
love the whoosh
</code></pre>
<h4 id="select-multiple-fields-from-a-file">Select Multiple Fields from a File</h4>