-
Notifications
You must be signed in to change notification settings - Fork 154
/
Copy path0.5.html
1038 lines (522 loc) · 51.3 KB
/
0.5.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 lang="" >
<head>
<meta charset="UTF-8">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>More Exploration · GitBook</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="description" content="">
<meta name="generator" content="GitBook 3.2.3">
<link rel="stylesheet" href="gitbook/style.css">
<link rel="stylesheet" href="gitbook/gitbook-plugin-intopic-toc/style.css">
<link rel="stylesheet" href="gitbook/gitbook-plugin-page-footer-ex/style/plugin.css">
<link rel="stylesheet" href="gitbook/gitbook-plugin-callouts/plugin.css">
<link rel="stylesheet" href="gitbook/gitbook-plugin-highlight/website.css">
<link rel="stylesheet" href="gitbook/gitbook-plugin-search/search.css">
<link rel="stylesheet" href="gitbook/gitbook-plugin-fontsettings/website.css">
<link rel="stylesheet" href="gitbook/gitbook-plugin-theme-comscore/test.css">
<link rel="stylesheet" href="styles.css">
<meta name="HandheldFriendly" content="true"/>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png">
<link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon">
<link rel="next" href="0.6.html" />
<link rel="prev" href="0.4.html" />
</head>
<body>
<div class="book">
<div class="book-summary">
<div id="book-search-input" role="search">
<input type="text" placeholder="Type to search" />
</div>
<nav role="navigation">
<ul class="summary">
<li class="chapter " data-level="1.1" data-path="index.html">
<a href="index.html">
Introduction
</a>
</li>
<li class="chapter " data-level="1.2" data-path="PA0.html">
<a href="PA0.html">
PA0 - 世界诞生的前夜: 开发环境配置
</a>
<ul class="articles">
<li class="chapter " data-level="1.2.1" data-path="0.1.html">
<a href="0.1.html">
Installing GNU/Linux
</a>
</li>
<li class="chapter " data-level="1.2.2" data-path="0.2.html">
<a href="0.2.html">
First Exploration with GNU/Linux
</a>
</li>
<li class="chapter " data-level="1.2.3" data-path="0.3.html">
<a href="0.3.html">
Installing Tools
</a>
</li>
<li class="chapter " data-level="1.2.4" data-path="0.4.html">
<a href="0.4.html">
Configuring vim
</a>
</li>
<li class="chapter active" data-level="1.2.5" data-path="0.5.html">
<a href="0.5.html">
More Exploration
</a>
</li>
<li class="chapter " data-level="1.2.6" data-path="0.6.html">
<a href="0.6.html">
Getting Source Code for PAs
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="1.3" data-path="PA1.html">
<a href="PA1.html">
PA1 - 开天辟地的篇章: 最简单的计算机
</a>
<ul class="articles">
<li class="chapter " data-level="1.3.1" data-path="1.1.html">
<a href="1.1.html">
在开始愉快的PA之旅之前
</a>
</li>
<li class="chapter " data-level="1.3.2" data-path="1.2.html">
<a href="1.2.html">
开天辟地的篇章
</a>
</li>
<li class="chapter " data-level="1.3.3" data-path="1.3.html">
<a href="1.3.html">
RTFSC
</a>
</li>
<li class="chapter " data-level="1.3.4" data-path="1.4.html">
<a href="1.4.html">
基础设施
</a>
</li>
<li class="chapter " data-level="1.3.5" data-path="1.5.html">
<a href="1.5.html">
表达式求值
</a>
</li>
<li class="chapter " data-level="1.3.6" data-path="1.6.html">
<a href="1.6.html">
监视点
</a>
</li>
<li class="chapter " data-level="1.3.7" data-path="1.7.html">
<a href="1.7.html">
如何阅读手册
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="1.4" data-path="PA2.html">
<a href="PA2.html">
PA2 - 简单复杂的机器: 冯诺依曼计算机系统
</a>
<ul class="articles">
<li class="chapter " data-level="1.4.1" data-path="2.1.html">
<a href="2.1.html">
不停计算的机器
</a>
</li>
<li class="chapter " data-level="1.4.2" data-path="2.2.html">
<a href="2.2.html">
RTFSC(2)
</a>
</li>
<li class="chapter " data-level="1.4.3" data-path="2.3.html">
<a href="2.3.html">
程序, 运行时环境与AM
</a>
</li>
<li class="chapter " data-level="1.4.4" data-path="2.4.html">
<a href="2.4.html">
基础设施(2)
</a>
</li>
<li class="chapter " data-level="1.4.5" data-path="2.5.html">
<a href="2.5.html">
输入输出
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="1.5" data-path="PA3.html">
<a href="PA3.html">
PA3 - 穿越时空的旅程: 批处理系统
</a>
<ul class="articles">
<li class="chapter " data-level="1.5.1" data-path="3.1.html">
<a href="3.1.html">
最简单的操作系统
</a>
</li>
<li class="chapter " data-level="1.5.2" data-path="3.2.html">
<a href="3.2.html">
穿越时空的旅程
</a>
</li>
<li class="chapter " data-level="1.5.3" data-path="3.3.html">
<a href="3.3.html">
用户程序和系统调用
</a>
</li>
<li class="chapter " data-level="1.5.4" data-path="3.4.html">
<a href="3.4.html">
文件系统
</a>
</li>
<li class="chapter " data-level="1.5.5" data-path="3.5.html">
<a href="3.5.html">
精彩纷呈的应用程序
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="1.6" data-path="PA4.html">
<a href="PA4.html">
PA4 - 虚实交错的魔法: 分时多任务
</a>
<ul class="articles">
<li class="chapter " data-level="1.6.1" data-path="4.1.html">
<a href="4.1.html">
多道程序
</a>
</li>
<li class="chapter " data-level="1.6.2" data-path="4.2.html">
<a href="4.2.html">
虚实交错的魔法
</a>
</li>
<li class="chapter " data-level="1.6.3" data-path="4.3.html">
<a href="4.3.html">
超越容量的界限
</a>
</li>
<li class="chapter " data-level="1.6.4" data-path="4.4.html">
<a href="4.4.html">
来自外部的声音
</a>
</li>
<li class="chapter " data-level="1.6.5" data-path="4.5.html">
<a href="4.5.html">
编写不朽的传奇
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="1.7" data-path="blank.html">
<a href="blank.html">
杂项
</a>
<ul class="articles">
<li class="chapter " data-level="1.7.1" data-path="FAQ.html">
<a href="FAQ.html">
常见问题(FAQ)
</a>
</li>
<li class="chapter " data-level="1.7.2" data-path="why.html">
<a href="why.html">
为什么要学习计算机系统基础
</a>
</li>
<li class="chapter " data-level="1.7.3" data-path="linux.html">
<a href="linux.html">
Linux入门教程
</a>
</li>
<li class="chapter " data-level="1.7.4" data-path="man.html">
<a href="man.html">
man入门教程
</a>
</li>
<li class="chapter " data-level="1.7.5" data-path="git.html">
<a href="git.html">
git入门教程
</a>
</li>
<li class="chapter " data-level="1.7.6" data-path="nemu-isa-api.html">
<a href="nemu-isa-api.html">
NEMU ISA相关API说明文档
</a>
</li>
<li class="chapter " data-level="1.7.7" data-path="changelog.html">
<a href="changelog.html">
更新日志
</a>
</li>
<li class="chapter " data-level="1.7.8" data-path="i386-intro.html">
<a href="i386-intro.html">
i386手册指令集阅读指南
</a>
</li>
<li class="chapter " data-level="1.7.9" data-path="exec.html">
<a href="exec.html">
指令执行例子
</a>
</li>
</ul>
</li>
<li class="divider"></li>
<li>
<a href="https://www.gitbook.com" target="blank" class="gitbook-link">
Published with GitBook
</a>
</li>
</ul>
</nav>
</div>
<div class="book-body">
<div class="body-inner">
<div class="book-header" role="navigation">
<!-- Title -->
<h1>
<i class="fa fa-circle-o-notch fa-spin"></i>
<a href="." >More Exploration</a>
</h1>
</div>
<div class="page-wrapper" tabindex="-1" role="main">
<div class="page-inner">
<div id="book-search-results">
<div class="search-noresults">
<section class="normal markdown-section">
<h2 id="more-exploration">More Exploration</h2>
<h3 id="learning-to-use-basic-tools">Learning to use basic tools</h3>
<p>After installing tools for PAs, it is time to explore GNU/Linux again!
<a href="linux.html">Here</a> is a small tutorial for GNU/Linux written by jyy.
If you are new to GNU/Linux, read the tutorial carefully,
and most important, try every command mentioned in the tutorial.
<font color="red">Remember, you can not learn anything by only reading the tutorial.</font>
Besides, <a href="http://linux.vbird.org/linux_basic" target="_blank">鸟哥的Linux私房菜</a> is a book suitable for freshman in GNU/Linux.
Another book recommended by us is <a href="http://www.harley.com/books/sg3.html" target="_blank">Harley Hahn's Guide to Unix and Linux</a>.</p>
<div class="panel panel-danger"><div class="panel-heading"><h5 class="panel-title" id="rtfm"><i class="fa fa-bullhorn"></i> RTFM</h5></div><div class="panel-body"><p>The most important command in GNU/Linux is <code>man</code> - the on-line manual pager.
This is because <code>man</code> can tell you how to use other commands.
<a href="man.html">Here</a> is a small tutorial for <code>man</code>.
Remember, <font color="red">learn to use <code>man</code>, learn to use everything.</font>
Therefore, if you want to know something about GNU/Linux (such as shell commands,
system calls, library functions, device files, configuration files...), <a href="http://en.wikipedia.org/wiki/RTFM" target="_blank">RTFM</a>.</p></div></div>
<div class="panel panel-danger"><div class="panel-heading"><h5 class="panel-title" id="为什么要rtfm"><i class="fa fa-bullhorn"></i> 为什么要RTFM?</h5></div><div class="panel-body"><p>RTFM是STFW的长辈, 在互联网还不是很流行的年代, RTFM是解决问题的一种有效方法.
这是因为手册包含了查找对象的<font color="red">所有</font>信息,
关于查找对象的<font color="red">一切</font>问题都可以在手册中找到答案.</p><p>你或许会觉得翻阅手册太麻烦了, 所以可能会在百度上随便搜一篇博客来尝试寻找解决方案.
但是, 你需要明确以下几点:</p><ul>
<li>你搜到的博客可能也是转载别人的, 有可能有坑</li>
<li>博主只是分享了他的经历, 有些说法也不一定准确</li>
<li>搜到了相关内容, 也不一定会有全面的描述</li>
</ul><p>最重要的是, 当你尝试了上述方法而又无法解决问题的时候,
你需要明确"我刚才只是在尝试走捷径, 看来我需要试试RTFM了".</p></div></div>
<!-- -->
<div class="panel panel-warning"><div class="panel-heading"><h5 class="panel-title" id="write-a-hello-world-program-under-gnulinux"><i class="fa fa-edit"></i> Write a "Hello World" program under GNU/Linux</h5></div><div class="panel-body"><p>Write a "Hello World" program, compile it, then run it under GNU/Linux.
If you do not know what to do, refer to the GNU/Linux tutorial above.</p></div></div>
<!-- -->
<div class="panel panel-warning"><div class="panel-heading"><h5 class="panel-title" id="write-a-makefile-to-compile-the-hello-world-program"><i class="fa fa-edit"></i> Write a Makefile to compile the "Hello World" program</h5></div><div class="panel-body"><p>Write a Makefile to compile the "Hello World" program above.
If you do not know what to do, refer to the GNU/Linux tutorial above.</p></div></div>
<p>Now, stop here. <a href="https://linuxconfig.org/gdb-debugging-tutorial-for-beginners" target="_blank">Here</a> is a small tutorial for GDB.
GDB is the most common used debugger under GNU/Linux.
If you have not used a debugger yet (even in Visual Studio),
blame the 程序设计基础 course first, then blame yourself,
and finally, <font color="red">read the tutorial to learn to use GDB</font>.</p>
<div class="panel panel-warning"><div class="panel-heading"><h5 class="panel-title" id="learn-to-use-gdb"><i class="fa fa-edit"></i> Learn to use GDB</h5></div><div class="panel-body"><p>Read the GDB tutorial above and use GDB following the tutorial.
In PA1, you will be required to implement a simplified version of GDB.
If you have not used GDB, you may have no idea to finish PA1.</p></div></div>
<!-- -->
<div class="panel panel-danger"><div class="panel-heading"><h5 class="panel-title" id="嘿-别偷懒啊"><i class="fa fa-exclamation"></i> 嘿! 别偷懒啊!</h5></div><div class="panel-body"><p>上文让你写个"Hello World"程序, 然后写个Makefile来编译它,
并且看教程学习一下GDB的基本使用呢!</p></div></div>
<h3 id="installing-tmux">Installing tmux</h3>
<p><code>tmux</code> is a terminal multiplexer.
With it, you can create multiple terminals in a single screen.
It is very convenient when you are working with a high resolution monitor.
To install <code>tmux</code>, just issue the following command:</p>
<pre><code>apt-get install tmux
</code></pre><p>Now you can run <code>tmux</code>, but let's do some configuration first.
Go back to the home directory:</p>
<pre><code>cd ~
</code></pre><p>New a file called <code>.tmux.conf</code>:</p>
<pre><code>vim .tmux.conf
</code></pre><p>Append the following content to the file:</p>
<pre><code>bind-key c new-window -c "#{pane_current_path}"
bind-key % split-window -h -c "#{pane_current_path}"
bind-key '"' split-window -c "#{pane_current_path}"
</code></pre><p>These three lines of settings make <code>tmux</code> "remember" the current working directory
of the current pane while creating new window/pane.</p>
<p>Maximize the terminal windows size, then use <code>tmux</code>
to create multiple normal-size terminals within single screen.
For example, you may edit different files in different directories simultaneously.
You can edit them in different terminals, compile them or execute other commands in another terminal,
without opening and closing source files back and forth.
You can scroll the content in a <code>tmux</code> terminal up and down.
For how to use <code>tmux</code>, please STFW.</p>
<div class="panel panel-danger"><div class="panel-heading"><h5 class="panel-title" id="又要没完没了地stfw了"><i class="fa fa-bullhorn"></i> 又要没完没了地STFW了?</h5></div><div class="panel-body"><p>对.</p><p>PA除了让大家巩固ICS理论课的知识之外, 还承担着一个重要的任务:
把大家培养成一个素质合格的CSer.
事实上, 一个素质合格的CSer, 需要具备独立搜索解决方案的能力.
这是IT企业和科研机构对程序员的一个基本要求:
你将来的老板很可能会把一个任务直接丢给你,
如果你一遇到困难就找人帮忙, 老板就会认为你没法创造价值.</p><p>PA在尝试让你重视这些业界和学术界都看重的基本要求, 从而让你锻炼这些能力和心态:
遇到问题了, 第一反应不是赶紧找个大神帮忙搞定, 而是"我来试试STFW和RTFM, 看能不能自己解决".
所以PA不是按部就班的中学实验, <font color="red">不要抱怨讲义没写清楚导致你走了弯路</font>, 我们就是故意的:
我们会尽量控制路不会太弯, 只要你摆正心态, 你是有能力去独立解决这些问题的.
重要的是, 你得接受现实: 你走的弯路, 都在说明你的能力有待提升,
以后少走弯路的唯一方法, 就是你现在认真把路走下去.</p></div></div>
<!-- -->
<div class="panel panel-danger"><div class="panel-heading"><h5 class="panel-title" id="提问的智慧别像弱智一样提问"><i class="fa fa-bullhorn"></i> 提问的智慧/别像弱智一样提问</h5></div><div class="panel-body"><p>一个素质合格的CSer需要具备的另一个标准是, 懂得如何提问.</p><p>相信大家作为CSer, 被问如何修电脑的事情应该不会少.
比如你有一个文科小伙伴, 他QQ跟你说一句"我的电脑出问题了", 让你帮他修.
然后你得问东问西才了解具体的问题, 接着你让他尝试各种方案, 让他给你尝试的反馈.
如果你有10个这样的小伙伴, 相信你肯定受不了了.
这下你多少能体会到助教的心情了吧.</p><p>事实上, 如果希望能提高得到回答的概率, 提问者应该学会如何更好地提问.
换句话说, 提问者应该去积极思考
"<font color="blue">我可以主动做些什么来让对方更方便地帮助我诊断问题</font>".
文科小伙伴确实不是学习计算机专业的, 你可以选择原谅他;
但你是CSer, 至少你得在问题中描述具体的现象以及你做过的尝试,
而不是直接丢一句"我的程序挂了", 就等着别人来救场.
在你将来的职业生涯中也很有可能需要向别人求助, 比如在github等开源社区中发issue,
或者是在stackoverflow等论坛上发帖, 或者给技术工程师发邮件等,
<font color="red">如果你的提问方式非常不专业, 很可能没有人愿意关注你的问题,
因为这不仅让人觉得你随便提的问题没那么重要,
而且大家也不愿意花费大量的时间向你来回地咨询</font>.</p><p>一种推荐的提问方式如下:</p><pre><code>我在xxx的时候遇到了xxx的错误. 这个错误可以通过以下步骤重现: (描述具体的现象)
1. 我的系统版本是xxx, 相关的工具版本是xxx
2. 我做了xxx (必要的时候贴个图)
3. 然后xxx (必要的时候贴个图)
...
为了排查这个错误, 我进行了以下尝试: (说明我很希望可以解决问题, 真的没办法才提问的)
1. 我做了xxx, 出现了xxx的结果 (必要的时候贴个图)
2. 我还做了xxx, 出现了xxx的结果 (必要的时候贴个图)
...
最后问题还没有解决, 请问我还需要做哪些事情?
</code></pre><p>另外请大家务必阅读<a href="https://github.com/ryanhanwu/How-To-Ask-Questions-The-Smart-Way/blob/master/README-zh_CN.md" target="_blank">提问的智慧</a>和<a href="https://github.com/tangx/Stop-Ask-Questions-The-Stupid-Ways/blob/master/README.md" target="_blank">别像弱智一样提问</a>这两篇文章,
里面有不少例子供大家参考.</p></div></div>
<p>The following picture shows a scene working with multiple terminals within single screen.
Is it COOL?</p>
<p><img src="images/Tmux1.png" alt="tmux"></p>
<div class="panel panel-danger"><div class="panel-heading"><h5 class="panel-title" id="为什么要使用tmux"><i class="fa fa-bullhorn"></i> 为什么要使用tmux?</h5></div><div class="panel-body"><p>这其实是一个"使用正确的工具做事情"的例子.</p><p>计算机天生就是为用户服务的, 只要你有任何需求, 你都可以想, "有没有工具能帮我实现?".
我们希望每个终端做不同的事情, 能够在屏幕上一览无余的同时, 还能在终端之间快速切换.
事实上, 通过STFW和RTFM你就可以掌握如何使用一款正确的工具:
你只要在搜索引擎上搜索"Linux 终端 分屏", 就可以搜到<code>tmux</code>这个工具;
然后再搜索"tmux 使用教程", 就可以学习到<code>tmux</code>的基本使用方法;
在终端中输入<code>man tmux</code>, 就可以查阅关于<code>tmux</code>的任何疑问.</p><p>当然, 学习不是零成本的. 往届有学长提出一种零学习成本的分屏方式:
打开4个终端, 并将它们分别拖动到屏幕的4个角落,
发现用Alt+Tab快捷键不方便选择窗口(因为4个窗口的外貌都差不多), 就使用鼠标点击的方式来切换.
然后形容安装学习<code>tmux</code>是"脱裤子放屁 -- 多此一举".</p><p><code>tmux</code>的初衷就是为用户节省上述的操作成本.
如果你抱着不愿意付出任何学习成本的心态, 就无法享受到工具带来的便利.</p></div></div>
<!-- -->
<div class="panel panel-info"><div class="panel-heading"><h5 class="panel-title" id="things-behind-scrolling"><i class="fa fa-question-circle"></i> Things behind scrolling</h5></div><div class="panel-body"><p>You should have used scroll bars in GUI.
You may take this for granted.
So you may consider the original un-scrollable terminal (the one you use when you just log in) the hell.
But think of these: why the original terminal can not be scrolled?
How does <code>tmux</code> make the terminals scrollable?
And last, do you know how to implement a scroll bar?</p><p>GUI is not something mysterious.
Remember, behind every elements in GUI, there is a story about it.
Learn the story, and you will learn a lot.
You may say "I just use GUI, and it is unnecessary to learn the story."
Yes, you are right.
The appearance of GUI is to hide the story for users.
But almost everyone uses GUI in the world,
and that is why you can not tell the difference between you and them.</p></div></div>
<h3 id="why-gnulinux-and-how-to">Why GNU/Linux and How to</h3>
<div class="panel panel-danger"><div class="panel-heading"><h5 class="panel-title" id="为什么要使用linux"><i class="fa fa-bullhorn"></i> 为什么要使用Linux?</h5></div><div class="panel-body"><p>我们先来看两个例子.</p><p><strong>如何比较两个文件是否完全相同?</strong>
这个例子看上去非常简单, 在Linux下使用<code>diff</code>命令就可以实现.
如果文件很大, 那不妨用<code>md5sum</code>来计算并比较它们的MD5.
对一个Linux用户来说, 键入这些命令只需要花费大约3秒的时间.
但在Windows下, 这件事要做起来就不那么容易了.
也许你下载了一个MD5计算工具, 但你需要点击多少次鼠标才能完成比较呢?
也许你觉得一次好像也省不了多少时间,
然而真相是, <font color="red">你的开发效率就是这样一点点降低的</font>.</p><p><strong>如何列出一个C语言项目中所有被包含过的头文件?</strong>
这个例子比刚才的稍微复杂一些, 但在Windows下你几乎无法通过GUI工具高效地做到它.
在Linux中, 我们只需要通过一行命令就可以做到了:</p><pre><code>find . -name "*.[ch]" | xargs grep "#include" | sort | uniq
</code></pre><p>通过查阅<code>man</code>, 你应该不难理解上述命令是如何实现所需功能的.
这个例子再次体现了Unix哲学:</p><ul>
<li>每个工具只做一件事情, 但做到极致</li>
<li>工具采用文本方式进行输入输出, 从而易于使用</li>
<li>通过工具之间的组合来解决复杂问题</li>
</ul><p>Unix哲学的最后一点最能体现Linux和Windows的区别: <font color="blue">编程创造</font>.
如果把工具比作代码中的函数, 工具之间的组合就是一种编程.
而对初学者来说, Windows的GUI工具之间几乎无法组合, 因为面向普通用户的Windows需要强调易用性.</p><p>所以, 你应该使用Linux的原因非常简单: <font color="red">作为一个码农,
Windows一直在阻碍你思想, 能力和效率的提升.</font></p></div></div>
<!-- -->
<div class="panel panel-danger"><div class="panel-heading"><h5 class="panel-title" id="如何用好linux"><i class="fa fa-bullhorn"></i> 如何用好Linux?</h5></div><div class="panel-body"><ol>
<li><del>卸载Windows</del>, 解放思想, 摆脱Windows对你的阻碍.
与其默认"<font color="red">没办法, 也只能这样了</font>",
你应该去尝试"<font color="green">看看能不能把这件事做好</font>".<ul>
<li>Linux下也有相应的常用软件, 如Chrome, WPS, 中文输入法, mplayer...</li>
<li>没有Windows你也可以活下去</li>
<li>实在不行可以装个Windows虚拟机备用</li>
</ul>
</li>
<li>熟悉一些常用的命令行工具, 并强迫自己在日常操作中使用它们<ul>
<li>文件管理 - <code>cd</code>, <code>pwd</code>, <code>mkdir</code>, <code>rmdir</code>, <code>ls</code>, <code>cp</code>, <code>rm</code>, <code>mv</code>, <code>tar</code></li>
<li>文件检索 - <code>cat</code>, <code>more</code>, <code>less</code>, <code>head</code>, <code>tail</code>, <code>file</code>, <code>find</code></li>
<li>输入输出控制 - 重定向, 管道, <code>tee</code>, <code>xargs</code></li>
<li>文本处理 - <code>vim</code>, <code>grep</code>, <code>awk</code>, <code>sed</code>, <code>sort</code>, <code>wc</code>, <code>uniq</code>, <code>cut</code>, <code>tr</code></li>
<li>正则表达式</li>
<li>系统监控 - <code>jobs</code>, <code>ps</code>, <code>top</code>, <code>kill</code>, <code>free</code>, <code>dmesg</code>, <code>lsof</code></li>
<li>上述工具覆盖了程序员绝大部分的需求<ul>
<li>可以先从简单的尝试开始, 用得多就记住了, 记不住就<code>man</code></li>
</ul>
</li>
</ul>
</li>
<li>RTFM + STFW</li>
<li>坚持.<ul>
<li>心态上, 相信<font color="blue">总有对的工具能帮助我做得更好</font></li>
<li>行动上, 愿意付出时间去<font color="blue">找到它, 学它, 用它</font></li>
</ul>
</li>
</ol></div></div>
<!-- -->
<div class="panel panel-danger"><div class="panel-heading"><h5 class="panel-title" id="墙裂推荐-the-missing-semester-of-your-cs-education"><i class="fa fa-bullhorn"></i> 墙裂推荐: The Missing Semester of Your CS Education</h5></div><div class="panel-body"><p><a href="https://missing.csail.mit.edu/" target="_blank">The Missing Semester of Your CS Education</a>是jyy墙裂推荐的Linux工具系列教程,
教你如何使用各种工具来帮助你在计算机上高效地完成各种任务, 让你终身收益.</p><p>这套教程有中文版, 去看看吧.</p></div></div>
<div class="panel panel-success"><div class="panel-heading"><h5 class="panel-title" id="克服恐惧-累积最初的信心"><i class="fa fa-lightbulb-o"></i> 克服恐惧, 累积最初的信心</h5></div><div class="panel-body"><p>事实上, 学习使用Linux是一个低成本, 高成功率的锻炼机会.
只要你愿意STFW和RTFM, 就能解决绝大部分的问题.
相比较而言, 你之后(后续PA中/后续课程中/工作中)遇到的问题只会更加困难.
因此, 独立解决这些简单的小问题, 你就会开始积累最初的信心,
从而也慢慢相信自己有能力解决更难的问题.</p></div></div>
<footer class="page-footer-ex"> <span class="page-footer-ex-copyright"> By <a href="https://sashimi-yzh.github.io/" target="_blank">Zihao Yu</a>, 采用<a href="http://creativecommons.org/licenses/by-nc-sa/3.0/cn/" target="_blank">知识共享 署名-非商业性使用-相同方式共享 3.0 中国大陆 许可协议</a>发布 </span>            <span class="page-footer-ex-footer-update"> 此页面修订于: 2024-08-20 09:06:20 </span> </footer>
</section>
</div>
<div class="search-results">
<div class="has-results">
<h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
<ul class="search-results-list"></ul>
</div>
<div class="no-results">
<h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
</div>
</div>
</div>
</div>
</div>
</div>
<a href="0.4.html" class="navigation navigation-prev " aria-label="Previous page: Configuring vim">
<i class="fa fa-angle-left"></i>
</a>
<a href="0.6.html" class="navigation navigation-next " aria-label="Next page: Getting Source Code for PAs">
<i class="fa fa-angle-right"></i>
</a>
</div>
<script>
var gitbook = gitbook || [];
gitbook.push(function() {
gitbook.page.hasChanged({"page":{"title":"More Exploration","level":"1.2.5","depth":2,"next":{"title":"Getting Source Code for PAs","level":"1.2.6","depth":2,"path":"0.6.md","ref":"0.6.md","articles":[]},"previous":{"title":"Configuring vim","level":"1.2.4","depth":2,"path":"0.4.md","ref":"0.4.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"3.x.x","theme":"default","variables":{},"plugins":["theme-comscore","intopic-toc","localized-footer","page-footer-ex","callouts"],"pluginsConfig":{"callouts":{"option":{"alert":"info","picto":"fa-edit"},"flag":{"alert":"success","picto":"fa-flag"},"question":{"alert":"info","picto":"fa-question-circle"},"info":{"alert":"info","picto":"fa-info-circle"},"todo":{"alert":"warning","picto":"fa-edit"},"caution":{"alert":"danger","picto":"fa-bullhorn"},"danger":{"alert":"danger","picto":"fa-exclamation"},"showTypeInHeader":false},"intopic-toc":{"isCollapsed":false,"isScrollspyActive":true,"label":"导航","maxDepth":6,"mode":"nested","selector":".markdown-section h2, .markdown-section h3, .markdown-section h4","visible":true},"page-footer-ex":{"copyright":"By [Zihao Yu](https://sashimi-yzh.github.io/), 采用[知识共享 署名-非商业性使用-相同方式共享 3.0 中国大陆 许可协议](http://creativecommons.org/licenses/by-nc-sa/3.0/cn/)发布","markdown":true,"update_format":"YYYY-MM-DD HH:mm:ss","update_label":"此页面修订于: "},"search":{},"localized-footer":{"filename":"FOOTER.md","hline":"true"},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"theme":"white","family":"sans","size":2},"highlight":{},"theme-comscore":{},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles.css","pdf":"styles.css"}},"file":{"path":"0.5.md","mtime":"2024-08-20T01:06:20.380Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2025-01-03T02:26:44.310Z"},"basePath":".","book":{"language":""}});
});
</script>
</div>
<script src="gitbook/gitbook.js"></script>
<script src="gitbook/theme.js"></script>
<script src="gitbook/gitbook-plugin-intopic-toc/anchor.min.js"></script>
<script src="gitbook/gitbook-plugin-intopic-toc/gumshoe.polyfills.min.js"></script>