summaryrefslogtreecommitdiff
path: root/handouts/trial
blob: abb750bab1a9eb17451dbeaa4cb68f2e12ee9716 (plain)
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
- - - - - - ---=[Urbana Electronics & Programming Summer Program]=--- - - - - -
[Trial Session 2/23/2018]
TOPIC 1 - Linux System Maintenance

[Section 1, SSH]----------------------------------------------------------------
	Welcome to UEPSP, today you will learn how to use a remote shell.
First off, what is a shell? On UNIX systems, the shell is the program you use to
interact with the computer. It's the outermost layer of the Operating System,
hence the name shell. On windows, the shell is called the command prompt.

	Specifically, you will be learning to use Bash(the shell) on Linux(the
operating system)

	You might not be running a unix system, and you might not have the
proper tools set up on your computer if you do. That's why I've set things up so
that you can use the shell on my computer, through your computer. This is called
a remote shell, remote meaning far away, or not the computer you're currently
using.

	There are many protocols for remote shells, such as telnet or ssh. We
will be using ssh today. To start off, download an ssh client. The client is the
program you run on my computer, that talks with the program running on my
computer, the server.

	---If you are running Windows, go to:
		https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html
		
		click on "putty.exe", under "Alternative Binary Files". Ask your
		me whether to use the 32 bit or 64 bit version.
		
		After the executable(program) has been downloaded, click on it.
			If it asks "Do you want to run this program", click run.
		
		in the text box titled "Host Name(or IP address)" type the ip
		address on the login slip I gave you.
		
		in the box next to it titled "Port", type the port on the login
		slip.

		Finally click "Open" and you should see a black window appear.

		If says "The authenticity of host ......", click yes

		The window should say "login as:", type in your username and
		press enter.
		
		Do you see Ducky?

	---If you are running Mac or Linux
		Congratulations, you should already have ssh installed!
		simply find the "terminal" program, and run that.

		A black box should come up, this is the terminal, and it is
		running the shell for your computer. However you want to run the
		shell on my computer.

		it should look something like this:
                +--------------------------------------------------------------+
		|[ducky@pond ~]$ 					       |
		|							       |
		|							       |
		|							       |
                +--------------------------------------------------------------+

		now to run ssh, you have to run a command, type in the command:
		"ssh -p [port] [username]@[ip]", replace [port] [username] and
		[ip] with what's on the login slip I handed you.

		For example, if the port is 1235, your username is ducky and
		the ip address is 123.456.7.89, you should type:

                +--------------------------------------------------------------+
		|[ducky@pond ~]$ssh -p 5535 ducky@123.456.7.89                 |
		|							       |
		|							       |
		|							       |
                +--------------------------------------------------------------+

		press enter, it should ask "The authenticity of host ....", type
		"yes" and press enter

		+--------------------------------------------------------------+
		|[ducky@pond ~]$ssh -p 5535 ducky@123.456.7.89                 |
		|The authenticity of host '123.456.7.89' can't be established  |
		|ECDSA key fingerprint is                                      |
		|SHA256:yUDWcwEryMjEyrK9ajHogibqgLuSd3Y/orHF1BEbJeE.           |
		|Are you sure you want to continue connecting (yes/no)?yes     |
		|							       |
		|							       |
                +--------------------------------------------------------------+

		do you see ducky?

	So what did we just do? Well to start off, you downloaded an ssh client,
this connects to an ssh server on my computer. When you type things into the ssh
client, it gets sent to the shell on my computer, and the output gets sent back
to you.

	In order to connect to my computer, you need to know where it is. That's
where the IP address comes in. An IP address is the location of a computer on a
network, just like your house has an address that tells you where it is in town.
In this case, we're all on the same local network, my wifi. The IP address on
the slip is therefore a local ip.

	A computer has to handle a whole lot of connections at once, so to know
what kind of thing it's connecting to, they use ports. For example, if you
wanted to connect to a minecraft server, it would be on port 25565. The standard
port for ssh is 22, but I changed it for security purposes.

	Ok now that you're connected to my ssh server, you should see ducky,
type your password and press enter. please remember that you won't see your
password when you type it. You should see something like the below:

+------------------------------------------------------------------------------+
|WELCOME TO URBANA UEPSP!                                                      |
|/----------------------\                                                      |
||    __      ducky     |                                                      |
||  <(o )___  says      |                                                      |
||   ( ._> /  hello     |                                                      |
||    `---'             |                                                      |
|\----------------------/                                                      |
|ducky@123.456.7.89's password:                                                |
+------------------------------------------------------------------------------+

finally you should now see something like this


+------------------------------------------------------------------------------+
|WELCOME TO URBANA UEPSP!                                                      |
|/----------------------\                                                      |
||    __      ducky     |                                                      |
||  <(o )___  says      |                                                      |
||   ( ._> /  hello     |                                                      |
||    `---'             |                                                      |
|\----------------------/                                                      |
|ducky@123.456.7.89's password:                                                |
|Last login: Fri Feb 23 22:19:43 2018 from 987.654.3.21                        |
|[ducky@otherpond ~]$                                                          |
+------------------------------------------------------------------------------+

Congratulations! you've opened a remote shell! You can now type commands that
will be run on my computer.

[Section 2, Bash]---------------------------------------------------------------

	Ok, so now you have a shell, but what is a shell? The shell is a program
that takes commands you type in, and runs them. There are many different kinds
of shells and the one you are running is called bash.

	To start off, let's type your first command, "help" and press enter.

+------------------------------------------------------------------------------+
|WELCOME TO URBANA UEPSP!                                                      |
|/----------------------\                                                      |
||    __      ducky     |                                                      |
||  <(o )___  says      |                                                      |
||   ( ._> /  hello     |                                                      |
||    `---'             |                                                      |
|\----------------------/                                                      |
|ducky@123.456.7.89's password:                                                |
|Last login: Fri Feb 23 22:19:43 2018 from 987.654.3.21                        |
|[ducky@otherpond ~]$help                                                      |
+------------------------------------------------------------------------------+

You should see something like the below afterwards:

+------------------------------------------------------------------------------+
|WELCOME TO URBANA UEPSP!                                                      |
|/----------------------\                                                      |
||    __      ducky     |                                                      |
||  <(o )___  says      |                                                      |
||   ( ._> /  hello     |                                                      |
||    `---'             |                                                      |
|\----------------------/                                                      |
|ducky@123.456.7.89's password:                                                |
|Last login: Fri Feb 23 22:19:43 2018 from 987.654.3.21                        |
|[ducky@otherpond ~]$help                                                      |
|GNU bash, version 4.4.12(1)-release (x86_64-unknown-linux-gnu)                |
|These shell commands are defined internally.  Type `help' to see this list.   |
|Type `help name' to find out more about the function `name'.                  |
|Use `info bash' to find out more about the shell in general.                  |
|Use `man -k' or `info' to find out more about commands not in this list.      |
|                                                                              |
|                                    ...                                       |
+------------------------------------------------------------------------------+

	Wow, that's a lot of text! to get rid of it, type "clear". You should
see something like the below:

+------------------------------------------------------------------------------+
|[ducky@otherpond ~]$                                                           |
|                                                                              |
+------------------------------------------------------------------------------+

	Now let's introduce the concept of working directories. When using a shell,
you're always in a certain directory(folder), that directory is called the
current working directory. The name of the directory is right after your
username, in this case it's "~". That's actually an abbreviation which means
your home directory. Your home directory where all your personal files go.

	To find out what's in a directory, simply type the command "ls". Nothing
comes up because your directory is empty.

	Directories have full names called "paths" that tell you it's exact
location. To find the path of your current working directory, type "pwd"

	You should see something like "/home/ducky"

	Now you know where home is!

	So what is this path? well first off, it starts off with the root
directory, which is written as "/". This is the directory everything is in.
Inside of that is the "home" directory, where all the homes are. Finally inside
of that is your home directory, "ducky".

	When a directory is inside of another directory, it is considered
"below" it. If a directory includes another directory, it is considered "above"
it.

	Ok but how do you move around? well that's simple, you type the command
"cd"(short for change directory) and the name or path of a directory. for
example if you want to move to the directory above your home, "/home", type:
	
	cd ..

					or

	cd /home

	cd takes in other information called arguments, which it uses to carry
out it's task. In this case, this could either be the full path of "home", which
is "/home". In another case, we type it's name "..".

	When you type the name of a directory, it's assumed that that directory
is a "local directory", or directory under your current directory. But hold on,
you said "home" was above my local directory! Well, that's why you don't type
"home". ".." is the name of the directory above the current directory, which in
this case is /home""

	Now type "ls" again, you shoul see a lot of directories now. You can see
your home directory, and everyone else's too!

	ok now try going to somebody else's home, type:

	cd knolax

	It'll come up with an error, something like:

	-bash: cd: knolax: Permission denied

	That's because you don't have permission. See that's somebody else's
directory, and it's owned by knolax. You can only access files that you own, or
that others own but give you permission to use. We'll go into permissions later
on.

	Ok, let's go home, type:

	cd ~

	Remember, ~ is an abbreviation for home. so when you type cd ~, you're
changing direcory to home.

	How do I make directories? well, that's the final command you'll learn
today, "mkdir".

	type the command:

	mkdir code

	Now you've made a directory named code insie of your home directory.

	type "ls" and you should see "code"
[END OF SECTION 2]--------------------------------------------------------------

Section 3 well be given to you by teacher instruction.