-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwarmup
More file actions
executable file
·375 lines (295 loc) · 17.1 KB
/
warmup
File metadata and controls
executable file
·375 lines (295 loc) · 17.1 KB
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
#!/usr/bin/env bash
set -euo pipefail
# ────────────────────────────────────────────────────────────────
# INTRO – MAN PAGES & SELF-RELIANCE
# ────────────────────────────────────────────────────────────────
clear
cat << "EOF"
=============================================
WELCOME TO THE LINUX DAILY WARM-UP
=============================================
Good morning, intern. As you know, AI created Skynet some years ago
and humankind had to ban it. We need to make sure you don't need it to perform.
It's only allowed for Senior engineers.
We do NOT Google or ask AI for commands.
We use the tools the system gives us.
Prove you can find and read information without exiting the terminal
while solving the following challenges, and you will get the job.
Fail, and you're out.
──────────────────────────────────────────────────────────────────────
EOF
read -r -p "Press Enter to accept the challenge..."
clear
cat << "EOF"
Before we throw real tasks at you, two quick tools you must master.
These are how every good engineer finds and understands commands.
1. Finding unknown commands: apropos (or man -k)
apropos searches the short descriptions of all installed man pages.
Examples:
apropos network
apropos "list contents"
2. Reading man pages: man <command>
Inside a man page:
────────────────────────────────────────────────────────────────
Key Action
────────────────────────────────────────────────────────────────
Space or f Move forward one full screen
b Move backward one full screen
j Move down one line
k Move up one line
h Move to the left
l Move to the right
/word Search forward for 'word'
?word Search backward for 'word'
n Jump to next search match
N Jump to previous search match
g Jump to the very top of the page
G Jump to the very bottom
────────────────────────────────────────────────────────────────
EOF
read -r -p "Press Enter to continue..."
# ────────────────────────────────────────────────────────────────
# SETUP – CONNECT TO YOUR WORKSTATION
# ────────────────────────────────────────────────────────────────
clear
cat <<EOF
═══════════════════════════════════════════════════════════════
ONBOARDING
═══════════════════════════════════════════════════════════════
Before you touch production systems, you need a proper workspace.
Your homelab is your training ground.
We're going to connect and secure it properly, the way real engineers do.
SSH into your own homelab manually.
If you have an SSH config for your homelab, delete it.
We're building muscle memory.
1. Generate a pair of SSH keys in your local machine
2. Define an SSH host alias on your homelab
3. Add your public key to the authorized keys on the server
4. Make sure password login is disabled on your homelab
──────────────────────────────────────────────────────────────────────
EOF
read -r -p "Press Enter to continue..."
# ────────────────────────────────────────────────────────────────
# Tmux Gymnastics — Linux Muscle Memory
# ────────────────────────────────────────────────────────────────
clear
cat <<EOF
Intern, show me you know how to install and manage packages
1. List all packages on the system, find if tmux is installed
2. If tmux is installed, uninstall it and its depedencies
3. Install tmux fresh
Now prove you didn't just apt install and pray.
In the real world, binaries hide. Old versions linger. Aliases exist.
- If we ran tmux right now, how to find the file or thing the shell would run?
- What if there's an alias? How to find eveything the shell knows about a name?
──────────────────────────────────────────────────────────────────────
EOF
read -r -p "When you answer those questions, and know what commands use to do so,
press Enter..."
clear
cat <<EOF
═══════════════════════════════════════════════════════════════
TMUX NAVIGATION WARMUP
═══════════════════════════════════════════════════════════════
Create a 'tutor' session and split it vertically.
Run linuxtutor in one of them from now on, and run the challenges
on your homelab on the other session.
Now, prove you can actually live in tmux without crying for mouse or custom bindings.
You'll find your own workflow style the more you use it.
Show me you know the basics though:
- Detach from the session
- Create more sessions, navigate among them. Get comfortable!
- List all tmux sessions
- Re-attach to your 'tutor' session
──────────────────────────────────────────────────────────────────────
EOF
read -r -p "When you have all set, press Enter to start the challenge..."
clear
cat <<EOF
Task 1/9
─────────
Before you touch anything, find out who you really are
on this system. Use four different commands.
Self-check:
- One command shows just your username.
- One shows who is currently logged in.
- One shows a more detailed view of logged-in users, what they are doing, and CPU usage.
- One shows your user ID, main group, and secondary groups.
──────────────────────────────────────────────────────────────────────
EOF
read -r -p "When you have run all four commands and understand the differences
between their outputs, press Enter to continue..."
# ────────────────────────────────────────────────────────────────
# Task 2 – Temporary user
# ────────────────────────────────────────────────────────────────
clear
cat <<EOF
Task 2/9
─────────
Let's start with some Linux gymnastics...
1. Create a temporary user called 'tempuser' (with home dir).
2. Ops! Change its username to 'tmpuser', update its home directory as well.
3. Create a file owned by tmpuser, set it to: owner rw, group r, others nothing.
(Use octal permissions mode always!).
4. Finally — delete tmpuser completely (including home).
──────────────────────────────────────────────────────────────────────
EOF
read -r -p "When you're ready, continue..."
# ────────────────────────────────────────────────────────────────
# Task 3 – Timmy
# ────────────────────────────────────────────────────────────────
clear
cat <<EOF
Task 3/9
─────────
Now, create another user for the other intern: 'timmy'.
Make sure he has a home directory and proper bash shell.
Then — create three files inside his home directory with these permissions:
1. secret.txt → (only owner rw)
2. report.txt → (owner rw, group+others r)
3. script → (owner rwx, group+others rx)
Self-check you MUST perform:
- List the files in long format to verify all is correct
──────────────────────────────────────────────────────────────────────
EOF
read -r -p "Press Enter to continue..."
# ────────────────────────────────────────────────────────────────
# Task 4 – Give Timmy sudo...
# ────────────────────────────────────────────────────────────────
clear
cat <<EOF
Task 4/9
─────────
Timmy just told me he needs sudo permissions to do something...
Never take things like this lightly!
Timmy is a good guy though, it's fine. Just do it.
Add him to the sudo (or wheel) group
Self-check:
- Check timmy's groups → confirm sudo/wheel is there
- If missing → fix and check again
(Open a new SSH connection to your homelab, but now with the timmy's user,
and open an instance of vim to simulate he is doing something)
──────────────────────────────────────────────────────────────────────
EOF
read -r -p "When you're done, continue..."
# ────────────────────────────────────────────────────────────────
# Task 5 – Read important /etc files
# ────────────────────────────────────────────────────────────────
clear
cat <<EOF
Task 5/9
─────────
Intern!
a) What pretty name does this OS/distribution have?
b) Print the names of the users who have a bash shell assigned (use pipes)
c) What makes the sudo/wheel groups special?
──────────────────────────────────────────────────────────────────────
EOF
read -r -p "Once you answered all, continue..."
# ────────────────────────────────────────────────────────────────
# Task 6 - Find & Locate
# ────────────────────────────────────────────────────────────────
clear
mkdir -p ~/sandbox/day1/logs/{app,system}
cat > ~/sandbox/day1/logs/app/error.log <<'END'
2024-01-01 10:00:00 INFO Application started successfully
2024-01-01 10:05:12 ERROR Database connection failed
2024-01-01 10:05:15 WARNING Retrying connection...
2024-01-01 10:10:00 INFO Connection established
2024-01-01 10:15:22 ERROR File not found: config.yaml
2024-01-01 10:20:00 INFO Processing complete
END
cat > ~/sandbox/day1/logs/app/access.log <<'END'
192.168.1.100 - GET /home 200
192.168.1.105 - POST /login 401
192.168.1.100 - GET /dashboard 200
END
cat > ~/sandbox/day1/logs/system/kernel.log <<'END'
Kernel boot complete
INFO: System initialized
WARNING: Deprecated driver loaded
END
touch ~/sandbox/day1/logs/app/debug.log # empty
touch ~/sandbox/day1/logs/system/messages.log # empty
cat <<EOF
Task 6/9
─────────
Show me you know how to find files efficiently through the system
1. Find the path to the passwd executable
2. List all .log files in ~/sandbox
3. Then, using the previous result, show all lines containing "ERROR" (case-insensitive)
with 1 line of context before and after each match
4. List all lines from .log files that do NOT contain "INFO" (case-insensitive)
5. Find and list all empty .log files under ~/sandbox/day1
──────────────────────────────────────────────────────────────────────
EOF
read -r -p "Continue when ready..."
# ────────────────────────────────────────────────────────────────
# Task 7 - Text Processing & Pipes
# ────────────────────────────────────────────────────────────────
clear
cat > ~/sandbox/data.txt << 'END'
Kubernetes is an open-source container orchestration platform.
Docker is a platform for developing and running containers.
Bash is the default shell on most Linux distributions.
Python is a high-level interpreted programming language.
Ansible is an agentless automation tool using SSH.
Terraform is an infrastructure as code tool by HashiCorp.
Prometheus is a monitoring and alerting toolkit.
Golang is a statically typed compiled language by Google.
Kubernetes uses YAML manifests to define resources.
Docker uses images to create lightweight containers.
END
cat <<EOF
Task 7/9
─────────
Let's see your text manipulation and pipe skills
Using this file: ~/sandbox/data.txt
1. Sort the file alphabetically and remove duplicates
2. Count how many lines contain the word "Kubernetes".
3. Show lines that contain either "Docker" or "Kubernetes" (case-sensitive)
4. Show lines that do NOT contain "Python" nor "Bash".
5. Count the total of words in lines containing "Kubernetes"
EOF
read -r -p "When your pipeline-fu is proven, continue..."
# ────────────────────────────────────────────────────────────────
# Task 8 - Process Management
# ────────────────────────────────────────────────────────────────
clear
cat <<EOF
Task 8/9
─────────
Master the running system.
1. Start a sleep process in background: sleep 300 &
2. List ALL running processes on the system (not just yours).
3. Find the PID of your sleep process using pgrep.
4. Politely terminate it (let it clean up).
5. Verify it's gone.
BONUS: Bring a background job to foreground, then send it back.
When processes obey your commands,
press Enter...
EOF
read -r -p ""
# ────────────────────────────────────────────────────────────────
# Task 9 - Service Management with systemd
# ────────────────────────────────────────────────────────────────
clear
cat <<EOF
Task 9/9
─────────
The final test: control the system itself.
1. Check if the cron service is running (systemctl).
2. View the last 20 log lines for cron (journalctl).
3. Stop the cron service (don't worry, we'll restart it).
4. Check status again — confirm it's stopped.
5. Start it again and verify.
Self-check:
- Service runs at boot? Check with is-enabled.
- What's the difference between stop and disable?
When you've mastered systemd,
press Enter...
EOF
read -r -p ""
cat <<EOF
Coming soon: Networking, system monitoring, and Bash Scripting
EOF