-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathtraininingnotes
More file actions
472 lines (252 loc) · 7.4 KB
/
traininingnotes
File metadata and controls
472 lines (252 loc) · 7.4 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
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
m
Linux Administration Training
ssh based authentication: https://stackoverflow.com/questions/66452084/ssh-authentication-process
Lab1:
1) You should know the basic commands
#How to create a directory
mkdir testing
# How to go inside the directory
cd testing
#Create a empty file
touch readme
#See contents of file
cat readme
#List all file
ls
ls -ltr
ls -la
# How to come out from directory
cd ..
#Help page of any command
man cat
man ls
man mkdir
----------------
Selinux vs apparomor
https://www.techtarget.com/searchdatacenter/tip/Compare-two-Linux-security-modules-SELinux-vs-AppArmor
Lab
#udpate the pacakge list
sudo apt-get update
#Install package
sudo apt-get install apache2
#remove the package
sudo apt-get remove apache2
#Redhat/centos linux dnf
Lab 4:
sudo adduser training
#It will prompt for password.. provide any passowrd
#Login to the user
su training
#try below activty
sudo apt-get update
#It will give an error
training is not in the sudoers file
--------------------
Lab 5:
https://github.com/
#Press i <insert mode>
training ALL=(ALL:ALL) ALL
#You need to press esc+:+wq+! (escape colon wq !)
#Now test
su training
sudo apt-get update
------------------
Day2: 07/05/25
lab 1:
https://www.redhat.com/en/blog/introduction-vi-editor
1) If i want to open a file using vi:[ If file is there, it will open that one, or else it will create new file
vi testfile.sh
2) If you want add something, you will enable the insert mode by pressing "i"
3) Then if you want to save it, come out from the insert mode by pressing: esc
4) If you want to save file :wq+enter
5) If you don't want to save file :q!
Lab2:
1) vi test.sh
2) Insert mode using "i"
3) type the below code
#!/bin/bash
ls /tmp
date
echo "Hi i am amit"
4) Save it esc+:+wq
5)
chmod +x test.sh
6)
./test.sh
bash test.sh
#!/bin/bash
package="apache2"
echo -n "Do you want to install the package?(y/n):"
read answer
if[ "$answer" == "y" ]; the
sudo apt-get update
sudo apt-get -y $package
eles
echo "not installing"
fi
---------------------------
Lab2
mkdir gitlearning
cd gitlearning
git --version
git status
git init
git status
---------
Lab3
setup your username and email id
git config --global user.name amit
git config --global user.email amit@ow.com
touch test.sh
git status
git add test.sh
git status
git commit -m "firstcommit"
git log
git status
Lab link:https://www.openwriteup.com/?page_id=1075
09/05
Sure! Here's a cleaned-up version of the Git Bash steps, using an RSA SSH key instead of ed25519 and with no emojis or custom icons.
Git Bash Steps to Generate RSA Key and Upload to GitHub
1. Generate an RSA SSH Key
Open Git Bash and run:
ssh-keygen -trsa -b 4096 -C "your_email@example.com"
Press Enter to accept the default file location: ~/.ssh/id_rsa
Enter a passphrase (optional)
Then display and copy the public key:
cat ~/.ssh/id_rsa.pub
2. Add SSH Key to GitHub
Go to https://github.com
Click your profile photo, then Settings
Go to SSH and GPG keys
Click New SSH key
Paste the copied public key
Click Add SSH key
3. Create a Repository on GitHub
Choose Public or Private
Leave "Initialize this repository with a README" unchecked
Click Create repository
4. Set Up Local Repository with Git Bash
cd /path/to/your/projects
Visit https://github.com/new
Enter the repository name, e.g., my-first-repo mkdir my-first-repo
cd my-first-repo
git init
touch README.md
git add README.md
git commit -m "Initial commit"
5. Connect to GitHub and Push
Replace your-username with your actual GitHub username:
git remote add origin git@github.com:your-username/my-first-repo.git
git push -u origin master
If your GitHub repository defaults to the main branch instead of master, use:
git branch -M main
git push -u origin main
1. L1 - In EC2 Ubuntu Instance Create a new user
and SSH Key pair with an authorized key
https://usercontent.one/wp/www.openwriteup.com/wp-content/uploads/2023/09/aws-instance-1.pdf?media=1728024675
2. L2 - As a Linux root user Create Files/Directory
in the same Instance and change the ownership to
a new user
1. Create a New User
useradd newuser
passwd newuser
2. Create Files and Directories as root
mkdir /opt/mydir
touch /opt/mydir/file1.txt /opt/mydir/file2.txt
3. Change Ownership to the New User
chown -R newuser:newuser /opt/mydir
The -R option applies the change recursively to all contents.
4. Verify Ownership
ls -l /opt/mydir
Expected output:
-rw-r--r-- 1 newuser newuser 0 May 9 12:00 file1.txt
-rw-r--r-- 1 newuser newuser 0 May 9 12:00 file2.txt
3. L3 - In EC2 Ubuntu Instance Create Files and
Directories and Grand R/W/X Access only to the
Owner and User Group
Task: Create Files and Directories on EC2 Ubuntu, Set Permissions for Owner and Group Only
1. SSH into Your EC2 Ubuntu Instance
ssh -i /path/to/your-key.pem ubuntu@your-ec2-public-dns
2. Create a Directory and Files
mkdir /home/ubuntu/projectL3
cd /home/ubuntu/projectL3
# Create sample files
touch file1.txt file2.txt
# Optional: Create a subdirectory
mkdir subdir
3. Create or Use a User Group
Create a new group (or use an existing one):
sudo groupadd projectgroup
Add current user (ubuntu) to the group:
sudo usermod -aG projectgroup ubuntu
You may need to log out and back in for group changes to take effect.
4. Change Group Ownership
sudo chgrp -R projectgroup /home/ubuntu/projectL3
5. Set Permissions: R/W/X for Owner and Group Only
chmod -R 770 /home/ubuntu/projectL3
Explanation of 770:
Owner: read (r), write (w), execute (x)
Group: read (r), write (w), execute (x)
Others: no access (---)
6. Verify Permissions
ls -l /home/ubuntu/projectL3
You should see something like:
-rwxrwx--- 1 ubuntu projectgroup 0 May 9 12:00 file1.txt
-rwxrwx--- 1 ubuntu projectgroup 0 May 9 12:00 file2.txt
4. L4 - In EC2 Ubuntu Instance install JDK and
sudo apt update
setup JAVA_HOME path environment variable
sudo apt install -y openjdk-17-jdk
export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
export PATH=$JAVA_HOME/bin:$PATH
5. L5 - Create two AWS EC2 Ubuntu Instances to
establish SSH Connection and SCP the files from
one Instance to another instance
6. L6 - Write a Linux Shell Script to Install Git, JDK,
Maven in EC2 Ubuntu Instance
#!/bin/bash
sudo apt-get install git
sudo apt-get install openjdk-17
13/05
Assignment
cicd-->scm
-- Create a directory
sudo su
mkdir testrepo
-- Convert that directory into git repo
cd testrepo
git init
-- Create a file
touch readme
-- add and commit the file
git config --global user.name=amit
git config --global user.email=a@ow.com
git add .
git commit -m "add"
ssh-keygen -t rsa
cat /root/.ssh/id_rsa.pub
-- Create a remote GitHub repo
Login to git and create repo
-- Copy the public key from linux box (cat command) and paste in github
-- Using ssh you need to push code
in your repo click on ssh type and take last three lines
-- Push your code
Copy and paste the last three lines and code will be pushed
Scp https://builtin.com/articles/scp-command
-- AWs codebuild
---
version: 0.2
phases:
build:
commands:
- echo Building the Docker image...
- docker build -t $IMAGE_NAME .
artifacts:
files:
- "**/*"
discard-paths: yes
env:
variables:
IMAGE_NAME: flask-app
--------------------------------------