Rabu, 26 September 2018

Pelatihan Linux 3

ip addr : cek ip kita
vim /etc/httpd/conf/httpd.conf
systemctl enable httpd
ip addr
cd /etc/sysconfig/network-scripts/
ls ifcfg-*
vim ifcfg-Wired_connection_1
nmcli connection reload
nmcli connection show
nmcli connection up Wired\ connection\ 1
ipaddr show
history : untuk lihat perintah terakhir kita
systemctl restart httpd.service
getenforce : cek aktif keamanan
getsebool -a | grep httpd : cek untuk pengaktifan getenforce (httpd_enable_homedirs --> , httpd_read_user_content --> )
setsebool -P httpd_enable_homedirs on
setsebool -P httpd_read_user_content on
http://localhost/~student25/ : untuk melihat web yang di buat oleh user lain
ls -ld $HOME : menampilkan dan keterangan suata file
vim userdir.conf : untuk mengaktifkan public_html
vim /etc/hosts : untuk membuat alias untuk di alamat web dan di redirect ke ip
mkdir -p /var/www/{default,aliaswww}

Selasa, 25 September 2018

Pelatihan Linux 2

touch file{1..7} : membuat file dari file 1 sampai 7
mkdir -p data1/pegawai/2018 : dengan cek parrent folder jika tidak ada langsung bikin

cd ./episode : masuk dengan relatife
cd /episode : dengan absolute tanpa pakai titik
cd ~namauser : untuk ke home user lain, syarat nya harus ada permisions
rmdir data1/pegawai/2018 data1/pegawai data1 : delete dari child ke parent
ls [fF]* : buka file yang awal nya f besar atau f kecil dan ujung nya bebas
ls f??e* :huruf awal f kecil, huruf ke dua bebas, huruf ke 3 bebas, huruf ke empat e, dan ke 5 bebas
chmod u=rw,g=,o= fi : mengubah akses menjadi kosong semua terkecuali user (u)
chgrp = merubah group
chown student(nama user):student(group) /home/student/f1 : merubah akses user dan grup
chown :student(group) /home/student/f1 : merubah akses grup saja
ls -i z2 (z2 adalah file) : untuk melihat nomor inux dari suatu file
find . -inum 350082738 -exec ls -l {} \; : mencari dengan nomor inux
echo "New File" >> /home/student/z2 : membuat file dengan nama file z2, dengan isi text file New File
1> file 2>&1 : kalau tidak error di redirect ke file dan kalau ada error kembalikan ke decriptor 1
atau
2> file 1>&2
atau
&> file
echo "tambah data" >> z1 : menambahkan isi data ke file z1
echo "ganti data" > z1 : mengganti isi data ke file z1
cat kota z1 > gabung
cat gabung : jalan kan yang atas dulu config nya, untuk mengabungkan file kota dan z1
split -10/etc/passwd pass : membuat file dengan isi file 10
wc-l pass* : untuk menampilkan isi yang sudah di pecah
cat pass* > pass_file : menjumlahkan isi file yang sudah di pecah
cat - kota - z1 >gabung : membuat judul dari setiap data yangs udah di buat
here documen : cat <<++ > peserta : (untuk mengakhiri pembuatan isi file dengan string ++ )
who | sort | cut -c1-8 | paste - - : menggabungkan semua perintah dengan satu perintah
useradd student1
useradd -u 1010 student3
usermod -l admin -d /home/admin -m(membuat folder) student4 : untuk merubah student4 menjadi admin
tail -2 /etc/passwd : melihat log data passwd terakhir
userdel student2 : menghapus user tanpa menghapus history
userdel -r student2 : menghapus user tanpa dengan history
groupadd marketing : membuat group
groupadd -r appweb : membuat group dibawah 1000
groupmod -g 1015 appweb : mengganti group id dengan 1015
groupmod -n javaapp appweb :mengganti nama group
usermod -aG sales student3 : mengganti group suatu user
groups student3 :melihat group suatu user
passwd admin : membuat password suatu user
bc : binary calculator
chage -l admin : melihat status user
chage -m 0 -M 90 -I 7 admin : mengganti status user
date -d "+90 days" : cek tanggal
chage -E 2018-12-24 admin : mengatur experid password user
usermod -L student3 : lock password student3
usermod -U student3 : unlock pasword student3
usermod -s /sbin/nologin student3 : ganti shell menggunakan nologin
-s : untuk shell
udo tail /var/log/secure : log aktivitas user
usermod -o -u 0 admin : membuat user seperti admin dengan id 0
rpm -qa | wc -l : melihat jumlah paket
rpm -ivh vsftpd-3.0.2-22.el7.x86_64.rpm : install paket
rpm -qa vsftpd : cek install paket
rpm -e vsftpd : delete paket
yum history : melihat history install
yum history undo 3 : uninstall semua paket







Manage Password
-----------------------
- passwd
-

Senin, 24 September 2018

Pelatihan Linux 1

Sesi console
- F1 GUI
- F2 - F6

console terminal :
tty : cek session posisi user dimana
ssh student@localhost : remote ke diri sendiri
who : cek aktivitas user
id : untuk cek dengan user siapa kita login
echo $TERM : untuk cek layar kita(sinkron untuk clear screen)
w : aktivitas secara detail kita
who -u : mengeluarkan aktivitas id nya, untuk memberhentikan proses (task manajer)
man man : membuka kamus per bab bertanya ke man
man passwd : default bab
man 5 passwd : menentukan bab
man -k zip : find kamus yang berhubungan dengan kata zip
updatedb : untuk mengupdate database lokal (kamus) su -
mandb : sama seperti updatedb, lebih fokus
cp /etc/passwd(folde yang akan di copy) pass(folder baru) : cara copy
cp -i /etc/passwd(folde yang akan di copy) pass(folder baru) : cara copy dengan alert
alias cp="cp -i"
file : untuk membaca propertis file
grep user(katauser) backup/fi(file nya)
grep -i user(katauser) backup/fi(file nya) tidak mengaharaukan besar kecil
grep -iv user(katauser) backup/fi(file nya) tidak menggunakan kata user
grep "bash$"(yang di akhirnya ada kata2 bash) backup/fi(posisi file)
grep "^student"(awal dengan kata) backup/f1
vim latihan.txt : membuat file dan mengeluar kan text editor
:q! : untuk keluar vim
vim $HOME/.exrc : pengaturan satu folder, jika membuat vim di situ otomatis config terbaca
atau vim ~/.exrc


vim mode :
- command -- input dianggap perintah
- editing/insert -- input dimasukan ke buffer
- last line mode -- :,/(find dari atas ke bawah),?(find dari bawah ke atas)

Linux Shell : regular user admin
-> sh (born shell) from nya : $ #
-> csh (c-shell) % #
-> ksh (korn shell) $ #
-> bash (born again shell) $ #

Windows Shell :
-> command
-> cmd
-> Powershell

database user
-----------------
- /etc/passwd -- database user
- /etc/group -- database group
- /etc/shadow -- database password

..................
Latihan Editor vim
..................

untuk masuk editing
- i,I = untuk insert
- a,A = Append
- o,O = Open Line

pergerakan kursor 
h = panah kiri
j = panah bawah
k = panah atas
l = panah kanan
0 = ke awal baris
$ = ke akhir baris
G = ke akhir file
nG = ke akhir baris n
w,W = kekanan 1 kata
b,B = kekiri 1  kata
 
change  dan replace 
...................

r = ganti 1 karakter
cw = replace
cc = ganti 1 baris

hapus 
.......
x = hapus 1 karakter 
dw = hapus
dd = hapus 1 baris
u = undo (membatalkan perintah)
ctrl+R = redo

copy, paste
..........

yw = copy 1 kata
yy, y = copy 1 baris
p = paste

cari string 
..........
/string = cari string dari atas ke bawah
?string = cari string dari bawah ke atas
n = pencarian string berikut nya
. = mengulang perintah terakhir 


ex mode
.......
:w = save
:w nama_file = simpan file dengan nama_file
:1,20 w nama_file = baris 1 s.d 20 simpan degan  nama_file
:wq = simpan dan keluar
:x = simpan dan keluar
ZZ = simpan dan keluar
:q = keluar tanpa menyimpan
:q! = keluar tanpa menyimpan

:f = mengingat nama file yang sedang di edit
:1,10 co 20 = baris 1 s.d 20 di copy ke baris 20
:1,10 d = hapus baris 1 s.d 10
:1,10 m $ = baris 1 s.d 10 dipindah ke akhir file
:r nama_file = insert nama_file ke file yang sedang di edit
:set nu = menampilkan no baris
:set nonu = menghilangkan no baris
:set tabstop=5 = untuk mengatur tabulasi 5 karakter
:set autoindent = set untuk auto indent
:e nama_file = pindah edit ke nama_file
:!command = menjalankan shell command
!!command = output perintah masukan ke editor vim

find and replace
...............
:l,$s/lama/baru/g = cari dari baris 1 s.d terakhir kata lama, kalau ketemu diganti dengan kata baru dengan global 


:%s/lama/baru/g = cari dari baris 1 s.d terakhir kata lama, kalau ketemu diganti dengan kata baru dengan global 

Visual Mode
..........
v = block per karakter
ctrl+v =  block per kolom
V = block baris

Selasa, 18 September 2018

script elasticsearch : tambah hapus lihat (add delete)


elasticsearch 2.4 :
- per id : http://localhost:9200/index(index)/pemda(document)/D489(id)?pretty
- per document : http://localhost:9200/index/aktivitas_realisasi/_search
- limit record/page : http://localhost:9200/index/aktivitas_pp/_search?from=0&size=20
- melihat semua document : http://localhost:9200/index/_mapping?pretty=true
- membuat index baru : http://localhost:9200/index_test?pretty=true (method put)
- hapus satu index : http://localhost:9200/index_test?pretty=true (method delete)
- membuat document : http://localhost:9200/index_test_lagi/document?1pretty=true (method pos)
- memeriksa satu document : http://localhost:9200/index_test_lagi/document/1?pretty=true
- menghapus 1 document : http://localhost:9200/index_test_lagi/document/1=true (method delete)
- insert bulk : http://localhost:9200/index_test_lagi/document/_bulk?pretty&refresh (post)
- count jumlah semua index : http://localhost:9200/index_test_lagi/_count?pretty=1
- memeriksa semua dokumen : http://localhost:9200/index_test_lagi/document/_search?pretty=true
- search berdasarkan nama field : http://localhost:9200/katalog_test/document_test/_search?q=nama:Jasuindo

console :
- delete index : curl -XDELETE localhost:9200/nama_index (tanpa http dan di local server/tempat elastic di install)

elasticsearch 7.10 :
- menghapus 1 document : http://localhost:9200/index_test_lagi/_doc/product_619931(method delete)

Minggu, 16 September 2018