-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
2113 lines (1376 loc) · 159 KB
/
index.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 class="theme-next pisces use-motion">
<head>
<meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link href="/vendors/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />
<link href="fonts.useso.com/css?family=Microsoft YaHei:300,300italic,400,400italic,700,700italic|Roboto Slab:300,300italic,400,400italic,700,700italic|Microsoft YaHei:300,300italic,400,400italic,700,700italic|PT Mono:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
<link href="/vendors/font-awesome/css/font-awesome.min.css?v=4.4.0" rel="stylesheet" type="text/css" />
<link href="/css/main.css?v=5.0.1" rel="stylesheet" type="text/css" />
<meta name="keywords" content="rwboy" />
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.0.1" />
<meta name="description" content="running in the wind">
<meta property="og:type" content="website">
<meta property="og:title" content="Rwboy's Blog">
<meta property="og:url" content="http://blog.rwboy.cn/index.html">
<meta property="og:site_name" content="Rwboy's Blog">
<meta property="og:description" content="running in the wind">
<meta property="og:locale" content="zh-Hans">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Rwboy's Blog">
<meta name="twitter:description" content="running in the wind">
<script type="text/javascript" id="hexo.configuration">
var NexT = window.NexT || {};
var CONFIG = {
scheme: 'Pisces',
sidebar: {"position":"left","display":"post"},
fancybox: true,
motion: true,
duoshuo: {
userId: 0,
author: '博主'
}
};
</script>
<link rel="canonical" href="http://blog.rwboy.cn/"/>
<title> Rwboy's Blog </title>
</head>
<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">
<script type="text/javascript">
(function() {
var hm = document.createElement("script");
hm.src = "//tajs.qq.com/stats?sId=58728827";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
</script>
<div class="container one-collumn sidebar-position-left
page-home
">
<div class="headband"></div>
<header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
<div class="header-inner"><div class="site-meta ">
<div class="custom-logo-site-title">
<a href="/" class="brand" rel="start">
<span class="logo-line-before"><i></i></span>
<span class="site-title">Rwboy's Blog</span>
<span class="logo-line-after"><i></i></span>
</a>
</div>
<p class="site-subtitle">Never stop learning</p>
</div>
<div class="site-nav-toggle">
<button>
<span class="btn-bar"></span>
<span class="btn-bar"></span>
<span class="btn-bar"></span>
</button>
</div>
<nav class="site-nav">
<ul id="menu" class="menu">
<li class="menu-item menu-item-home">
<a href="/" rel="section">
<i class="menu-item-icon fa fa-fw fa-home"></i> <br />
首页
</a>
</li>
<li class="menu-item menu-item-categories">
<a href="/categories" rel="section">
<i class="menu-item-icon fa fa-fw fa-th"></i> <br />
分类
</a>
</li>
<li class="menu-item menu-item-about">
<a href="/about" rel="section">
<i class="menu-item-icon fa fa-fw fa-user"></i> <br />
关于
</a>
</li>
<li class="menu-item menu-item-archives">
<a href="/archives" rel="section">
<i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
归档
</a>
</li>
<li class="menu-item menu-item-tags">
<a href="/tags" rel="section">
<i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
标签
</a>
</li>
<li class="menu-item menu-item-search">
<a href="javascript:;" class="popup-trigger">
<i class="menu-item-icon fa fa-search fa-fw"></i> <br />
搜索
</a>
</li>
</ul>
<div class="site-search">
<div class="popup">
<span class="search-icon fa fa-search"></span>
<input type="text" id="local-search-input">
<div id="local-search-result"></div>
<span class="popup-btn-close">close</span>
</div>
</div>
</nav>
</div>
</header>
<main id="main" class="main">
<div class="main-inner">
<div class="content-wrap">
<div id="content" class="content">
<section id="posts" class="posts-expand">
<article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a class="post-title-link" href="/zh-Hans/2018-06-08-Intellij-IDEA常用快捷键.html" itemprop="url">
Intellij IDEA常用快捷键
</a>
</h1>
<div class="post-meta">
<span class="post-time">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time itemprop="dateCreated" datetime="2018-06-08T09:07:41+08:00" content="2018-06-08">
2018-06-08
</time>
</span>
<span class="post-category" >
|
<span class="post-meta-item-icon">
<i class="fa fa-folder-o"></i>
</span>
<span class="post-meta-item-text">分类于</span>
<span itemprop="about" itemscope itemtype="https://schema.org/Thing">
<a href="/categories/速查手册/" itemprop="url" rel="index">
<span itemprop="name">速查手册</span>
</a>
</span>
</span>
<span id="/zh-Hans/2018-06-08-Intellij-IDEA常用快捷键.html" class="leancloud_visitors" data-flag-title="Intellij IDEA常用快捷键">
|
<span class="post-meta-item-icon">
<i class="fa fa-eye"></i>
</span>
<span class="post-meta-item-text">阅读次数 </span>
<span class="leancloud-visitors-count"></span>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h1 id="综述"><a href="#综述" class="headerlink" title="综述"></a>综述</h1><p>Alt+回车 导入包,自动修正</p>
<p>Ctrl+N 查找类</p>
<p>Ctrl+Shift+N 查找文件</p>
<p>Ctrl+Alt+L 格式化代码</p>
<p>Ctrl+Alt+O 优化导入的类和包</p>
<p>Alt+Insert 生成代码(如get,set方法,构造函数等)</p>
<p>Ctrl+E或者Alt+Shift+C 最近更改的代码</p>
<p>Ctrl+R 替换文本</p>
<p>Ctrl+F 查找文本</p>
<p>Ctrl+Shift+Space 自动补全代码</p>
<p>Ctrl+空格 代码提示</p>
<p>Ctrl+Alt+Space 类名或接口名提示</p>
<p>Ctrl+P 方法参数提示</p>
<p>Ctrl+Shift+Alt+N 查找类中的方法或变量</p>
<p>Alt+Shift+C 对比最近修改的代码</p>
<p>Shift+F6 重构-重命名</p>
<p>Ctrl+Shift+先上键</p>
<p>Ctrl+X 删除行</p>
<p>Ctrl+D 复制行</p>
<p>Ctrl+/ 或 Ctrl+Shift+/ 注释(// 或者/<em>…</em>/ )</p>
<p>Ctrl+J 自动代码</p>
<p>Ctrl+E 最近打开的文件</p>
<p>Ctrl+H 显示类结构图</p>
<p>Ctrl+Q 显示注释文档</p>
<p>Alt+F1 查找代码所在位置</p>
<p>Alt+1 快速打开或隐藏工程面板</p>
<p>Ctrl+Alt+ left/right 返回至上次浏览的位置</p>
<p>Alt+ left/right 切换代码视图</p>
<p>Alt+ Up/Down 在方法间快速移动定位</p>
<p>Ctrl+Shift+Up/Down 代码向上/下移动。</p>
<p>F2 或Shift+F2 高亮错误或警告快速定位</p>
<p>代码标签输入完成后,按Tab,生成代码。</p>
<p>选中文本,按Ctrl+Shift+F7 ,高亮显示所有该文本,按Esc高亮消失。</p>
<p>Ctrl+W 选中代码,连续按会有其他效果</p>
<p>选中文本,按Alt+F3 ,逐个往下查找相同文本,并高亮显示。</p>
<p>Ctrl+Up/Down 光标跳转到第一行或最后一行下</p>
<p>Ctrl+B 快速打开光标处的类或方法 </p>
<hr>
<h1 id="Intellij-IDEA最常用快捷键"><a href="#Intellij-IDEA最常用快捷键" class="headerlink" title="Intellij IDEA最常用快捷键"></a>Intellij IDEA最常用快捷键</h1><p>1.Ctrl+E,可以显示最近编辑的文件列表</p>
<p>2.Shift+Click可以关闭文件</p>
<p>3.Ctrl+[或]可以跳到大括号的开头结尾</p>
<p>4.Ctrl+Shift+Backspace可以跳转到上次编辑的地方</p>
<p>5.Ctrl+F12,可以显示当前文件的结构</p>
<p>6.Ctrl+F7可以查询当前元素在当前文件中的引用,然后按F3可以选择</p>
<p>7.Ctrl+N,可以快速打开类</p>
<p>8.Ctrl+Shift+N,可以快速打开文件</p>
<p>9.Alt+Q可以看到当前方法的声明</p>
<p>10.Ctrl+W可以选择单词继而语句继而行继而函数</p>
<p>11.Alt+F1可以将正在编辑的元素在各个面板中定位</p>
<p>12.Ctrl+P,可以显示参数信息</p>
<p>13.Ctrl+Shift+Insert可以选择剪贴板内容并插入</p>
<p>14.Alt+Insert可以生成构造器/Getter/Setter等</p>
<p>15.Ctrl+Alt+V 可以引入变量。例如把括号内的SQL赋成一个变量</p>
<p>16.Ctrl+Alt+T可以把代码包在一块内,例如try/catch</p>
<p>17.Alt+Up and Alt+Down可在方法间快速移动</p>
<hr>
<h1 id="IDEA内存优化"><a href="#IDEA内存优化" class="headerlink" title="IDEA内存优化"></a>IDEA内存优化</h1><p>因机器本身的配置而配置:</p>
<p>\IntelliJ IDEA 8\bin\idea.exe.vmoptions </p>
<p>-Xms64m<br>-Xmx256m<br>-XX:MaxPermSize=92m<br>-ea<br>-server<br>-Dsun.awt.keepWorkingSetOnMinimize=true</p>
<hr>
<h1 id="查询快捷键"><a href="#查询快捷键" class="headerlink" title="查询快捷键"></a>查询快捷键</h1><p>CTRL+N 查找类<br>CTRL+SHIFT+N 查找文件<br>CTRL+SHIFT+ALT+N 查找类中的方法或变量<br>CIRL+B 找变量的来源<br>CTRL+ALT+B 找所有的子类<br>CTRL+SHIFT+B 找变量的类<br>CTRL+G 定位行<br>CTRL+F 在当前窗口查找文本<br>CTRL+SHIFT+F 在指定窗口查找文本<br>CTRL+R 在 当前窗口替换文本<br>CTRL+SHIFT+R 在指定窗口替换文本<br>ALT+SHIFT+C 查找修改的文件<br>CTRL+E 最近打开的文件<br>F3 向下查找关键字出现位置<br>SHIFT+F3 向上一个关键字出现位置<br>F4 查找变量来源<br>CTRL+ALT+F7 选中的字符查找工程出现的地方<br>CTRL+SHIFT+O 弹出显示查找内容</p>
<hr>
<h1 id="自动代码"><a href="#自动代码" class="headerlink" title="自动代码"></a>自动代码</h1><p>ALT+回车 导入包,自动修正<br>CTRL+ALT+L 格式化代码<br>CTRL+ALT+I 自动缩进<br>CTRL+ALT+O 优化导入的类和包<br>ALT+INSERT 生成代码(如GET,SET方法,构造函数等)<br>CTRL+E 最近更改的代码<br>CTRL+SHIFT+SPACE 自动补全代码<br>CTRL+空格 代码提示<br>CTRL+ALT+SPACE 类名或接口名提示<br>CTRL+P 方法参数提示<br>CTRL+J 自动代码<br>CTRL+ALT+T 把选中的代码放在 TRY{} IF{} ELSE{} 里</p>
<hr>
<h1 id="复制快捷方式"><a href="#复制快捷方式" class="headerlink" title="复制快捷方式"></a>复制快捷方式</h1><p>CTRL+D 复制行<br>CTRL+X 剪切,删除行 </p>
<hr>
<h1 id="其他快捷方式"><a href="#其他快捷方式" class="headerlink" title="其他快捷方式"></a>其他快捷方式</h1><p>CIRL+U 大小写切换<br>CTRL+Z 倒退<br>CTRL+SHIFT+Z 向前<br>CTRL+ALT+F12 资源管理器打开文件夹<br>ALT+F1 查找文件所在目录位置<br>SHIFT+ALT+INSERT 竖编辑模式<br>CTRL+/ 注释//<br>CTRL+SHIFT+/ 注释/<em>…</em>/<br>CTRL+W 选中代码,连续按会有其他效果<br>CTRL+B 快速打开光标处的类或方法<br>ALT+ ←/→ 切换代码视图<br>CTRL+ALT ←/→ 返回上次编辑的位置<br>ALT+ ↑/↓ 在方法间快速移动定位<br>SHIFT+F6 重构-重命名<br>CTRL+H 显示类结构图<br>CTRL+Q 显示注释文档<br>ALT+1 快速打开或隐藏工程面板<br>CTRL+SHIFT+UP/DOWN 代码向上/下移动。<br>CTRL+UP/DOWN 光标跳转到第一行或最后一行下<br>ESC 光标返回编辑框<br>SHIFT+ESC 光标返回编辑框,关闭无用的窗口<br>F1 帮助千万别按,很卡!<br>CTRL+F4 非常重要下班都用</p>
<hr>
<h1 id="下面的不是很有用"><a href="#下面的不是很有用" class="headerlink" title="下面的不是很有用"></a>下面的不是很有用</h1><p>18.在一些地方按Alt+Enter可以得到一些Intention Action,例如将”==”改为”equals()”</p>
<p>19.Ctrl+Shift+Alt+N可以快速打开符号</p>
<p>20.Ctrl+Shift+Space在很多时候都能够给出Smart提示</p>
<p>21.Alt+F3可以快速寻找</p>
<p>22.Ctrl+/和Ctrl+Shift+/可以注释代码</p>
<p>23.Ctrl+Alt+B可以跳转到抽象方法的实现</p>
<p>24.Ctrl+O可以选择父类的方法进行重写</p>
<p>25.Ctrl+Q可以看JavaDoc</p>
<p>26.Ctrl+Alt+Space是类名自动完成</p>
<p>27.快速打开类/文件/符号时,可以使用通配符,也可以使用缩写</p>
<p>28.Live Templates! Ctrl+J</p>
<p>29.Ctrl+Shift+F7可以高亮当前元素在当前文件中的使用</p>
<p>30.Ctrl+Alt+Up /Ctrl+Alt+Down可以快速跳转搜索结果</p>
<p>31.Ctrl+Shift+J可以整合两行</p>
<p>32.Alt+F8是计算变量值</p>
<hr>
<h1 id="IntelliJ-IDEA使用技巧一览表"><a href="#IntelliJ-IDEA使用技巧一览表" class="headerlink" title="IntelliJ IDEA使用技巧一览表"></a>IntelliJ IDEA使用技巧一览表</h1><p>在使用 InelliJ IDEA 的过程中,通过查找资料以及一些自己的摸索,发现这个众多 Java 程序员喜欢的 IDE 里有许多值得一提的小窍门,如果能熟练的将它们应用于实际开发过程中,相信它会大大节省你的开发时间,而且随之而来的还会有那么一点点成就感:) Try it !</p>
<p>1 、写代码时用 Alt-Insert ( Code|Generate… )可以创建类里面任何字段的 getter 与 setter 方法。<br><figure class="highlight routeros"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><?xml:namespace<span class="built_in"> prefix </span>= v ns = <span class="string">"urn:schemas-microsoft-com:vml"</span> /></span><br></pre></td></tr></table></figure></p>
<p>2 、右键点击断点标记(在文本的左边栏里)激活速查菜单,你可以快速设置 enable/disable 断点或者条件它的属性。</p>
<p>3 、 CodeCompletion (代码完成)属性里的一个特殊的变量是,激活 Ctrl-Alt-Space 可以完成在或不在当前文件里的类名。如果类没有引入则 import 标志会自动创建。</p>
<p>4 、使用 Ctrl-Shift-V 快捷键可以将最近使用的剪贴板内容选择插入到文本。使用时系统会弹出一个含有剪贴内容的对话框,从中你可以选择你要粘贴的部分。 </p>
<p>5 、利用 CodeCompletion (代码完成)属性可以快速地在代码中完成各种不同地语句,方法是先键入一个类名地前几个字母然后再用 Ctrl-Space 完成全称。如果有多个选项,它们会列在速查列表里。 </p>
<p>6 、用 Ctrl-/ 与 Ctrl-Shift-/ 来注释 / 反注释代码行与代码块。</p>
<p>-/ 用单行注释标记(“ //… ”)来注释 / 反注释当前行或者选择地代码块。而 Ctrl-Shift-/ 则可以用块注释标记(“ /<em>…</em>/ ”)把所选块包围起来。要反注释一个代码块就在块中任何一个地方按 Ctrl-Shift-/ 即可。</p>
<p>7 、按 Alt-Q ( View|Context Info )可以不需要移动代码就能查看当前方法地声明。连续按两次会显示当前所编辑的类名。 </p>
<p>8 、使用 Refactor|Copy Class… 可以创建一个所选择的类的“副本”。这一点很有用,比如,在你想要创建一个大部分内容都和已存在类相同的类时。 </p>
<p>9 、在编辑器里 Ctrl-D 可以复制选择的块或者没有所选块是的当前行。</p>
<p>10 、 Ctrl-W (选择字)在编辑器里的功能是先选择脱字符处的单词,然后选择源代码的扩展区域。举例来说,先选择一个方法名,然后是调用这个方法的表达式,然后是整个语句,然后包容块,等等。</p>
<p>11 、如果你不想让指示事件细节的“亮球”图标在编辑器上显示,通过按 Alt-Enter 组合键打开所有事件列表然后用鼠标点击它就可以把这个事件文本附件的亮球置成非活动状态。 </p>
<p>这样以后就不会有指示特殊事件的亮球出现了,但是你仍然可以用 Alt-Enter 快捷键使用它。</p>
<p>12 、在使用 CodeCompletion 时,可以用逗点( . )字符,逗号(,)分号(;),空格和其它字符输入弹出列表里的当前高亮部分。选择的名字会随着输入的字符自动输入到编辑器里。 </p>
<p>13 、在任何工具窗口里使用 Escape 键都可以把焦点移到编辑器上。 </p>
<p>Shift-Escape 不仅可以把焦点移到编辑器上而且还可以隐藏当前(或最后活动的)工具窗口。 </p>
<p>F12 键把焦点从编辑器移到最近使用的工具窗口。 </p>
<p>14 、在调试程序时查看任何表达式值的一个容易的方法就是在编辑器中选择文本(可以按几次 Ctrl-W 组合键更有效地执行这个操作)然后按 Alt-F8 。 </p>
<p>15 、要打开编辑器脱字符处使用的类或者方法 Java 文档的浏览器,就按 Shift-F1 (右键菜单的 External JavaDoc )。 </p>
<p>要使用这个功能须要把加入浏览器的路径,在“ General ”选项中设置( Options | IDE Settings ),另外还要把创建的 Java 文档加入到工程中( File | Project Properties )。 </p>
<p>16 、用 Ctrl-F12 ( View | File Structure Popup )键你可以在当前编辑的文件中快速导航。 </p>
<p>这时它会显示当前类的成员列表。选中一个要导航的元素然后按 Enter 键或 F4 键。要轻松地定位到列表中的一个条目,只需键入它的名字即可。 </p>
<p>17 、在代码中把光标置于标记符或者它的检查点上再按 Alt-F7 (右键菜单中的 Find Usages… )会很快地查找到在整个工程中使用地某一个类、方法或者变量的位置。</p>
<p>18 、按 Ctrl-N ( Go to | Class… )再键入类的名字可以快速地在编辑器里打开任何一个类。从显示出来的下拉列表里选择类。 </p>
<p>同样的方法你可以通过使用 Ctrl-Shift-N ( Go to | File… )打开工程中的非 Java 文件。</p>
<p>19 、要导航代码中一些地方使用到的类、方法或者变量的声明,把光标放在查看项上再按 Ctrl-B 即可。也可以通过按 Ctrl 键的同时在查看点上单击鼠标键调转到声明处。 </p>
<p>20 、把光标放到查看点上再按 Ctrl-Alt-B 可以导航到一个抽象方法的实现代码。</p>
<p>21 、要看一个所选择的类的继承层次,按 Ctrl-H ( Browse Type Hierarchy )即可。也可以激活编辑器中的继承关系视图查看当前编辑类的继承关系。22 、使用 Ctrl-Shift-F7 ( Search | Highlight Usages in File )可以快速高亮显示当前文件中某一变量的使用地方。按 Escape 清除高亮显示。 </p>
<p>23 、用 Alt-F3 ( Search | Incremental Search )在编辑器中实现快速查查找功能。 </p>
<p>在“ Search for: ”提示工具里输入字符,使用箭头键朝前和朝后搜索。按 Escape 退出。</p>
<p>24 、按 Ctrl-J 组合键来执行一些你记不起来的 Live Template 缩写。比如,键“ it ”然后按 Ctrl-J 看看有什么发生。</p>
<p>25 、 Introduce Variable 整合帮助你简化代码中复杂的声明。举个例子,在下面的代码片断里,在代码中选择一个表达式:然后按 Ctrl-Alt-V 。</p>
<p>26 、 Ctrl-Shift-J 快捷键把两行合成一行并把不必要的空格去掉以匹配你的代码格式。</p>
<p>27 、 Ctrl-Shift-Backspace ( Go to | Last Edit Location )让你调转到代码中所做改变的最后一个地方。 </p>
<p>多按几次 Ctrl-Shift-Backspace 查看更深的修改历史。 </p>
<p>28 、用 Tools | Reformat Code… 根据你的代码样式参考(查看 Options | IDE Setting | Code Style )格式化代码。</p>
<p>使用 Tools | Optimize Imports… 可以根据设置(查看 Options | IDE Setting | Code Style | Imports )自动“优化” imports (清除无用的 imports 等)。</p>
<p>29 、使用 IDEA 的 Live Templates | Live Templates 让你在眨眼间创建许多典型代码。比如,在一个方法里键入 </p>
<p>再按 Tab 键看有什么事情发生了。 </p>
<p>用 Tab 键在不同的模板域内移动。查看 Options | Live Templates 获取更多的细节。</p>
<p>30 、要查看一个文件中修改的本地历史,激活右键菜单里的 Local VCS | Show History… 。也许你可以导航不同的文件版本,看看它们的不同之处再回滚到以前的任何一个版本吧。 </p>
<p>使用同样的右键菜单条目还可以看到一个目录里修改的历史。有了这个特性你就不会丢失任何代码了。</p>
<p>31 、如果要了解主菜单里每一个条目的用途,把鼠标指针移到菜单条目上再应用程序框架的底部的状态栏里就会显示它们的一些简短描述,也许会对你有帮助。 </p>
<p>32 、要在编辑器里显示方法间的分隔线,打开 Options | IDE Settings | Editor ,选中“ Show method separators ”检查盒( checkbox )。 </p>
<p>33 、用 Alt-Up 和 Alt-Down 键可以在编辑器里不同的方法之间快速移动。 </p>
<p>34 、用 F2/Shift-F2 键在高亮显示的语法错误间跳转。 </p>
<p>用 Ctrl-Alt-Down/Ctrl-Alt-Up 快捷键则可以在编译器错误信息或者查找操作结果间跳转。</p>
<p>35 、通过按 Ctrl-O ( Code | Override Methods… )可以很容易地重载基本类地方法。 </p>
<p>要完成当前类 implements 的(或者抽象基本类的)接口的方法,就使用 Ctrl-I ( Code | Implement Methods… )。 </p>
<p>36 、如果光标置于一个方法调用的括号间,按 Ctrl-P 会显示一个可用参数的列表。</p>
<p>37 、要快速查看编辑器脱字符处使用的类或方法的 Java 文档,按 Ctrl-Q (在弹出菜单的 Show Quick JavaDoc 里)即可。 </p>
<p>38 、像 Ctrl-Q ( Show Quick JavaDoc 显示简洁 Java 文档), Ctrl-P ( Show Parameter Info 显示参数信息), Ctrl-B ( Go to Declaration 跳转到声明), Shift-F1 ( External JavaDoc 外部 Java 文档)以及其它一些快捷键不仅可以在编辑器里使用,也可以应用在代码完成右键列表里。 </p>
<p>39 、 Ctrl-E ( View | Recent Files )弹出最近访问的文件右键列表。选中文件按 Enter 键打开。 </p>
<p>40 、在 IDEA 中可以很容易地对你的类,方法以及变量进行重命名并在所有使用到它们的地方自动更正。 </p>
<p>试一下,把编辑器脱字符置于任何一个变量名字上然后按 Shift-F6 ( Refactor | Rename… )。在对话框里键入要显示地新名字再按 Enter 。你会浏览到使用这个变量地所有地方然后按“ Do Refactor ”按钮结束重命名操作。</p>
<p>41 、要在任何视图( Project View 工程视图, Structure View 结构视图或者其它视图)里快速 </p>
<p>选择当前编辑地部分(类,文件,方法或者字段),按 Alt-F1 ( View | Select in… )。 </p>
<p>42 、在“ new ”字符后实例化一个已知类型对象时也许你会用到 SmartType 代码完成这个特性。比如,键入 </p>
<p>再按 Ctrl-Shift-Space :</p>
<p>43 、通过使用 SmartType 代码完成,在 IDEA 中创建接口的整个匿名 implementation 也是非常容易的,比如,对于一些 listener (监听器),可以键入 </p>
<p>Component component; </p>
<p>component.addMouseListener( </p>
<p> new <caret is="" here=""> </caret></p>
<p>); </p>
<p>然后再按 Ctrl-Shift-Space 看看有什么发生了。 </p>
<p>44 、在你需要设置一个已知类型的表达式的值时用 SmartType 代码完成也很有帮助。比如,键入 </p>
<p>String s = ( <caret is="" here=""> </caret></p>
<p>再按 Ctrl-Shift-Space 看看会有什么出现。 </p>
<p>45 、在所有视图里都提供了速查功能:在树里只需键入字符就可以快速定位到一个条目。 </p>
<p>46 、当你想用代码片断捕捉异常时,在编辑器里选中这个片断,按 Ctrl-Alt-T ( Code | Surround with… )然后选择“ try/catch ”。它会自动产生代码片断中抛出的所有异常的捕捉块。在 Options | File Templates | Code tab 中你还可以自己定制产生捕捉块的模板。 </p>
<p>用列表中的其它项可以包围别的一些结构。 </p>
<p>47 、在使用代码完成时,用 Tab 键可以输入弹出列表里的高亮显示部分。 </p>
<p>不像用 Enter 键接受输入,这个选中的名字会覆盖掉脱字符右边名字的其它部分。这一点在用一个方法或者变量名替换另一个时特别有用。 </p>
<p>48 、在声明一个变量时代码完成特性会给你显示一个建议名。比如,开始键入“ private FileOutputStream ”然后按 Ctrl-Space </p>
</div>
<div>
</div>
<div>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a class="post-title-link" href="/zh-Hans/2018-06-08-eclipse-常用快捷键.html" itemprop="url">
Eclipse 常用快捷键
</a>
</h1>
<div class="post-meta">
<span class="post-time">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time itemprop="dateCreated" datetime="2018-06-08T09:02:15+08:00" content="2018-06-08">
2018-06-08
</time>
</span>
<span class="post-category" >
|
<span class="post-meta-item-icon">
<i class="fa fa-folder-o"></i>
</span>
<span class="post-meta-item-text">分类于</span>
<span itemprop="about" itemscope itemtype="https://schema.org/Thing">
<a href="/categories/速查手册/" itemprop="url" rel="index">
<span itemprop="name">速查手册</span>
</a>
</span>
</span>
<span id="/zh-Hans/2018-06-08-eclipse-常用快捷键.html" class="leancloud_visitors" data-flag-title="Eclipse 常用快捷键">
|
<span class="post-meta-item-icon">
<i class="fa fa-eye"></i>
</span>
<span class="post-meta-item-text">阅读次数 </span>
<span class="leancloud-visitors-count"></span>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h1 id="编辑"><a href="#编辑" class="headerlink" title="编辑"></a>编辑</h1><p>Ctrl+1 快速修复(最经典的快捷键,就不用多说了,可以解决很多问题,比如import类、try catch包围等)<br>Ctrl+Shift+F 格式化当前代码<br>Ctrl+Shift+M 添加类的import导入<br>Ctrl+Shift+O 组织类的import导入(既有Ctrl+Shift+M的作用,又可以帮你去除没用的导入,很有用)<br>Ctrl+Y 重做(与撤销Ctrl+Z相反)<br>Alt+/ 内容辅助(帮你省了多少次键盘敲打,太常用了)<br>Ctrl+D 删除当前行或者多行<br>Alt+↓ 当前行和下面一行交互位置(特别实用,可以省去先剪切,再粘贴了)<br>Alt+↑ 当前行和上面一行交互位置(同上)<br>Ctrl+Alt+↓ 复制当前行到下一行(复制增加)<br>Ctrl+Alt+↑ 复制当前行到上一行(复制增加)<br>Shift+Enter 在当前行的下一行插入空行(这时鼠标可以在当前行的任一位置,不一定是最后)<br>Ctrl+/ 注释当前行,再按则取消注释</p>
<hr>
<h1 id="选择"><a href="#选择" class="headerlink" title="选择"></a>选择</h1><p>Alt+Shift+↑ 选择封装元素<br>Alt+Shift+← 选择上一个元素<br>Alt+Shift+→ 选择下一个元素<br>Shift+← 从光标处开始往左选择字符<br>Shift+→ 从光标处开始往右选择字符<br>Ctrl+Shift+← 选中光标左边的单词<br>Ctrl+Shift+→ 选中光标又边的单词</p>
<hr>
<h1 id="移动"><a href="#移动" class="headerlink" title="移动"></a>移动</h1><p>Ctrl+← 光标移到左边单词的开头,相当于vim的b<br>Ctrl+→ 光标移到右边单词的末尾,相当于vim的e</p>
<hr>
<h1 id="搜索"><a href="#搜索" class="headerlink" title="搜索"></a>搜索</h1><p>Ctrl+K 参照选中的Word快速定位到下一个(如果没有选中word,则搜索上一次使用搜索的word)<br>Ctrl+Shift+K 参照选中的Word快速定位到上一个<br>Ctrl+J 正向增量查找(按下Ctrl+J后,你所输入的每个字母编辑器都提供快速匹配定位到某个单词,如果没有,则在状态栏中显示没有找到了,查一个单词时,特别实用,要退出这个模式,按escape建)<br>Ctrl+Shift+J 反向增量查找(和上条相同,只不过是从后往前查)<br>Ctrl+Shift+U 列出所有包含字符串的行<br>Ctrl+H 打开搜索对话框<br>Ctrl+G 工作区中的声明<br>Ctrl+Shift+G 工作区中的引用</p>
<hr>
<h1 id="导航"><a href="#导航" class="headerlink" title="导航"></a>导航</h1><p>Ctrl+Shift+T 搜索类(包括工程和关联的第三jar包)<br>Ctrl+Shift+R 搜索工程中的文件<br>Ctrl+E 快速显示当前Editer的下拉列表(如果当前页面没有显示的用黑体表示)<br>F4 打开类型层次结构<br>F3 跳转到声明处<br>Alt+← 前一个编辑的页面<br>Alt+→ 下一个编辑的页面(当然是针对上面那条来说了)<br>Ctrl+PageUp/PageDown 在编辑器中,切换已经打开的文件</p>
<hr>
<h1 id="调试"><a href="#调试" class="headerlink" title="调试"></a>调试</h1><p>F5 单步跳入<br>F6 单步跳过<br>F7 单步返回<br>F8 继续<br>Ctrl+Shift+D 显示变量的值<br>Ctrl+Shift+B 在当前行设置或者去掉断点<br>Ctrl+R 运行至行(超好用,可以节省好多的断点)</p>
<hr>
<h1 id="重构"><a href="#重构" class="headerlink" title="重构"></a>重构</h1><p>(一般重构的快捷键都是Alt+Shift开头的了)<br>Alt+Shift+R 重命名方法名、属性或者变量名 (是我自己最爱用的一个了,尤其是变量和类的Rename,比手工方法能节省很多劳动力)<br>Alt+Shift+M 把一段函数内的代码抽取成方法 (这是重构里面最常用的方法之一了,尤其是对一大堆泥团代码有用)<br>Alt+Shift+C 修改函数结构(比较实用,有N个函数调用了这个方法,修改一次搞定)<br>Alt+Shift+L 抽取本地变量( 可以直接把一些魔法数字和字符串抽取成一个变量,尤其是多处调用的时候)<br>Alt+Shift+F 把Class中的local变量变为field变量 (比较实用的功能)<br>Alt+Shift+I 合并变量(可能这样说有点不妥Inline)<br>Alt+Shift+V 移动函数和变量(不怎么常用)<br>Alt+Shift+Z 重构的后悔药(Undo)</p>
<hr>
<h1 id="其他"><a href="#其他" class="headerlink" title="其他"></a>其他</h1><p>Alt+Enter 显示当前选择资源的属性,windows下的查看文件的属性就是这个快捷键,通常用来查看文件在windows中的实际路径<br>Ctrl+↑ 文本编辑器 上滚行<br>Ctrl+↓ 文本编辑器 下滚行<br>Ctrl+M 最大化当前的Edit或View (再按则反之)<br>Ctrl+O 快速显示 OutLine(不开Outline窗口的同学,这个快捷键是必不可少的)<br>Ctrl+T 快速显示当前类的继承结构<br>Ctrl+W 关闭当前Editer(windows下关闭打开的对话框也是这个,还有qq、旺旺、浏览器等都是)<br>Ctrl+L 文本编辑器 转至行<br>F2 显示工具提示描述</p>
</div>
<div>
</div>
<div>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a class="post-title-link" href="/zh-Hans/2018-06-07-linux-常用命令大全.html" itemprop="url">
Linux 常用命令大全
</a>
</h1>
<div class="post-meta">
<span class="post-time">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time itemprop="dateCreated" datetime="2018-06-07T17:54:01+08:00" content="2018-06-07">
2018-06-07
</time>
</span>
<span class="post-category" >
|
<span class="post-meta-item-icon">
<i class="fa fa-folder-o"></i>
</span>
<span class="post-meta-item-text">分类于</span>
<span itemprop="about" itemscope itemtype="https://schema.org/Thing">
<a href="/categories/速查手册/" itemprop="url" rel="index">
<span itemprop="name">速查手册</span>
</a>
</span>
</span>
<span id="/zh-Hans/2018-06-07-linux-常用命令大全.html" class="leancloud_visitors" data-flag-title="Linux 常用命令大全">
|
<span class="post-meta-item-icon">
<i class="fa fa-eye"></i>
</span>
<span class="post-meta-item-text">阅读次数 </span>
<span class="leancloud-visitors-count"></span>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<p>#系统信息<br><figure class="highlight tcl"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line">arch 显示机器的处理器架构(<span class="number">1</span>) </span><br><span class="line">uname -m 显示机器的处理器架构(<span class="number">2</span>) </span><br><span class="line">uname -r 显示正在使用的内核版本 </span><br><span class="line">dmidecode -q 显示硬件系统部件 - (SMBIOS / DMI) </span><br><span class="line">hdparm -i /dev/hda 罗列一个磁盘的架构特性 </span><br><span class="line">hdparm -tT /dev/sda 在磁盘上执行测试性读取操作 </span><br><span class="line">cat /<span class="keyword">proc</span>/cpuinfo 显示CPU<span class="title"> info的信息</span> </span><br><span class="line">cat /<span class="keyword">proc</span>/interrupts 显示中断 </span><br><span class="line">cat /<span class="keyword">proc</span>/meminfo 校验内存使用 </span><br><span class="line">cat /<span class="keyword">proc</span>/swaps 显示哪些swap被使用 </span><br><span class="line">cat /<span class="keyword">proc</span>/version 显示内核的版本 </span><br><span class="line">cat /<span class="keyword">proc</span>/net/dev 显示网络适配器及统计 </span><br><span class="line">cat /<span class="keyword">proc</span>/mounts 显示已加载的文件系统 </span><br><span class="line">lspci -tv 罗列<span class="title"> PCI</span> 设备 </span><br><span class="line">lsusb -tv 显示<span class="title"> USB</span> 设备 </span><br><span class="line">date 显示系统日期 </span><br><span class="line">cal 2007 显示2007年的日历表 </span><br><span class="line">date 041217002007.00 设置日期和时间 - 月日时分年.秒 </span><br><span class="line">clock -w 将时间修改保存到<span class="title"> BIOS</span></span><br></pre></td></tr></table></figure> </p>
<hr>
<p>#关机 (系统的关机、重启以及登出 )<br><figure class="highlight less"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-tag">shutdown</span> <span class="selector-tag">-h</span> <span class="selector-tag">now</span> 关闭系统(<span class="number">1</span>) </span><br><span class="line"><span class="selector-tag">init</span> <span class="selector-tag">0</span> 关闭系统(<span class="number">2</span>) </span><br><span class="line"><span class="selector-tag">telinit</span> <span class="selector-tag">0</span> 关闭系统(<span class="number">3</span>) </span><br><span class="line"><span class="selector-tag">shutdown</span> <span class="selector-tag">-h</span> <span class="selector-tag">hours</span><span class="selector-pseudo">:minutes</span> <span class="selector-tag">&</span> 按预定时间关闭系统 </span><br><span class="line"><span class="selector-tag">shutdown</span> <span class="selector-tag">-c</span> 取消按预定时间关闭系统 </span><br><span class="line"><span class="selector-tag">shutdown</span> <span class="selector-tag">-r</span> <span class="selector-tag">now</span> 重启(<span class="number">1</span>) </span><br><span class="line"><span class="selector-tag">reboot</span> 重启(<span class="number">2</span>) </span><br><span class="line"><span class="selector-tag">logout</span> 注销 </span><br></pre></td></tr></table></figure></p>
<hr>
<p>#文件和目录 </p>
<figure class="highlight stata"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">cd</span> /home 进入 '/ home' 目录' </span><br><span class="line"><span class="keyword">cd</span> .. 返回上一级目录 </span><br><span class="line"><span class="keyword">cd</span> ../.. 返回上两级目录 </span><br><span class="line"><span class="keyword">cd</span> 进入个人的主目录 </span><br><span class="line"><span class="keyword">cd</span> ~user1 进入个人的主目录 </span><br><span class="line"><span class="keyword">cd</span> - 返回上次所在的目录 </span><br><span class="line"><span class="keyword">pwd</span> 显示工作路径 </span><br><span class="line"><span class="keyword">ls</span> 查看目录中的文件 </span><br><span class="line"><span class="keyword">ls</span> -F 查看目录中的文件 </span><br><span class="line"><span class="keyword">ls</span> -<span class="keyword">l</span> 显示文件和目录的详细资料 </span><br><span class="line"><span class="keyword">ls</span> -a 显示隐藏文件 </span><br><span class="line"><span class="keyword">ls</span> *[0-9]* 显示包含数字的文件名和目录名 </span><br><span class="line">tree 显示文件和目录由根目录开始的树形结构(1) </span><br><span class="line">lstree 显示文件和目录由根目录开始的树形结构(2) </span><br><span class="line"><span class="keyword">mkdir</span> dir1 创建一个叫做 'dir1' 的目录' </span><br><span class="line"><span class="keyword">mkdir</span> dir1 dir2 同时创建两个目录 </span><br><span class="line"><span class="keyword">mkdir</span> -p /tmp/dir1/dir2 创建一个目录树 </span><br><span class="line"><span class="keyword">rm</span> -f file1 删除一个叫做 'file1' 的文件' </span><br><span class="line"><span class="keyword">rmdir</span> dir1 删除一个叫做 'dir1' 的目录' </span><br><span class="line"><span class="keyword">rm</span> -rf dir1 删除一个叫做 'dir1' 的目录并同时删除其内容 </span><br><span class="line"><span class="keyword">rm</span> -rf dir1 dir2 同时删除两个目录及它们的内容 </span><br><span class="line">mv dir1 new_dir 重命名/移动 一个目录 </span><br><span class="line">cp file1 file2 复制一个文件 </span><br><span class="line">cp <span class="keyword">dir</span><span class="comment">/* . 复制一个目录下的所有文件到当前工作目录 </span></span><br><span class="line"><span class="comment">cp -a /tmp/dir1 . 复制一个目录到当前工作目录 </span></span><br><span class="line"><span class="comment">cp -a dir1 dir2 复制一个目录 </span></span><br><span class="line"><span class="comment">ln -s file1 lnk1 创建一个指向文件或目录的软链接 </span></span><br><span class="line"><span class="comment">ln file1 lnk1 创建一个指向文件或目录的物理链接 </span></span><br><span class="line"><span class="comment">touch -t 0712250000 file1 修改一个文件或目录的时间戳 - (YYMMDDhhmm) </span></span><br><span class="line"><span class="comment">file file1 outputs the mime type of the file as text </span></span><br><span class="line"><span class="comment">iconv -l 列出已知的编码 </span></span><br><span class="line"><span class="comment">iconv -f fromEncoding -t toEncoding inputFile > outputFile creates a new from the given input file by assuming it is encoded in fromEncoding and converting it to toEncoding. </span></span><br><span class="line"><span class="comment">find . -maxdepth 1 -name *.jpg -print -exec convert "{}" -resize 80x60 "thumbs/{}" \; batch resize files in the current directory and send them to a thumbnails directory (requires convert from Imagemagick) </span></span><br><span class="line"><span class="comment"></span></span><br></pre></td></tr></table></figure>
<hr>
<p>#文件搜索<br><figure class="highlight sqf"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">find</span> / -<span class="built_in">name</span> file1 从 <span class="string">'/'</span> 开始进入根文件系统搜索文件和目录 </span><br><span class="line"><span class="built_in">find</span> / -user user1 搜索属于用户 <span class="string">'user1'</span> 的文件和目录 </span><br><span class="line"><span class="built_in">find</span> /home/user1 -<span class="built_in">name</span> \*.bin 在目录 <span class="string">'/ home/user1'</span> 中搜索带有<span class="string">'.bin'</span> 结尾的文件 </span><br><span class="line"><span class="built_in">find</span> /usr/bin -<span class="built_in">type</span> f -atime +<span class="number">100</span> 搜索在过去<span class="number">100</span>天内未被使用过的执行文件 </span><br><span class="line"><span class="built_in">find</span> /usr/bin -<span class="built_in">type</span> f -mtime -<span class="number">10</span> 搜索在<span class="number">10</span>天内被创建或者修改过的文件 </span><br><span class="line"><span class="built_in">find</span> / -<span class="built_in">name</span> \*.rpm -<span class="built_in">exec</span> chmod <span class="number">755</span> <span class="string">'{}'</span> \; 搜索以 <span class="string">'.rpm'</span> 结尾的文件并定义其权限 </span><br><span class="line"><span class="built_in">find</span> / -xdev -<span class="built_in">name</span> \*.rpm 搜索以 <span class="string">'.rpm'</span> 结尾的文件,忽略光驱、捷盘等可移动设备 </span><br><span class="line">locate \*.ps 寻找以 <span class="string">'.ps'</span> 结尾的文件 - 先运行 <span class="string">'updatedb'</span> 命令 </span><br><span class="line">whereis <span class="built_in">halt</span> 显示一个二进制文件、源码或man的位置 </span><br><span class="line">which <span class="built_in">halt</span> 显示一个二进制文件或可执行文件的完整路径 </span><br><span class="line"></span><br></pre></td></tr></table></figure></p>
<hr>
<p>#挂载一个文件系统 </p>
<figure class="highlight gradle"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">mount <span class="regexp">/dev/</span>hda2 <span class="regexp">/mnt/</span>hda2 挂载一个叫做hda2的盘 - 确定目录 <span class="string">'/ mnt/hda2'</span> 已经存在 </span><br><span class="line">umount <span class="regexp">/dev/</span>hda2 卸载一个叫做hda2的盘 - 先从挂载点 <span class="string">'/ mnt/hda2'</span> 退出 </span><br><span class="line">fuser -km <span class="regexp">/mnt/</span>hda2 当设备繁忙时强制卸载 </span><br><span class="line">umount -n <span class="regexp">/mnt/</span>hda2 运行卸载操作而不写入 <span class="regexp">/etc/m</span>tab 文件- 当文件为只读或当磁盘写满时非常有用 </span><br><span class="line">mount <span class="regexp">/dev/</span>fd0 <span class="regexp">/mnt/</span>floppy 挂载一个软盘 </span><br><span class="line">mount <span class="regexp">/dev/</span>cdrom <span class="regexp">/mnt/</span>cdrom 挂载一个cdrom或dvdrom </span><br><span class="line">mount <span class="regexp">/dev/</span>hdc <span class="regexp">/mnt/</span>cdrecorder 挂载一个cdrw或dvdrom </span><br><span class="line">mount <span class="regexp">/dev/</span>hdb <span class="regexp">/mnt/</span>cdrecorder 挂载一个cdrw或dvdrom </span><br><span class="line">mount -o loop <span class="keyword">file</span>.iso <span class="regexp">/mnt/</span>cdrom 挂载一个文件或ISO镜像文件 </span><br><span class="line">mount -t vfat <span class="regexp">/dev/</span>hda5 <span class="regexp">/mnt/</span>hda5 挂载一个Windows FAT32文件系统 </span><br><span class="line">mount <span class="regexp">/dev/</span>sda1 <span class="regexp">/mnt/u</span>sbdisk 挂载一个usb 捷盘或闪存设备 </span><br><span class="line">mount -t smbfs -o username=user,password=pass <span class="comment">//WinClient/share /mnt/share 挂载一个windows网络共享 </span></span><br><span class="line"></span><br></pre></td></tr></table></figure>
<hr>
<p>#磁盘空间<br><figure class="highlight stata"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">df -<span class="keyword">h</span> 显示已经挂载的分区列表 </span><br><span class="line"><span class="keyword">ls</span> -lSr |<span class="keyword">more</span> 以尺寸大小排列文件和目录 </span><br><span class="line">du -<span class="keyword">sh</span> dir1 估算目录 'dir1' 已经使用的磁盘空间' </span><br><span class="line">du -sk * | <span class="keyword">sort</span> -rn 以容量大小为依据依次显示文件和目录的大小 </span><br><span class="line">rpm -q -a --qf '%10{SIZE}t%{NAME}<span class="keyword">n</span>' | <span class="keyword">sort</span> -k1,1n 以大小为依据依次显示已安装的rpm包所使用的空间 (fedora, redhat类系统) </span><br><span class="line">dpkg-<span class="keyword">query</span> -W -f='<span class="variable">${Installed</span>-Size;10}t<span class="variable">${Package}</span><span class="keyword">n</span>' | <span class="keyword">sort</span> -k1,1n 以大小为依据显示已安装的deb包所使用的空间 (ubuntu, debian类系统) </span><br><span class="line"></span><br></pre></td></tr></table></figure></p>
<hr>
<p>#用户和群组<br><figure class="highlight awk"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">groupadd group_name 创建一个新用户组 </span><br><span class="line">groupdel group_name 删除一个用户组 </span><br><span class="line">groupmod -n new_group_name old_group_name 重命名一个用户组 </span><br><span class="line">useradd -c <span class="string">"Name Surname "</span> -g admin -d <span class="regexp">/home/u</span>ser1 -s <span class="regexp">/bin/</span>bash user1 创建一个属于 <span class="string">"admin"</span> 用户组的用户 </span><br><span class="line">useradd user1 创建一个新用户 </span><br><span class="line">userdel -r user1 删除一个用户 ( <span class="string">'-r'</span> 排除主目录) </span><br><span class="line">usermod -c <span class="string">"User FTP"</span> -g system -d <span class="regexp">/ftp/u</span>ser1 -s <span class="regexp">/bin/</span>nologin user1 修改用户属性 </span><br><span class="line">passwd 修改口令 </span><br><span class="line">passwd user1 修改一个用户的口令 (只允许root执行) </span><br><span class="line">chage -E <span class="number">2005</span>-<span class="number">12</span>-<span class="number">31</span> user1 设置用户口令的失效期限 </span><br><span class="line">pwck 检查 <span class="string">'/etc/passwd'</span> 的文件格式和语法修正以及存在的用户 </span><br><span class="line">grpck 检查 <span class="string">'/etc/passwd'</span> 的文件格式和语法修正以及存在的群组 </span><br><span class="line">newgrp group_name 登陆进一个新的群组以改变新创建文件的预设群组 </span><br><span class="line"></span><br></pre></td></tr></table></figure></p>
<hr>
<p>#文件的权限</p>
<h2 id="使用-“-”-设置权限,使用-“-“-用于取消"><a href="#使用-“-”-设置权限,使用-“-“-用于取消" class="headerlink" title="使用 “+” 设置权限,使用 “-“ 用于取消"></a>使用 “+” 设置权限,使用 “-“ 用于取消</h2><figure class="highlight perl"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line">ls -lh 显示权限 </span><br><span class="line">ls /tmp | pr -T5 -W$COLUMNS 将终端划分成<span class="number">5</span>栏显示 </span><br><span class="line"><span class="keyword">chmod</span> ugo+rwx directory1 设置目录的所有人(u)、群组(g)以及其他人(o)以读(r )、写(w)和执行(<span class="keyword">x</span>)的权限 </span><br><span class="line"><span class="keyword">chmod</span> go-rwx directory1 删除群组(g)与其他人(o)对目录的读写执行权限 </span><br><span class="line"><span class="keyword">chown</span> user1 file1 改变一个文件的所有人属性 </span><br><span class="line"><span class="keyword">chown</span> -R user1 directory1 改变一个目录的所有人属性并同时改变改目录下所有文件的属性 </span><br><span class="line">chgrp group1 file1 改变文件的群组 </span><br><span class="line"><span class="keyword">chown</span> user1:group1 file1 改变一个文件的所有人和群组属性 </span><br><span class="line">find / -perm -u+<span class="keyword">s</span> 罗列一个系统中所有使用了SUID控制的文件 </span><br><span class="line"><span class="keyword">chmod</span> u+<span class="keyword">s</span> /bin/file1 设置一个二进制文件的 SUID 位 - 运行该文件的用户也被赋予和所有者同样的权限 </span><br><span class="line"><span class="keyword">chmod</span> u-<span class="keyword">s</span> /bin/file1 禁用一个二进制文件的 SUID位 </span><br><span class="line"><span class="keyword">chmod</span> g+<span class="keyword">s</span> /home/public 设置一个目录的SGID 位 - 类似SUID ,不过这是针对目录的 </span><br><span class="line"><span class="keyword">chmod</span> g-<span class="keyword">s</span> /home/public 禁用一个目录的 SGID 位 </span><br><span class="line"><span class="keyword">chmod</span> o+t /home/public 设置一个文件的 STIKY 位 - 只允许合法所有人删除文件 </span><br><span class="line"><span class="keyword">chmod</span> o-t /home/public 禁用一个目录的 STIKY 位</span><br><span class="line"></span><br></pre></td></tr></table></figure>
<hr>
<p>#文件的特殊属性</p>
<p>##使用 “+” 设置权限,使用 “-“ 用于取消<br><figure class="highlight stylus"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">chattr +<span class="selector-tag">a</span> file1 只允许以追加方式读写文件 </span><br><span class="line">chattr +c file1 允许这个文件能被内核自动压缩/解压 </span><br><span class="line">chattr +d file1 在进行文件系统备份时,dump程序将忽略这个文件 </span><br><span class="line">chattr +<span class="selector-tag">i</span> file1 设置成不可变的文件,不能被删除、修改、重命名或者链接 </span><br><span class="line">chattr +s file1 允许一个文件被安全地删除 </span><br><span class="line">chattr +S file1 一旦应用程序对这个文件执行了写操作,使系统立刻把修改的结果写到磁盘 </span><br><span class="line">chattr +u file1 若文件被删除,系统会允许你在以后恢复这个被删除的文件 </span><br><span class="line">lsattr 显示特殊的属性 </span><br><span class="line"></span><br></pre></td></tr></table></figure></p>
<hr>
<p>#打包和压缩文件 </p>
<figure class="highlight ceylon"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br></pre></td><td class="code"><pre><span class="line">bunzip<span class="number">2</span> file<span class="number">1</span>.bz<span class="number">2</span> 解压一个叫做 <span class="string">'file1.bz2'</span>的文件 </span><br><span class="line">bzip<span class="number">2</span> file<span class="number">1</span> 压缩一个叫做 <span class="string">'file1'</span> 的文件 </span><br><span class="line">gunzip file<span class="number">1</span>.gz 解压一个叫做 <span class="string">'file1.gz'</span>的文件 </span><br><span class="line">gzip file<span class="number">1</span> 压缩一个叫做 <span class="string">'file1'</span>的文件 </span><br><span class="line">gzip -<span class="number">9</span> file<span class="number">1</span> 最大程度压缩 </span><br><span class="line">rar a file<span class="number">1</span>.rar test<span class="number">_f</span>ile 创建一个叫做 <span class="string">'file1.rar'</span> 的包 </span><br><span class="line">rar a file<span class="number">1</span>.rar file<span class="number">1</span> file<span class="number">2</span> dir<span class="number">1</span> 同时压缩 <span class="string">'file1'</span>, <span class="string">'file2'</span> 以及目录 <span class="string">'dir1'</span> </span><br><span class="line">rar x file<span class="number">1</span>.rar 解压rar包 </span><br><span class="line">unrar x file<span class="number">1</span>.rar 解压rar包 </span><br><span class="line">tar -cvf archive.tar file<span class="number">1</span> 创建一个非压缩的 tarball </span><br><span class="line">tar -cvf archive.tar file<span class="number">1</span> file<span class="number">2</span> dir<span class="number">1</span> 创建一个包含了 <span class="string">'file1'</span>, <span class="string">'file2'</span> 以及 <span class="string">'dir1'</span>的档案文件 </span><br><span class="line">tar -tf archive.tar 显示一个包中的内容 </span><br><span class="line">tar -xvf archive.tar 释放一个包 </span><br><span class="line">tar -xvf archive.tar -C /tmp 将压缩包释放到 /tmp目录下 </span><br><span class="line">tar -cvfj archive.tar.bz<span class="number">2</span> dir<span class="number">1</span> 创建一个bzip<span class="number">2</span>格式的压缩包 </span><br><span class="line">tar -xvfj archive.tar.bz<span class="number">2</span> 解压一个bzip<span class="number">2</span>格式的压缩包 </span><br><span class="line">tar -cvfz archive.tar.gz dir<span class="number">1</span> 创建一个gzip格式的压缩包 </span><br><span class="line">tar -xvfz archive.tar.gz 解压一个gzip格式的压缩包 </span><br><span class="line">zip file<span class="number">1</span>.zip file<span class="number">1</span> 创建一个zip格式的压缩包 </span><br><span class="line">zip -r file<span class="number">1</span>.zip file<span class="number">1</span> file<span class="number">2</span> dir<span class="number">1</span> 将几个文件和目录同时压缩成一个zip格式的压缩包 </span><br><span class="line">unzip file<span class="number">1</span>.zip 解压一个zip格式压缩包 </span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line">RPM 包 - (Fedora, Redhat及类似系统) </span><br><span class="line">rpm -ivh <span class="keyword">package</span>.rpm 安装一个rpm包 </span><br><span class="line">rpm -ivh --nodeeps <span class="keyword">package</span>.rpm 安装一个rpm包而忽略依赖关系警告 </span><br><span class="line">rpm -U <span class="keyword">package</span>.rpm 更新一个rpm包但不改变其配置文件 </span><br><span class="line">rpm -F <span class="keyword">package</span>.rpm 更新一个确定已经安装的rpm包 </span><br><span class="line">rpm -e <span class="keyword">package</span><span class="number">_n</span>ame.rpm 删除一个rpm包 </span><br><span class="line">rpm -qa 显示系统中所有已经安装的rpm包 </span><br><span class="line">rpm -qa | grep httpd 显示所有名称中包含 <span class="string">"httpd"</span> 字样的rpm包 </span><br><span class="line">rpm -qi <span class="keyword">package</span><span class="number">_n</span>ame 获取一个已安装包的特殊信息 </span><br><span class="line">rpm -qg <span class="string">"System Environment/Daemons"</span> 显示一个组件的rpm包 </span><br><span class="line">rpm -ql <span class="keyword">package</span><span class="number">_n</span>ame 显示一个已经安装的rpm包提供的文件列表 </span><br><span class="line">rpm -qc <span class="keyword">package</span><span class="number">_n</span>ame 显示一个已经安装的rpm包提供的配置文件列表 </span><br><span class="line">rpm -q <span class="keyword">package</span><span class="number">_n</span>ame --whatrequires 显示与一个rpm包存在依赖关系的列表 </span><br><span class="line">rpm -q <span class="keyword">package</span><span class="number">_n</span>ame --whatprovides 显示一个rpm包所占的体积 </span><br><span class="line">rpm -q <span class="keyword">package</span><span class="number">_n</span>ame --scripts 显示在安装/删除期间所执行的脚本l </span><br><span class="line">rpm -q <span class="keyword">package</span><span class="number">_n</span>ame --changelog 显示一个rpm包的修改历史 </span><br><span class="line">rpm -qf /etc/httpd/conf/httpd.conf 确认所给的文件由哪个rpm包所提供 </span><br><span class="line">rpm -qp <span class="keyword">package</span>.rpm -l 显示由一个尚未安装的rpm包提供的文件列表 </span><br><span class="line">rpm --<span class="keyword">import</span> /media/cdrom/RPM-GPG-KEY 导入公钥数字证书 </span><br><span class="line">rpm --checksig <span class="keyword">package</span>.rpm 确认一个rpm包的完整性 </span><br><span class="line">rpm -qa gpg-pubkey 确认已安装的所有rpm包的完整性 </span><br><span class="line">rpm -V <span class="keyword">package</span><span class="number">_n</span>ame 检查文件尺寸、 许可、类型、所有者、群组、MD<span class="number">5</span>检查以及最后修改时间 </span><br><span class="line">rpm -Va 检查系统中所有已安装的rpm包- 小心使用 </span><br><span class="line">rpm -Vp <span class="keyword">package</span>.rpm 确认一个rpm包还未安装 </span><br><span class="line">rpm<span class="number">2</span>cpio <span class="keyword">package</span>.rpm | cpio --extract --make-directories *bin* 从一个rpm包运行可执行文件 </span><br><span class="line">rpm -ivh /usr/src/redhat/RPMS/`arch`/<span class="keyword">package</span>.rpm 从一个rpm源码安装一个构建好的包 </span><br><span class="line">rpmbuild --rebuild <span class="keyword">package</span><span class="number">_n</span>ame.src.rpm 从一个rpm源码构建一个 rpm 包 </span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line">YUM 软件包升级器 - (Fedora, RedHat及类似系统) </span><br><span class="line">yum install <span class="keyword">package</span><span class="number">_n</span>ame 下载并安装一个rpm包 </span><br><span class="line">yum localinstall <span class="keyword">package</span><span class="number">_n</span>ame.rpm 将安装一个rpm包,使用你自己的软件仓库为你解决所有依赖关系 </span><br><span class="line">yum update <span class="keyword">package</span><span class="number">_n</span>ame.rpm 更新当前系统中所有安装的rpm包 </span><br><span class="line">yum update <span class="keyword">package</span><span class="number">_n</span>ame 更新一个rpm包 </span><br><span class="line">yum remove <span class="keyword">package</span><span class="number">_n</span>ame 删除一个rpm包 </span><br><span class="line">yum list 列出当前系统中安装的所有包 </span><br><span class="line">yum search <span class="keyword">package</span><span class="number">_n</span>ame 在rpm仓库中搜寻软件包 </span><br><span class="line">yum clean packages 清理rpm缓存删除下载的包 </span><br><span class="line">yum clean headers 删除所有头文件 </span><br><span class="line">yum clean all 删除所有缓存的包和头文件 </span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line">DEB 包 (Debian, Ubuntu 以及类似系统) </span><br><span class="line">dpkg -i <span class="keyword">package</span>.deb 安装/更新一个 deb 包 </span><br><span class="line">dpkg -r <span class="keyword">package</span><span class="number">_n</span>ame 从系统删除一个 deb 包 </span><br><span class="line">dpkg -l 显示系统中所有已经安装的 deb 包 </span><br><span class="line">dpkg -l | grep httpd 显示所有名称中包含 <span class="string">"httpd"</span> 字样的deb包 </span><br><span class="line">dpkg -s <span class="keyword">package</span><span class="number">_n</span>ame 获得已经安装在系统中一个特殊包的信息 </span><br><span class="line">dpkg -L <span class="keyword">package</span><span class="number">_n</span>ame 显示系统中已经安装的一个deb包所提供的文件列表 </span><br><span class="line">dpkg --contents <span class="keyword">package</span>.deb 显示尚未安装的一个包所提供的文件列表 </span><br><span class="line">dpkg -S /bin/ping 确认所给的文件由哪个deb包提供 </span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line">APT 软件工具 (Debian, Ubuntu 以及类似系统) </span><br><span class="line">apt-get install <span class="keyword">package</span><span class="number">_n</span>ame 安装/更新一个 deb 包 </span><br><span class="line">apt-cdrom install <span class="keyword">package</span><span class="number">_n</span>ame 从光盘安装/更新一个 deb 包 </span><br><span class="line">apt-get update 升级列表中的软件包 </span><br><span class="line">apt-get upgrade 升级所有已安装的软件 </span><br><span class="line">apt-get remove <span class="keyword">package</span><span class="number">_n</span>ame 从系统删除一个deb包 </span><br><span class="line">apt-get check 确认依赖的软件仓库正确 </span><br><span class="line">apt-get clean 从下载的软件包中清理缓存 </span><br><span class="line">apt-cache search searched-<span class="keyword">package</span> 返回包含所要搜索字符串的软件包名称 </span><br><span class="line"></span><br></pre></td></tr></table></figure>
<hr>
<p>#查看文件内容 </p>
<figure class="highlight stata"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">cat</span> file1 从第一个字节开始正向查看文件的内容 </span><br><span class="line">tac file1 从最后一行开始反向查看一个文件的内容 </span><br><span class="line"><span class="keyword">more</span> file1 查看一个长文件的内容 </span><br><span class="line">less file1 类似于 '<span class="keyword">more</span>' 命令,但是它允许在文件中和正向操作一样的反向操作 </span><br><span class="line">head -2 file1 查看一个文件的前两行 </span><br><span class="line">tail -2 file1 查看一个文件的最后两行 </span><br><span class="line">tail -f /<span class="keyword">var</span>/<span class="keyword">log</span>/messages 实时查看被添加到一个文件中的内容 </span><br><span class="line"></span><br></pre></td></tr></table></figure>
<hr>
<p>#文本处理<br><figure class="highlight vim"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">cat</span> file1 file2 ... | <span class="keyword">command</span> <> file1_in.txt_or_file1_out.txt general <span class="keyword">syntax</span> <span class="keyword">for</span> text manipulation using PIPE, STDIN <span class="built_in">and</span> STDOUT </span><br><span class="line"><span class="keyword">cat</span> file1 | <span class="keyword">command</span>( sed, <span class="keyword">grep</span>, awk, <span class="keyword">grep</span>, etc...) > result.txt 合并一个文件的详细说明文本,并将简介写入一个新文件中 </span><br><span class="line"><span class="keyword">cat</span> file1 | <span class="keyword">command</span>( sed, <span class="keyword">grep</span>, awk, <span class="keyword">grep</span>, etc...) >> result.txt 合并一个文件的详细说明文本,并将简介写入一个已有的文件中 </span><br><span class="line"><span class="keyword">grep</span> Aug /var/<span class="built_in">log</span>/<span class="keyword">messages</span> 在文件 <span class="string">'/var/log/messages'</span>中查找关键词<span class="string">"Aug"</span> </span><br><span class="line"><span class="keyword">grep</span> ^Aug /var/<span class="built_in">log</span>/<span class="keyword">messages</span> 在文件 <span class="string">'/var/log/messages'</span>中查找以<span class="string">"Aug"</span>开始的词汇 </span><br><span class="line"><span class="keyword">grep</span> [<span class="number">0</span>-<span class="number">9</span>] /var/<span class="built_in">log</span>/<span class="keyword">messages</span> 选择 <span class="string">'/var/log/messages'</span> 文件中所有包含数字的行 </span><br><span class="line"><span class="keyword">grep</span> Aug -R /var/<span class="built_in">log</span>/* 在目录 <span class="string">'/var/log'</span> 及随后的目录中搜索字符串<span class="string">"Aug"</span> </span><br><span class="line">sed <span class="string">'s/stringa1/stringa2/g'</span> example.txt 将example.txt文件中的 <span class="string">"string1"</span> 替换成 <span class="string">"string2"</span> </span><br><span class="line">sed <span class="string">'/^$/d'</span> example.txt 从example.txt文件中删除所有空白行 </span><br><span class="line">sed <span class="string">'/ *#/d; /^$/d'</span> example.txt 从example.txt文件中删除所有注释和空白行 </span><br><span class="line"><span class="keyword">echo</span> <span class="string">'esempio'</span> | <span class="keyword">tr</span> <span class="string">'[:lower:]'</span> <span class="string">'[:upper:]'</span> 合并上下单元格内容 </span><br><span class="line">sed -<span class="keyword">e</span> <span class="string">'1d'</span> result.txt 从文件example.txt 中排除第一行 </span><br><span class="line">sed -n <span class="string">'/stringa1/p'</span> 查看只包含词汇 <span class="string">"string1"</span>的行 </span><br><span class="line">sed -<span class="keyword">e</span> <span class="string">'s/ *$//'</span> example.txt 删除每一行最后的空白字符 </span><br><span class="line">sed -<span class="keyword">e</span> <span class="string">'s/stringa1//g'</span> example.txt 从文档中只删除词汇 <span class="string">"string1"</span> 并保留剩余全部 </span><br><span class="line">sed -n <span class="string">'1,5p;5q'</span> example.txt 查看从第一行到第<span class="number">5</span>行内容 </span><br><span class="line">sed -n <span class="string">'5p;5q'</span> example.txt 查看第<span class="number">5</span>行 </span><br><span class="line">sed -<span class="keyword">e</span> <span class="string">'s/00*/0/g'</span> example.txt 用单个零替换多个零 </span><br><span class="line"><span class="keyword">cat</span> -n file1 标示文件的行数 </span><br><span class="line"><span class="keyword">cat</span> example.txt | awk <span class="string">'NR%2==1'</span> 删除example.txt文件中的所有偶数行 </span><br><span class="line"><span class="keyword">echo</span> <span class="keyword">a</span> <span class="keyword">b</span> <span class="keyword">c</span> | awk <span class="string">'{print $1}'</span> 查看一行第一栏 </span><br><span class="line"><span class="keyword">echo</span> <span class="keyword">a</span> <span class="keyword">b</span> <span class="keyword">c</span> | awk <span class="string">'{print $1,$3}'</span> 查看一行的第一和第三栏 </span><br><span class="line">paste file1 file2 合并两个文件或两栏的内容 </span><br><span class="line">paste -d <span class="string">'+'</span> file1 file2 合并两个文件或两栏的内容,中间用<span class="string">"+"</span>区分 </span><br><span class="line"><span class="keyword">sort</span> file1 file2 排序两个文件的内容 </span><br><span class="line"><span class="keyword">sort</span> file1 file2 | uniq 取出两个文件的并集(重复的行只保留一份) </span><br><span class="line"><span class="keyword">sort</span> file1 file2 | uniq -<span class="keyword">u</span> 删除交集,留下其他的行 </span><br><span class="line"><span class="keyword">sort</span> file1 file2 | uniq -d 取出两个文件的交集(只留下同时存在于两个文件中的文件) </span><br><span class="line">comm -<span class="number">1</span> file1 file2 比较两个文件的内容只删除 <span class="string">'file1'</span> 所包含的内容 </span><br><span class="line">comm -<span class="number">2</span> file1 file2 比较两个文件的内容只删除 <span class="string">'file2'</span> 所包含的内容 </span><br><span class="line">comm -<span class="number">3</span> file1 file2 比较两个文件的内容只删除两个文件共有的部分 </span><br><span class="line"></span><br></pre></td></tr></table></figure></p>
<hr>
<p>#字符设置和文件格式转换<br><figure class="highlight stata"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">dos2unix filedos.txt fileunix.txt 将一个文本文件的格式从MSDOS转换成UNIX </span><br><span class="line">unix2dos fileunix.txt filedos.txt 将一个文本文件的格式从UNIX转换成MSDOS </span><br><span class="line"><span class="keyword">recode</span> ..HTML < page.txt > page.html 将一个文本文件转换成html </span><br><span class="line"><span class="keyword">recode</span> -<span class="keyword">l</span> | <span class="keyword">more</span> 显示所有允许的转换格式 </span><br><span class="line"></span><br></pre></td></tr></table></figure></p>
<hr>
<p>#文件系统分析<br><figure class="highlight dts"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">badblocks -v <span class="meta-keyword">/dev/</span>hda1 检查磁盘hda1上的坏磁块 </span><br><span class="line">fsck <span class="meta-keyword">/dev/</span>hda1 修复/检查hda1磁盘上linux文件系统的完整性 </span><br><span class="line">fsck.ext2 <span class="meta-keyword">/dev/</span>hda1 修复/检查hda1磁盘上ext2文件系统的完整性 </span><br><span class="line">e2fsck <span class="meta-keyword">/dev/</span>hda1 修复/检查hda1磁盘上ext2文件系统的完整性 </span><br><span class="line">e2fsck -j <span class="meta-keyword">/dev/</span>hda1 修复/检查hda1磁盘上ext3文件系统的完整性 </span><br><span class="line">fsck.ext3 <span class="meta-keyword">/dev/</span>hda1 修复/检查hda1磁盘上ext3文件系统的完整性 </span><br><span class="line">fsck.vfat <span class="meta-keyword">/dev/</span>hda1 修复/检查hda1磁盘上fat文件系统的完整性 </span><br><span class="line">fsck.msdos <span class="meta-keyword">/dev/</span>hda1 修复/检查hda1磁盘上dos文件系统的完整性 </span><br><span class="line">dosfsck <span class="meta-keyword">/dev/</span>hda1 修复/检查hda1磁盘上dos文件系统的完整性 </span><br><span class="line"></span><br></pre></td></tr></table></figure></p>
<hr>
<p>#初始化一个文件系统<br><figure class="highlight awk"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">mkfs <span class="regexp">/dev/</span>hda1 在hda1分区创建一个文件系统 </span><br><span class="line">mke2fs <span class="regexp">/dev/</span>hda1 在hda1分区创建一个linux ext2的文件系统 </span><br><span class="line">mke2fs -j <span class="regexp">/dev/</span>hda1 在hda1分区创建一个linux ext3(日志型)的文件系统 </span><br><span class="line">mkfs -t vfat <span class="number">32</span> -F <span class="regexp">/dev/</span>hda1 创建一个 FAT32 文件系统 </span><br><span class="line">fdformat -n <span class="regexp">/dev/</span>fd0 格式化一个软盘 </span><br><span class="line">mkswap <span class="regexp">/dev/</span>hda3 创建一个swap文件系统 </span><br><span class="line"></span><br></pre></td></tr></table></figure></p>
<hr>
<p>#SWAP文件系统<br><figure class="highlight awk"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">mkswap <span class="regexp">/dev/</span>hda3 创建一个swap文件系统 </span><br><span class="line">swapon <span class="regexp">/dev/</span>hda3 启用一个新的swap文件系统 </span><br><span class="line">swapon <span class="regexp">/dev/</span>hda2 <span class="regexp">/dev/</span>hdb3 启用两个swap分区 </span><br><span class="line"></span><br></pre></td></tr></table></figure></p>
<hr>
<p>#备份<br><figure class="highlight jboss-cli"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line"> </span><br><span class="line">dump -0aj -f <span class="string">/tmp/home0.bak</span> <span class="string">/home</span> 制作一个 '<span class="string">/home</span>' 目录的完整备份 </span><br><span class="line">dump -1aj -f <span class="string">/tmp/home0.bak</span> <span class="string">/home</span> 制作一个 '<span class="string">/home</span>' 目录的交互式备份 </span><br><span class="line">restore -if <span class="string">/tmp/home0.bak</span> 还原一个交互式备份 </span><br><span class="line">rsync -rogpav <span class="params">--delete</span> <span class="string">/home</span> <span class="string">/tmp</span> 同步两边的目录 </span><br><span class="line">rsync -rogpav -e ssh <span class="params">--delete</span> <span class="string">/home</span> ip_address:<span class="string">/tmp</span> 通过SSH通道rsync </span><br><span class="line">rsync -az -e ssh <span class="params">--delete</span> ip_addr:<span class="string">/home/public</span> <span class="string">/home/local</span> 通过ssh和压缩将一个远程目录同步到本地目录 </span><br><span class="line">rsync -az -e ssh <span class="params">--delete</span> <span class="string">/home/local</span> ip_addr:<span class="string">/home/public</span> 通过ssh和压缩将本地目录同步到远程目录 </span><br><span class="line">dd bs=1M <span class="keyword">if</span>=<span class="string">/dev/hda</span> | gzip | ssh user@ip_addr 'dd of=hda.gz' 通过ssh在远程主机上执行一次备份本地磁盘的操作 </span><br><span class="line">dd <span class="keyword">if</span>=<span class="string">/dev/sda</span> of=<span class="string">/tmp/file1</span> 备份磁盘内容到一个文件 </span><br><span class="line">tar -Puf backup.tar <span class="string">/home/user</span> 执行一次对 '<span class="string">/home/user</span>' 目录的交互式备份操作 </span><br><span class="line"><span class="params">( cd /tmp/local/ && tar c . )</span> | ssh -C user@ip_addr '<span class="keyword">cd</span> <span class="string">/home/share/</span> && tar x -p' 通过ssh在远程目录中复制一个目录内容 </span><br><span class="line"><span class="params">( tar c /home )</span> | ssh -C user@ip_addr '<span class="keyword">cd</span> <span class="string">/home/backup-home</span> && tar x -p' 通过ssh在远程目录中复制一个本地目录 </span><br><span class="line">tar cf - . | <span class="params">(cd /tmp/backup ; tar xf - )</span> 本地将一个目录复制到另一个地方,保留原有权限及链接 </span><br><span class="line">find <span class="string">/home/user1</span> -name '*<span class="string">.txt</span>' | xargs cp -av <span class="params">--target-directory=/home/backup/</span> <span class="params">--parents</span> 从一个目录查找并复制所有以 '<span class="string">.txt</span>' 结尾的文件到另一个目录 </span><br><span class="line">find <span class="string">/var/log</span> -name '*<span class="string">.log</span>' | tar cv <span class="params">--files-from=-</span> | bzip2 > log.tar.bz2 查找所有以 '<span class="string">.log</span>' 结尾的文件并做成一个bzip包 </span><br><span class="line">dd <span class="keyword">if</span>=<span class="string">/dev/hda</span> of=<span class="string">/dev/fd0</span> bs=512 count=1 做一个将 MBR <span class="params">(Master Boot Record)</span>内容复制到软盘的动作 </span><br><span class="line">dd <span class="keyword">if</span>=<span class="string">/dev/fd0</span> of=<span class="string">/dev/hda</span> bs=512 count=1 从已经保存到软盘的备份中恢复MBR内容 </span><br><span class="line"></span><br></pre></td></tr></table></figure></p>
<hr>
<p>#光盘<br><figure class="highlight jboss-cli"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"> </span><br><span class="line">cdrecord -v gracetime=2 dev=<span class="string">/dev/cdrom</span> -eject blank=fast -force 清空一个可复写的光盘内容 </span><br><span class="line">mkisofs <span class="string">/dev/cdrom</span> > <span class="keyword">cd</span>.iso 在磁盘上创建一个光盘的iso镜像文件 </span><br><span class="line">mkisofs <span class="string">/dev/cdrom</span> | gzip > <span class="keyword">cd</span>_iso.gz 在磁盘上创建一个压缩了的光盘iso镜像文件 </span><br><span class="line">mkisofs -J -allow-leading-dots -R -V <span class="string">"Label CD"</span> -iso-level 4 -o <span class="string">./cd.iso</span> data_<span class="keyword">cd</span> 创建一个目录的iso镜像文件 </span><br><span class="line">cdrecord -v dev=<span class="string">/dev/cdrom</span> <span class="keyword">cd</span>.iso 刻录一个ISO镜像文件 </span><br><span class="line">gzip -dc <span class="keyword">cd</span>_iso.gz | cdrecord dev=<span class="string">/dev/cdrom</span> - 刻录一个压缩了的ISO镜像文件 </span><br><span class="line">mount -o loop <span class="keyword">cd</span>.iso <span class="string">/mnt/iso</span> 挂载一个ISO镜像文件 </span><br><span class="line">cd-paranoia -B 从一个CD光盘转录音轨到 wav 文件中 </span><br><span class="line">cd-paranoia -- <span class="string">"-3"</span> 从一个CD光盘转录音轨到 wav 文件中(参数-3) </span><br><span class="line">cdrecord <span class="params">--scanbus</span> 扫描总线以识别scsi通道 </span><br><span class="line">dd <span class="keyword">if</span>=<span class="string">/dev/hdc</span> | md5sum 校验一个设备的md5sum编码,例如一张 CD </span><br><span class="line"></span><br></pre></td></tr></table></figure></p>
<hr>
<p>#网络 - (以太网和WIFI无线)<br><figure class="highlight tcl"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br></pre></td><td class="code"><pre><span class="line"> </span><br><span class="line">ifconfig eth0 显示一个以太网卡的配置 </span><br><span class="line">ifup eth0 启用一个 <span class="string">'eth0'</span> 网络设备 </span><br><span class="line">ifdown eth0 禁用一个 <span class="string">'eth0'</span> 网络设备 </span><br><span class="line">ifconfig eth0 <span class="number">192.168</span><span class="number">.1</span><span class="number">.1</span> netmask <span class="number">255.255</span><span class="number">.255</span><span class="number">.0</span> 控制IP地址 </span><br><span class="line">ifconfig eth0 promisc 设置 <span class="string">'eth0'</span> 成混杂模式以嗅探数据包 (sniffing) </span><br><span class="line">dhclient eth0 以dhcp模式启用 <span class="string">'eth0'</span> </span><br><span class="line">route -n show routing table </span><br><span class="line">route add -net <span class="number">0</span>/<span class="number">0</span> gw IP_Gateway configura default gateway </span><br><span class="line">route add -net <span class="number">192.168</span><span class="number">.0</span><span class="number">.0</span> netmask <span class="number">255.255</span><span class="number">.0</span><span class="number">.0</span> gw <span class="number">192.168</span><span class="number">.1</span><span class="number">.1</span> configure static route to reach network <span class="string">'192.168.0.0/16'</span> </span><br><span class="line">route del <span class="number">0</span>/<span class="number">0</span> gw IP_gateway remove static route </span><br><span class="line">echo <span class="string">"1"</span> > /<span class="keyword">proc</span>/sys/net/ipv4/ip_forward<span class="title"> activate</span> ip<span class="title"> routing</span> </span><br><span class="line">hostname<span class="title"> show</span> hostname<span class="title"> of</span> system </span><br><span class="line">host<span class="title"> www.example.com</span> lookup<span class="title"> hostname</span> to<span class="title"> resolve</span> name<span class="title"> to</span> ip<span class="title"> address</span> and<span class="title"> viceversa(1)</span> </span><br><span class="line">nslookup<span class="title"> www.example.com</span> lookup<span class="title"> hostname</span> to<span class="title"> resolve</span> name<span class="title"> to</span> ip<span class="title"> address</span> and<span class="title"> viceversa(2)</span> </span><br><span class="line">ip<span class="title"> link</span> show<span class="title"> show</span> link<span class="title"> status</span> of<span class="title"> all</span> interfaces </span><br><span class="line">mii-tool<span class="title"> eth0</span> show<span class="title"> link</span> status<span class="title"> of</span> 'eth0' </span><br><span class="line">ethtool<span class="title"> eth0</span> show<span class="title"> statistics</span> of<span class="title"> network</span> card 'eth0' </span><br><span class="line">netstat -tup<span class="title"> show</span> all<span class="title"> active</span> network<span class="title"> connections</span> and<span class="title"> their</span> PID </span><br><span class="line">netstat -tupl<span class="title"> show</span> all<span class="title"> network</span> services<span class="title"> listening</span> on<span class="title"> the</span> system<span class="title"> and</span> their<span class="title"> PID</span> </span><br><span class="line">tcpdump<span class="title"> tcp</span> port 80<span class="title"> show</span> all<span class="title"> HTTP</span> traffic </span><br><span class="line">iwlist<span class="title"> scan</span> show<span class="title"> wireless</span> networks </span><br><span class="line">iwconfig<span class="title"> eth1</span> show<span class="title"> configuration</span> of<span class="title"> a</span> wireless<span class="title"> network</span> card </span><br><span class="line">hostname<span class="title"> show</span> hostname </span><br><span class="line">host<span class="title"> www.example.com</span> lookup<span class="title"> hostname</span> to<span class="title"> resolve</span> name<span class="title"> to</span> ip<span class="title"> address</span> and<span class="title"> viceversa</span> </span><br><span class="line">nslookup<span class="title"> www.example.com</span> lookup<span class="title"> hostname</span> to<span class="title"> resolve</span> name<span class="title"> to</span> ip<span class="title"> address</span> and<span class="title"> viceversa</span> </span><br><span class="line">whois<span class="title"> www.example.com</span> lookup<span class="title"> on</span> Whois<span class="title"> database</span> </span><br><span class="line"></span><br></pre></td></tr></table></figure></p>
</div>
<div>
</div>
<div>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a class="post-title-link" href="/zh-Hans/2018-06-05-(一)hadoop-安装部署.html" itemprop="url">
(一)Hadoop 安装部署
</a>
</h1>
<div class="post-meta">
<span class="post-time">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time itemprop="dateCreated" datetime="2018-06-05T11:10:04+08:00" content="2018-06-05">
2018-06-05
</time>
</span>
<span class="post-category" >
|
<span class="post-meta-item-icon">
<i class="fa fa-folder-o"></i>
</span>
<span class="post-meta-item-text">分类于</span>
<span itemprop="about" itemscope itemtype="https://schema.org/Thing">
<a href="/categories/大数据技术/" itemprop="url" rel="index">
<span itemprop="name">大数据技术</span>
</a>
</span>
</span>
<span id="/zh-Hans/2018-06-05-(一)hadoop-安装部署.html" class="leancloud_visitors" data-flag-title="(一)Hadoop 安装部署">
|
<span class="post-meta-item-icon">
<i class="fa fa-eye"></i>
</span>
<span class="post-meta-item-text">阅读次数 </span>
<span class="leancloud-visitors-count"></span>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h1 id="部署环境说明"><a href="#部署环境说明" class="headerlink" title="部署环境说明"></a>部署环境说明</h1><ul>
<li>安装系统环境: centos7.4</li>
<li>hadoop版本:hadoop-2.6.0-cdh5.7.0</li>
<li>单主机伪分布式环境</li>
<li>官网文档地址:<a href="http://archive.cloudera.com/cdh5/cdh/5/hadoop/hadoop-project-dist/hadoop-common/SingleCluster.html" target="_blank" rel="noopener">hadoop单主机安装</a></li>
</ul>
<hr>
<h1 id="安装步骤"><a href="#安装步骤" class="headerlink" title="安装步骤"></a>安装步骤</h1><hr>
<h2 id="1-安装配置jdk环境"><a href="#1-安装配置jdk环境" class="headerlink" title="1. 安装配置jdk环境"></a>1. 安装配置jdk环境</h2><ul>
<li>查看预装jdk信息: <figure class="highlight vim"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">yum <span class="keyword">list</span> installed | <span class="keyword">grep</span> jdk</span><br></pre></td></tr></table></figure>
所得结果如下:<figure class="highlight stylus"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">copy-jdk-configs<span class="selector-class">.noarch</span> <span class="number">3.3</span>-<span class="number">10</span><span class="selector-class">.el7_5</span> @updates </span><br><span class="line"> java-<span class="number">1.7</span>.<span class="number">0</span>-openjdk<span class="selector-class">.x86_64</span> <span class="number">1</span>:<span class="number">1.7</span>.<span class="number">0.181</span>-<span class="number">2.6</span>.<span class="number">14.8</span><span class="selector-class">.el7_5</span> @updates </span><br><span class="line"> java-<span class="number">1.7</span>.<span class="number">0</span>-openjdk-headless<span class="selector-class">.x86_64</span> <span class="number">1</span>:<span class="number">1.7</span>.<span class="number">0.181</span>-<span class="number">2.6</span>.<span class="number">14.8</span><span class="selector-class">.el7_5</span> @updates </span><br><span class="line"> java-<span class="number">1.8</span>.<span class="number">0</span>-openjdk<span class="selector-class">.x86_64</span> <span class="number">1</span>:<span class="number">1.8</span>.<span class="number">0.171</span>-<span class="number">8</span><span class="selector-class">.b10</span><span class="selector-class">.el7_5</span> @updates </span><br><span class="line"> java-<span class="number">1.8</span>.<span class="number">0</span>-openjdk-headless<span class="selector-class">.x86_64</span> <span class="number">1</span>:<span class="number">1.8</span>.<span class="number">0.171</span>-<span class="number">8</span><span class="selector-class">.b10</span><span class="selector-class">.el7_5</span> @updates</span><br></pre></td></tr></table></figure>
</li>
</ul>
<ul>
<li>卸载预装jdk:<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-tag">yum</span> <span class="selector-tag">-y</span> <span class="selector-tag">remove</span> <span class="selector-tag">java-1</span><span class="selector-class">.7</span><span class="selector-class">.0-openjdk</span>*</span><br><span class="line"><span class="selector-tag">yum</span> <span class="selector-tag">-y</span> <span class="selector-tag">remove</span> <span class="selector-tag">java-1</span><span class="selector-class">.8</span><span class="selector-class">.0-openjdk</span>*</span><br></pre></td></tr></table></figure></li>
<li>安装openjdk1.8<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-tag">yum</span> <span class="selector-tag">-y</span> <span class="selector-tag">install</span> <span class="selector-tag">java-1</span><span class="selector-class">.8</span><span class="selector-class">.0-openjdk</span>*</span><br></pre></td></tr></table></figure></li>
<li>配置java环境变量<figure class="highlight crystal"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">export JAVA_HOME=<span class="regexp">/usr/lib</span><span class="regexp">/jvm/java</span>-<span class="number">1.8</span>.<span class="number">0</span></span><br><span class="line">export PATH=$JAVA_HOME/<span class="symbol">bin:</span>$PATH</span><br><span class="line">export CLASSPATH=.:$JAVA_HOME/<span class="class"><span class="keyword">lib</span>/<span class="title">dt</span>.<span class="title">jar</span>:$<span class="title">JAVA_HOME</span>/<span class="title">lib</span>/<span class="title">tools</span>.<span class="title">jar</span></span></span><br></pre></td></tr></table></figure>
</li>
</ul>
<hr>
<h2 id="2-配置ssh免密登陆"><a href="#2-配置ssh免密登陆" class="headerlink" title="2.配置ssh免密登陆"></a>2.配置ssh免密登陆</h2><ul>
<li>安装ssh服务(如果没有安装,centos默认安装了)<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">yum <span class="keyword">install</span> openssh-<span class="keyword">server</span> -y</span><br></pre></td></tr></table></figure></li>
<li>生成key(一路回车到结束,记住生成的目录,我的生成目录为/root/.ssh/id_rsa)<figure class="highlight ebnf"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="attribute">ssh-keygen -t rsa</span></span><br></pre></td></tr></table></figure></li>
<li>跳转到生成的key目录<figure class="highlight jboss-cli"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">cd</span> <span class="string">/root/.ssh</span></span><br></pre></td></tr></table></figure></li>
<li>拷贝id_rsa.pub<figure class="highlight awk"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">cp ~<span class="regexp">/.ssh/i</span>d_rsa.pub ~<span class="regexp">/.ssh/</span>authorized_keys</span><br></pre></td></tr></table></figure></li>
<li>验证本地免密登陆是否成功<figure class="highlight ebnf"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="attribute">ssh localhost</span></span><br></pre></td></tr></table></figure>
或 <figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-tag">ssh</span> 172<span class="selector-class">.168</span><span class="selector-class">.4</span><span class="selector-class">.44</span></span><br></pre></td></tr></table></figure>
(上面ip为服务器ip)</li>
</ul>
<hr>
<h2 id="3-下载安装hadoop"><a href="#3-下载安装hadoop" class="headerlink" title="3.下载安装hadoop"></a>3.下载安装hadoop</h2><h3 id="3-1下载并解压-hadoop-2-6-0-cdh5-7-0"><a href="#3-1下载并解压-hadoop-2-6-0-cdh5-7-0" class="headerlink" title="3.1下载并解压 hadoop-2.6.0-cdh5.7.0"></a>3.1下载并解压 hadoop-2.6.0-cdh5.7.0</h3> <figure class="highlight x86asm"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">cd /opt</span><br><span class="line">wget http://archive.cloudera.com/cdh5/<span class="number">cdh</span>/<span class="number">5</span>/hadoop-<span class="number">2.6</span><span class="meta">.0</span>-cdh5<span class="meta">.7</span><span class="meta">.0</span>.tar.gz</span><br><span class="line">tar -zxvf hadoop-<span class="number">2.6</span><span class="meta">.0</span>-cdh5<span class="meta">.7</span><span class="meta">.0</span>.tar.gz -C /opt</span><br></pre></td></tr></table></figure>
<h3 id="3-2-修改配置文件-基于hadoop-home目录"><a href="#3-2-修改配置文件-基于hadoop-home目录" class="headerlink" title="3.2 修改配置文件(基于hadoop_home目录)"></a>3.2 修改配置文件(基于hadoop_home目录)</h3><ul>
<li><p>目录etc/hadoop/hadoop-env.sh:</p>
<figure class="highlight routeros"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">修改<span class="builtin-name">export</span> <span class="attribute">JAVA_HOME</span>=<span class="variable">${JAVA_HOME}</span></span><br><span class="line">为<span class="builtin-name">export</span> <span class="attribute">JAVA_HOME</span>=/usr/lib/jvm/java-1.8.0</span><br></pre></td></tr></table></figure>
</li>
<li><p>目录etc/hadoop/core-site.xml:</p>
<figure class="highlight dts"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="params"><configuration></span></span><br><span class="line"> <span class="params"><property></span></span><br><span class="line"> <span class="params"><name></span>fs.defaultFS<span class="params"></name></span></span><br><span class="line"> <span class="params"><value></span>hdfs:<span class="comment">//localhost:8020</value></span></span><br><span class="line"> <span class="params"></property></span></span><br><span class="line"> <span class="params"><property></span></span><br><span class="line"> <span class="params"><name></span>hadoop.tmp.dir<span class="params"></name></span></span><br><span class="line"> <span class="params"><value></span><span class="meta-keyword">/home/</span>mm/tmp<span class="params"></value></span></span><br><span class="line"> <span class="params"></property></span></span><br><span class="line"><span class="params"></configuration></span></span><br></pre></td></tr></table></figure></li>