-
Notifications
You must be signed in to change notification settings - Fork 0
/
bash.html
170 lines (127 loc) · 3.93 KB
/
bash.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
<html>
<head>
<!-- makes browser more consistent -->
<link rel="stylesheet" href="css/normalize.css">
<!-- necessary for rainbow js -->
<link rel="stylesheet" href="css/solarized-light.css">
<!-- cheatsheet specific stylesheets -->
<link rel="stylesheet" href="css/cheatsheet.css">
</head>
<body>
<h1>Bash</h1>
<div class="container">
<article>
<h2>Link</h2>
<a href="http://explainshell.com/">http://explainshell.com - Type in a command to see the help text for it's arguments</a>
</article>
<article>
<h2>Configuration</h2>
<dl>
<dt><code>/etc/profile</code></dt>
<dd>generic system-wide profile</dd>
<dt><code>.bash_profile</code></dt>
<dd>processed every time I login (e.g. via ssh, console, ...)</dd>
<dt><code>.bashrc</code></dt>
<dd>processed every time I open a non-login shell (e.g. xterm)</dd>
</dl>
<hr/>
<p>Call .bashrc from .bash_profile:
<code class="multiline" data-language="shell">if [ -f ~/.bashrc ]
then
~/.bashrc
fi</code>
</p>
</article>
<article>
<h2>Keyboard Shortcuts</h2>
<table class="nowrap_first_column">
<tr>
<td><kbd>Ctrl</kbd> + <kbd>A</kbd></td>
<td>Go to the beginning of the line</td>
</tr>
<tr>
<td><kbd>Ctrl</kbd> + <kbd>E</kbd></td>
<td>Go to the end of the line</td>
</tr>
<tr>
<td><kbd>Ctrl</kbd> + <kbd>L</kbd></td>
<td>Clear the screen</td>
</tr>
<tr>
<td><kbd>Ctrl</kbd> + <kbd>R</kbd></td>
<td>Search through previously used commands</td>
</tr>
<tr>
<td><kbd>Ctrl</kbd> + <kbd>Z</kbd></td>
<td>Puts the current process into the background. Run <code>fg</code> to restore it.</td>
</tr>
<tr>
<td><kbd>Ctrl</kbd> + <kbd>K</kbd></td>
<td>Delete everything after the cursor</td>
</tr>
<tr>
<td><kbd>Ctrl</kbd> + <kbd>U</kbd></td>
<td>Delete everything before the cursor</td>
<tr>
<tr>
<td><kbd>Ctrl</kbd> + <kbd>T</kbd></td>
<td>Swap the two characters before the cursor</td>
</tr>
<tr>
<td><kbd>Tab</kbd></td>
<td>Autocomplete</td>
</tr>
</table>
</article>
<article>
<h2>Alias</h2>
<dl>
<dt><code>alias ls="ls -l"</code></dt>
<dd>Calls <code>ls -l</code> every time I run <code>ls</code></dd>
<dt><code>unalias ls</code></dt>
<dd>Removes previous alias</dd>
<dt><code>alias -p</code></dt>
<dd>Print all aliases</dd>
</dl>
</article>
<article>
<h2>Processes</h2>
<dl>
<dt><code>jobs</code></dt>
<dd>Lists all background processes and there jobspec</dd>
<dt><code>ps</code></dt>
<dd>Lists all processes and there pid</dd>
<dt><kbd>Ctrl</kbd> + <kbd>Z</kbd></dt>
<dd>Puts the current process into the background</dd>
<dt><code>fg [%jobspec]</code></dt>
<dd>Puts process in the foreground</dd>
<dt><code>bg [%jobspec]</code></dt>
<dd>Puts process in the background</dd>
<dt><code>cp bigfile target <strong>&</strong></code></dt>
<dd>Runs copy process in the background</dd>
<dt><kbd>Ctrl</kbd> + <kbd>C</kbd></dt>
<dd>Kill the current foreground process</dd>
<dt><code>kill -15 %jobspec|pid</code></dt>
<dd>Shutdown the process orderly.</dd>
<dt><code>kill -9 %jobspec|pid</code></dt>
<dd>Kill the process mercilessly</dd>
</dl>
</article>
<article>
<h2>Quoting</h2>
<dl>
<dt>Backslash: <code>\</code></dt>
<dd>Escape character</dd>
<dt>Single quote: <code>'string'</code></dt>
<dd>Every character stands for itself. No escape character</dd>
<dt>Double quote: <code>"string"</code></dt>
<dd><code>$</code>, <code>`</code>, <code>\</code>, <code>!</code>, <code>*</code> and <code>@</code> have a special meaning</dd>
<dt>ANSI-C$'string'
</dl>
</article>
</div>
<!-- syntax highlighting -->
<script src="js\cheatsheet.js"></script>
<script src="js\rainbow-custom.min.js"></script>
</body>
</html>