forked from marioa/2013-12-03-edinburgh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHintsAndTips.html
executable file
·132 lines (127 loc) · 3.08 KB
/
HintsAndTips.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
---
layout: lesson
root: .
title: Hints and tips
---
<h2>Getting help about a command - <code>man</code> pages</h2>
<p>
Type:
</p>
<pre>
$ man COMMAND
</pre>
<p>
For example:
</p>
<pre>
$ man ls
$ man grep
$ man git
</pre>
<p>
The up and down arrows on your keyboard allow you to scroll up and down the page.
</p>
<p>
To exit from the <code>man</code> page, press <code>q</code>.
</p>
<h2>Auto-completion</h2>
<p>
Bash shells support what is called <em>tab completion</em>. If you type part of a command or file name, then press TAB, it will show the commands or files that match that prefix of the command. For example, if you type:
</p>
<pre>
$ gre
</pre>
<p>
then, without pressing ENTER, you press TAB you should see something like
</p>
<pre>
$ gre
greadelf grep grepjar
grefer grep-changelog
</pre>
<p>
which are all the commands that match <code>gre</code>. This also works for files. For example, if you type:
</p>
<pre>
$ ls dat
</pre>
<p>
then, without pressing ENTER, you press TAB you should see a list of all the files that start with <code>dat</code>. If there is only one, then the file name will be auto-completed e.g.
</p>
<pre>
$ ls data.txt
</pre>
<h2>Command history, or avoid having to retype commands</h2>
<p>
Bash shells support a command history - they record every command you type in. If you use up-arrow, or <code>CTRL-P</code>, at the command prompt you can scroll back to the previous command you executed. Down-arrow, or <code>CTRL-N</code>, allows you to scroll to the next command.
</p>
<p>
You can then move the cursor and edit the command. To move the cursor in the line you can do:
</p>
<ul>
<li>Left, <code>CTRL-B</code></li>
<li>Right, <code>CTRL-F</code></li>
<li>To the start of the line, <code>CTRL-A</code></li>
<li>To the end of the line, <code>CTRL-E</code></li>
</ul>
<p>
If you enter:
</p>
<pre>
$ history
</pre>
<p>
You'll see a list of the commands in the history. Each has a number. If you enter:
</p>
<pre>
$ !NNN
</pre>
<p>
where <code>NNN</code> is the number of a command in the history, that command will be rerun.
</p>
<p>
To search for a command that you've run before you can do:
</p>
<pre>
$ history | grep "COMMAND"
</pre>
<p>
For example:
</p>
<pre>
$ history | grep "ls"
</pre>
<h2>A quick-start guide to the <code>nano</code> editor</h2>
<p>
nano is a simple text editor for Linux/Unix.
</p>
<p>
To start:
</p>
<pre>
$ nano file.txt
</pre>
<p>
To move the cursor:
</p>
<ul>
<li>Left, <code>CTRL-B</code></li>
<li>Right, <code>CTRL-F</code></li>
<li>Up a line, <code>CTRL-P</code></li>
<li>Down a line, <code>CTRL-N</code></li>
<li>To the start of the line, <code>CTRL-A</code></li>
<li>To the end of the line, <code>CTRL-E</code></li>
</ul>
<p>
To delete and undelete a line:
</p>
<ul>
<li>Delete the current line, <code>CTRL-K</code></li>
<li>Undelete the recently deleted lines, <code>CTRL-U</code></li>
</ul>
<p>
To save a file, <code>CTRL-O</code>. You will be given the opportunity to edit the file name to save the file under a different name.
</p>
<p>
To quit, <code>CTRL-X</code>. If the file has unsaved changes you'll be given the chance to save them now.
</p>