-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrhel.txt
634 lines (398 loc) · 10.1 KB
/
rhel.txt
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
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
===Instalasi RHEL 7===
~ Minimal
~ LVM2
~ NTP
===shell & manajemen file & directory===
whoami → cek user aktiv
pwd → print working directory
cd → change directory
mkdir → make directory
rmdir → remove empty directory
ls → listing directory
[command] --help
man [command]
touch → membuat file kosong
rm → menghapus file/dir
cp → copy file/dir
mv → move/rename file/dir
file → melihat tipe file
===editor teks vi===
cat → menampilkan isi file teks
command vi
i → masuk ke mode edit
esc → kembali ke mode command
:w [namafile] → simpan file
:q! → keluar
:wq → simpan dan keluar
yy → copy 1 baris di posisi kursor
3yy → copy 3 baris mulai dari posisi kursor ke bawah
dd → delete/cut 1 baris di posisi kursor
3yy → delete/cut 3 baris mulai dari posisi kursor ke bawah
u → undo
:redo → redo
/[string] → mencari kata string
n → mencari kata string berikutnya
:%s/string_awal/string_pengganti/g
===manajemen disk===
1. membuat partisi disk → fdisk
# fdisk -l
# fdisk /dev/sdb
p → menampilkan skema partisi
g → create partition table gpt
n → membuat partisi baru
w → menyimpan skema partisi
q → keluar tanpa menyimpan
# partprobe → kernel membaca skema partisi baru
# fdisk -l
2. membuat file system → ext4, xfs
# mkfs.xfs -L DATA /dev/sdb1
3. mount → /etc/fstab
# mkdir /mnt/data → directory mount point
# vi /etc/fstab
/dev/sdb1 /mnt/data xfs defaults 0 0
# mount /dev/sdb1
# mount
# df -h
# umount /dev/sdb1
# df -h
===Manajemen Paket===
Repository → Database paket + index
Manajemen paket → yum
File konfigurasi repositori → /etc/yum.repos.d/*.repo
---Konfigurasi Repo ke DVD---
1. Buat direktori mount point DVD
# mkdir /media/cdrom
2. Mount DVD RHEL
# mount /dev/cdrom /media/cdrom
# df -h
3. Buat file konfigurasi repo
# cd /etc/yum.repos.d/
# vi rhel7-dvd.repo
[rhel7-dvd]
name=Red Hat Enterprise Linux 7 DVD
baseurl=file:///media/cdrom
enabled=1
gpgcheck=0
# yum repolist
# yum search nano
# yum install nano
# yum list | more
===Konfigurasi Jaringan===
1. Colok kabel UTP
# dmesg | grep enp
# nmtui
IP: 10.0.0.2x/24
Gateway: 10.0.0.1
DNS1: 8.8.8.8
DNS2: 8.8.4.4
[X] Automatically connected
# ip addr → Cek alamat IP
# ip route → Cek default gateway
# cat /etc/resolv.conf → Cek DNS resolver
# ping 10.0.0.2x
# ping 10.0.0.1
# ping 8.8.8.8
# ping 10.0.0.20
–-Test service network (httpd)---
# yum install httpd
# systemctl start httpd
# systemctl status httpd
# systemctl stop firewalld
# systemctl disable firewalld
# systemctl status firewalld
Browsing dari Host OS laptop ke RHEL Server
http://10.0.0.2x
===SSH Service===
# systemctl status sshd
Test SSH dari Hos OS laptop ke RHEL 7 Server
---SSH Tanpa Password (Key Public)---
---Generate Key Public di Host OS Laptop (Linux)---
$ ssh-keygen
$ ls -lh ~/.ssh/
---Copy Key Public ke server SSH di Host OS Laptop (Linux)---
$ ssh-copy-id -i ~/.ssh/id_rsa.pub [email protected]
Test SSH dari Hos OS laptop ke RHEL 7 Server
---Transfer File lewat SCP---
SCP dari Host OS ke Server
scp -r /etc/passwd [email protected]:/root/
SSH ke Server
# ls -lh /root
SCP dari Server ke Host OS
scp -r [email protected]:/etc/redhat-release ~/
===Manajemen User===
Tipe User:
1. root → administrator
2. pseudo users → user aplikasi
3. users → user biasa
File konfigurasi user: /etc/passwd
root:x:0:0:root:/root:/bin/bash
[user]:[password]:[uid]:[gid]:[deskripsi]:[home dir]:[shell]
File konfigurasi password: /etc/shadow
---Membuat User---
# useradd -m budi
---Set Password User---
# passwd budi
File konfigurasi grup: /etc/group
---Login Ke User Lain di Shell Aktif---
su – [user]
---Login Ke root di Shell Aktif---
su -
---Membuat Grup Baru---
# grupadd -g 9999 jagoan
---Memasukkan user ke dalam grup---
# usermod -aG jagoan budi
# usermod -aG jagoan samad
# tail -5 /etc/passwd
# tail -5 /etc/group
===Hak Akses (Permission) dan Kepemilikan (Ownership) File/Dir===
# ls -lh /latihan
-rw-r--r--. 1 root root 0 Feb 21 17:45 file1
- → file/direktori
rw- → permission user owner
r-- → permission group owner
r-- → permission other
. → selinux
1 → jumlah hardlink
root → user owner
root → group owner
0 → ukuran file
Feb 21 17:45 → waktu modifikasi terakhir
file1 → nama file
---permission---
r 4 w 2 x 1
0 - - -
1 - - x
2 - w -
3 - w x
4 r - -
5 r - x
6 r w -
7 r w x
chmod → ubah permission file/dir
chmod [nilai permission user group other] [file/dir]
chmod [ugoa][+-=][rwx-] [file/dir]
chmod u=r,g=-,o=- file_user1a
---Ubah Ownership---
chown → ubah ownership user & grup
chgrp → ubah ownership grup
====Set SELinux Permissive===
# getenforce → cek status SELinux
# setenforce [0|1] → set SELinux Permissive | Enforcing
===Konfigurasi Jam dan Tanggal===
date → system clock (jam tanggal sistem Linux)
hwclock → hardware clock (jam tanggal sistem BIOS)
1. instal paket ntp
# yum install ntp ntpdate
# systemctl start ntpd
# systemctl enable ntpd
# systemctl status ntpd
2. set time-zome
# timedatectl list-timezones | grep -i jakarta
# timedatectl set-timezone Asia/Jakarta
3. set system time menggunakan ntp
# timedatectl set-ntp yes
4. verifikasi
# timedatectl
# date
5. sinkronisasi system clock dan hardware clock
# hwclock --systohc
===Log===
Direktori lokasi log default → /var/log
Log system utama → /var/log/messages
File konfigurasi Log: /etc/rsyslog.conf
Service manajemen log:
# systemctl status rsyslog
tools baca log:
tail
tailf
===Logical Volume Management (LVM)===
1. Set partisi tipe 15 (Linux LVM) dengan fdisk
# fdisk /dev/sdb
# partprobe
2. Instal paket lvm2
# yum install lvm2
# reboot
3. Membuat Physical Volume (PV)
# pvcreate /dev/sdb2 /dev/sdb3
# pvs
# pvdisplay
4. Membuat Volume Group (VG)
# vgcreate vg01 /dev/sdb2 /dev/sdb3
# vgs
# vgdisplay
5. Membuat Logical Volume (LV)
# lvcreate vg01 -L 3G -n lv01
# lvs
# lvdisplay
# vgs
6. Format LV
# mkfs.xfs /dev/vg01/lv01 -L VG01LV01
7. Mount LV
# mkdir /mnt/vg01lv01
# vi /etc/fstab
/dev/vg01/lv01 /mnt/vg01lv01 xfs defaults 0 0
# mount /dev/vg01/lv01
# mount
# df -h
---Extend LV---
0. Menulis file ke partisi LV
# unalias cp
# for X in {1..1000000};do cp -v /etc/passwd /mnt/vg01lv01/file$X; sleep 5; done
Buka terminal baru
1. Membuat PV partisi baru
# pvcreate /dev/sdb4
# pvs
2. Masukkan PV baru ke VG yang sudah ada
# vgextend vg01 /dev/sdb4
# vgs
3. Extend LV01
# lvextend -l +100%FREE /dev/vg01/lv01
# lvs
# df -h
4. Resize filesystem (ext4 → resize2fs | xfs → xfs_growfs)
# xfs_growfs /mnt/vg01lv01/
# df -h
---Remove PV---
Perhatikan dan hitung kapasitas yang sudah dipakai dan kapasitas disk dari VG yang akan diremove
1. Shrink file system (ext4 bisa shrink, xfs belum bisa shrink)
# xfs_growfs -L 941875 /mnt/vg01lv01/
2. Reduce LV
# lvreduce -L 3.7G /dev/vg01/lv01
# lvs
3. Remove PV dari VG
# vgreduce vg01 /dev/sdb2
4. Remove status PV partisi disk
# pvremove /dev/sdb2
===Shell Script==
# cd /latihan
# vi latihan3.sh
--------------------------------------
#!/bin/bash
echo “halo, ini skrip pertama saya”
---------------------------------------
# cat latihan3.sh
# chmod +x latihan3.sh
# ./latihan3.sh
# vi latihan4.sh
---------------------------------------------
#!/bin/bash
unalias cp
for X in {1..1000000}
do
cp -v /etc/passwd /mnt/vg01lv01/file$X
sleep 5
done
-------------------------------------------------
# chmod +x latihan4.sh
# ./latihan4.sh
===Proses Boot===
1. BIOS
2. Boot loader → GRUB
3. Kernel → /boot/vmlinuz-xxxx
4. SystemD → PID 1
5. Services
===Manajemen Proses===
Menampilkan keseluruhan proses
# ps -aux | more
# ps -aux | head -1
# ps -aux | grep latihan4.sh
Tipe proses:
1. Proses Daemons (SystemD)
Proses yang dijalankan oleh SystemD/Services
2. Proses Foreground
Proses yang diinput dan berjalan di shell aktif
3. Proses Background
Proses yang diinput di shell aktif tapi berjalan di belakang shell.
[COMMAND] &
fg → mengubah proses background menjadi proses foreground
bg → mengubah proses stop menjadi proses background
# ./latihan4.sh &
# jobs → menampilkan proses background atau proses stop
# fg 1
Ctrl+Z → proses stop (lanjutkan proses dengan fg atau bg)
# jobs
# bg 1
# jobs
---Menampilkan Proses Statis---
# ps -aux | more
---Mengirim Sinyal Ke Proses (Kill)---
# ps -aux | grep latihan4.sh
# kill -9 [PID]
---Menampilkan Proses Dinamis---
# top
===Repo CentOS Updates===
Contoh Repo CentOS Updates:
http://kambing.ui.ac.id/centos/7/updates/x86_64/
# cd /etc/yum.repos.d
# vi centos7-updates.repo
[centos7-updates]
name=CentOS 7 Updates
baseurl=http://10.0.0.117/repo/centos/7/updates/x86_64/
enabled=1
gpgcheck=0
# yum repolist
---Upgrade Paket---
# yum upgrade
===Repo CentOS EPEL===
Contoh Repo EPEL:
http://fedora.dionipe.web.id/epel/7/x86_64/
#cd /etc/yum.repos.d
# vi epel7.repo
[epel]
name=EPEL 7
baseurl=http://10.0.0.117/repo/epel/7/x86_64/
enabled=1
gpgcheck=0
# yum repolist
# yum install htop testdisk
# yum install yumex
===Partisi Swap===
# swapon -s
# top
# free -m → status memori ram & swap
---Membuat & Aktifkan Partisi Swap---
1. Partisi tipe Linux Swap (14)
# fdisk /dev/sdb
# partprobe
# fdisk -l
2. Format tipe FS Swap
# mkswap -L SWAP /dev/sdb5
3. Aktifkan partisi Swap
# swapon /dev/sdb5
# swapon -s
4. Edit file konfigurasi mount
# vi /etc/fstab
/dev/sdb5 swap swap defaults 0 0
5. Matikan Swap
# swapoff /dev/sdb5
# swapon -s
===FTP Service===
1. Instal paket vsftpd
# yum install vsftpd
2. Aktifkan Service VSFTPD
# systemctl start vsftpd
# systemctl enable vsftpd
# systemctl status vsftpd
3. Test login FTP dari klien (Host OS Laptop)
User: anonymous
Password: [ENTER]
4. Edit file konfigurasi vsftpd: /etc/vsftpd/vsftpd.conf
# vi /etc/vsftpd/vsftpd.conf
------------------------------------
anonymous_enable=NO
------------------------------------
# systemctl restart vsftpd
4. Test login FTP dari klien (Host OS Laptop)
User: anonymous
Password: [ENTER] → GAGAL
===KVM===
# yum install qemu-kvm virt-manager
===Root Password Recovery===
http://linoxide.com/linux-how-to/reset-forgotten-root-password-rhel-centos-7/
===Tools Admin===
nmap
tcpdump
mtr
fping
HP/WA/Telegram: 0811 1117 115