Secara singkat, peritah linux adalah text yang harus kamu ketikan di terminal untuk mengeksekusi
sebuah aplikasi berbasis CLI.
Untuk lebih mudah memahami ini,pahami dulu konsep dibawah ini.
Pada dasarnya aplikasi dibagi menjadi 2, berdasar tampilan /cara user berinteraksi yaitu :
Perintah dasar linux ini ada disetiap jenis linux sebagai standar aplikasi bawaan berbasis console
(Command) untuk melakukan kegiatan mendasar pada sistem operasi linux.
Atau dengan bahasa yang sederhana perintah dasar linux adalah perintah linux yang pasti ada di
setiap distro linux,baik SUSE,Redhat,Debian ,Arch beserta distro turunan nya.
Hardlink : link/shortcut yang kita buat mengarah langsung ke data dalam hardisk
ln file1.txt file2.txt
mount /umount
Mount digunakan untuk memuat directory/drive/device kedalam struktur directory linux sehingga
dapat diakses dan digunakan oleh system dan user,sedangkan umount berfungsi sebaliknya.
[masarie@SparkFly ~]$ mount /dev/cdrom /media/cdrom
tar
tar digunakan untuk mengkompress file /folder kedalam bentuk archive dan meng extract archive file
yang dibuat dengan perintah tar.
Membuat archive file :
[masarie@SparkFly ~]$tar -cf archive.tar file1 file2
Meng extract archive file :
[masarie@SparkFly ~]$tar -cf archive.tar file1 file2
touch
digunakan utnuk memodifikasi proprti waktu pada file, atau bisa juga digunakan untuk membuat file
kosong. kita bisa mmebuat 3 file kosong sekaligus dengan mengetikan touch file1 file2
file3
services
merupakan command untuk mengatur startup daemon(service) pada sistem yang menggunakan init.d
sebagai service managernya
service nama_service opsi ,opsi disini biasanya status ,start,restart,stop
systemctl
merupakan command untuk mengatur startup daemon(service) yang menggunakan systemd sebagai
service managernya, systemd merupakan versi pembaruan dari init.d
systemctl opsi nama_service.service .
opsi disini bisa status,start ,stop,restart, untuk lengkapnya ketik systemctl lalu tekan tab untuk
menampilkan command yang tersedia. nama service biasanya memiliki suffix .service
contoh systemctl stauts sshd.service
processor :1
vendor_id : GenuineIntel
cpu family :6
model : 61
model name : Intel(R) Core(TM) i5-5200U CPU @ 2.20GHz
stepping :4
microcode : 0x19
cpu MHz : 2463.183
cache size : 3072 KB
physical id :0
siblings: 4
core id :1
cpu cores :2
apicid :2
initial apicid : 2
fpu : yes
fpu_exception : yes
cpuid level : 20
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36
clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc
arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq
dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic
movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch epb
intel_pt tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms
invpcid rdseed adx smap xsaveopt dtherm ida arat pln pts
bugs :
bogomips : 4392.72
clflush size : 64
cache_alignment : 64
address sizes : 39 bits physical, 48 bits virtual
power management:
processor :2
vendor_id : GenuineIntel
cpu family :6
model : 61
model name : Intel(R) Core(TM) i5-5200U CPU @ 2.20GHz
stepping :4
microcode : 0x19
cpu MHz : 2464.794
cache size : 3072 KB
physical id :0
siblings: 4
core id :0
cpu cores :2
apicid :1
initial apicid : 1
fpu : yes
fpu_exception : yes
cpuid level : 20
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36
clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc
arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq
dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic
movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch epb
intel_pt tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms
invpcid rdseed adx smap xsaveopt dtherm ida arat pln pts
bugs :
bogomips : 4393.38
clflush size : 64
cache_alignment : 64
address sizes : 39 bits physical, 48 bits virtual
power management:
processor :3
vendor_id : GenuineIntel
cpu family :6
model : 61
model name : Intel(R) Core(TM) i5-5200U CPU @ 2.20GHz
stepping :4
microcode : 0x19
cpu MHz : 2463.989
cache size : 3072 KB
physical id :0
siblings: 4
core id :1
cpu cores :2
apicid :3
initial apicid : 3
fpu : yes
fpu_exception : yes
cpuid level : 20
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36
clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc
arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq
dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic
movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch epb
intel_pt tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms
invpcid rdseed adx smap xsaveopt dtherm ida arat pln pts
bugs :
bogomips : 4392.76
clflush size : 64
cache_alignment : 64
address sizes : 39 bits physical, 48 bits virtual
power management:
Contoh Perintah Linux Untuk Mengelola Media
Penyimpan
(Drive Storage Utility)
Perintah linux dibawah ini bisa kamu gunakan untuk melihat informasi dan status akan hdd/ssd mu
mulai dari sisa hardisk, pemakaian harddisk, informasi partisi dan mounting nya.
du (Disk Usage)
Perintah $ du -sh digunakan untuk melihat summary ukuran pemakaian volume hdd untuk setiap
folder atau file yang ada dalam sistem.
untuk manual penggunaan nya silakan gunakan perintah $ man du
[masarie@SparkFly ~]$ du -sh /home/masarie
25G /home/masarie
[masarie@SparkFly ~]$
df (Disk Free)
Digunakan untuk melihat laporan penggunaan rung hdd/ssd yang terpasang di komputer mu.
untuk manual penggunaan nya silakan gunakan perintah $ man df
[masarie@SparkFly ~]$ df -h
Filesystem Size Used Avail Use% Mounted on
dev 3.9G 0 3.9G 0% /dev
run 3.9G 1.5M 3.9G 1% /run
/dev/sda2 33G 19G 14G 59% /
tmpfs 3.9G 107M 3.8G 3% /dev/shm
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/sda1 975M 392K 975M 1% /boot/efi
tmpfs 3.9G 44K 3.9G 1% /tmp
/dev/sda4 87G 26G 61G 30% /home
/dev/sda9 65G 60G 4.4G 94% /run/media/masarie/DATA
tmpfs 791M 20K 791M 1% /run/user/1000
[masarie@SparkFly ~]$
lsblk (List Block Devices)
Digunakan untuk menampilkan block device yang tersedia,namun tidak menampilkan RAM , block
device yang dimaksud disini seperti flashdisk,mmc,HDD,SSD,DCROM dll.
Untuk manual penggunaan nya silakan gunakan perintah $ man lsblk
[masarie@SparkFly ~]$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 223.6G 0 disk
├─sda1 8:1 0 976.6M 0 part /boot/efi
├─sda2 8:2 0 32.9G 0 part /
├─sda3 8:3 0 1.9G 0 part [SWAP]
├─sda4 8:4 0 88.8G 0 part /home
├─sda5 8:5 0 300M 0 part
├─sda6 8:6 0 100M 0 part
├─sda7 8:7 0 128M 0 part
├─sda8 8:8 0 34.3G 0 part
└─sda9 8:9 0 64.2G 0 part /run/media/masarie/DATA
mmcblk0 179:0 0 1.9G 0 disk
└─mmcblk0p1 179:1 0 1.9G 0 part
cfdisk /fdisk
digunakan untuk mengelola prtisi hdd/ssd mulai membuat,hapus,edit partisi hdd/ssd yang ada di
komputermu.
kill /killall/xkill/pkill
pada dasarnya semua command tersebut digunakan untuk mmerubah behavior atau membunuh
process yang sedang berjalan, hanya saya masing masing command dibuat dengan tujuan yang
spesifik.
–kill : mengirim signal ke process untuk merubah behavior atau membunuh nya. kill [signal
or option] PID(s)
Signal Name Signal Value Behaviour
SIGHUP 1 Hangup
SIGKILL 9 Kill Signal
SIGTERM 15 Terminate
untuk melihat PID dari process bisa menggunakan perintah ps -a ,pidof namaProcess atau ps
-aux |grep namaprocess–killall : membunuh proses dengan menggunakan nama process(bukan
PID), dan sekaligus membunuh child process , perintah ini sangat efisien digunakan jika process
mempunyai banyak instance atau child process. killall [signal or option]
namaProcess
–xkill : digunakan untuk membunuh process yang mempunyai tampilan GUI, cara menggunakan nya
cukup ketikan perintah xkill pada terminal lalu klik pada aplikasi GUI yang ingin kamu bunuh.
[masarie@SparkFly ~]$ xkill
Select the window whose client you wish to kill with button 1....
–pkill :membunuh process dengan menggunakan nama processpkill namaProcess
time
digunakan sebagai stopwatch yang mencatat waktu yang diperlukan oleh suatu process untuk
memproses data hingga selesai.
[masarie@SparkFly ~]$ time chromium
Created new window in existing browser session.
real 0m0.343s
user 0m0.207s
sys 0m0.090s
[masarie@SparkFly ~]$
lsmod
Untuk menampilkan module /driver yang diload ke kernel, jadi dengan kata lain kita bisa
menampilkan driver yang terinstall di linux dengan mengetikan perintah lsmod
Conth Perintah Linux Untuk Mengelola Jaringan
(Networking)
Setelah berhasil menginstall linux dan mengugnakan nya pasti kamu perlu melakukan setting dan
pengecekan terhadap jaringan.
Mulai dari memasang IP, cek IP, cek koneksi ,hingga melihat port yang terbuka di linux
menggunakan perintah linux via terminal.
Berikut perintah linux dasar yang bisa kamu gunakan untuk melakukan semua itu.
ping
ping digunakan untuk mengecek komputer dengan IP tertentu terhubung ke jaringan atau tidak atau
bisa juga untuk mengecek response time komputer dalam sebuah jaringan
[masarie@SparkFly ~]$ ping goole.com
PING goole.com (87.106.83.127) 56(84) bytes of data.
64 bytes from s325913783.websitehome.co.uk (87.106.83.127): icmp_seq=1 ttl=44 time=235 ms
64 bytes from s325913783.websitehome.co.uk (87.106.83.127): icmp_seq=3 ttl=44 time=235 ms
64 bytes from s325913783.websitehome.co.uk (87.106.83.127): icmp_seq=4 ttl=44 time=234 ms
64 bytes from s325913783.websitehome.co.uk (87.106.83.127): icmp_seq=5 ttl=44 time=235 ms
64 bytes from s325913783.websitehome.co.uk (87.106.83.127): icmp_seq=6 ttl=44 time=235 ms
^C
--- goole.com ping statistics ---
6 packets transmitted, 5 received, 16% packet loss, time 5021ms
rtt min/avg/max/mdev = 234.267/235.236/235.783/0.742 ms
Gunakan CTRL+C untuk mengakhiri perintah ping
nslookup
digunakan untuk mengetahui IP dari hostname/domain yang ingin kita ketahui ip nya.
[masarie@SparkFly ~]$ nslookup tembolok.id
Server: 192.168.41.1
Address: 192.168.41.1#53
Non-authoritative answer:
Name: tembolok.id
Address: 104.28.0.85
Name: tembolok.id
Address: 104.28.1.85
Name: tembolok.id
Address: 2400:cb00:2048:1::681c:55
Name: tembolok.id
Address: 2400:cb00:2048:1::681c:155
tracepath
digunakan untuk menelusuri jalur paket data ketika melewati jaringan,biasaya akan tertera beberapa
IP/host yang merupakan gateway router.
[masarie@SparkFly ~]$ tracepath detik.com
1?: [LOCALHOST] pmtu 1500
1: 192.168.41.1 0.938ms
1: 192.168.41.1 0.861ms
2: 192.168.41.1 1.370ms pmtu 1480
2: ??? 7.845ms
3: 125.160.1.197 8.657ms
4: ??? 9.069ms
5: telkomnet-as17974.iix.net.id 19.195ms asymm 7
6: detik-as24211.iix.net.id 19.561ms asymm 7
7: 203.190.244.34 18.891ms
8: 103.49.221.211 19.366ms reached
Resume: pmtu 1480 hops 8 back 8
netstat
digunakan untuk melihat statistik status protokol TCP/IP yang sedang digunakan.sebagai contoh kita
menggunakan opsi -tulpn untuk melihat port yang terbuka pada komputer
[root@SparkFly ~]# netstat -tulpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 456/dropbear
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 670/cupsd
tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN 523/postgres
tcp 0 0 0.0.0.0:445 0.0.0.0:* LISTEN 657/smbd
tcp 0 0 127.0.0.1:55553 0.0.0.0:* LISTEN 754/msfrpcd
tcp 0 0 0.0.0.0:139 0.0.0.0:* LISTEN 657/smbd
tcp6 0 0 :::22 :::* LISTEN 456/dropbear
tcp6 0 0 ::1:631 :::* LISTEN 670/cupsd
tcp6 0 0 ::1:5432 :::* LISTEN 523/postgres
tcp6 0 0 :::445 :::* LISTEN 657/smbd
tcp6 0 0 :::139 :::* LISTEN 657/smbd
udp 0 0 192.168.41.31:137 0.0.0.0:* 637/nmbd
udp 0 0 192.168.41.12:137 0.0.0.0:* 637/nmbd
udp 0 0 0.0.0.0:137 0.0.0.0:* 637/nmbd
udp 0 0 192.168.41.31:138 0.0.0.0:* 637/nmbd
udp 0 0 192.168.41.12:138 0.0.0.0:* 637/nmbd
udp 0 0 0.0.0.0:138 0.0.0.0:* 637/nmbd
udp 0 0 0.0.0.0:5353 0.0.0.0:* 2254/libpepflashpla
udp 0 0 0.0.0.0:5353 0.0.0.0:* 413/avahi-daemon: r
udp 0 0 0.0.0.0:39551 0.0.0.0:* 413/avahi-daemon: r
udp6 0 0 :::37598 :::* 413/avahi-daemon: r
udp6 0 0 :::5353 :::* 2254/libpepflashpla
udp6 0 0 :::5353 :::* 413/avahi-daemon: r
ifconfig /ifup /ifdown
ifconfig digunakan untuk mengkonfigurasi network interface atau bisa digunakan untuk sekedar
mengecek status interface dan IP.
[root@SparkFly ~]# ifconfig -a
enp6s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.41.12 netmask 255.255.255.224 broadcast 192.168.41.31
inet6 fe80::34c0:de18:6f88:15d6 prefixlen 64 scopeid 0x20<link>
ether b8:2a:72:f7:9d:c8 txqueuelen 1000 (Ethernet)
RX packets 1035320 bytes 1275138136 (1.1 GiB)
RX errors 0 dropped 17493 overruns 0 frame 0
TX packets 784709 bytes 72859933 (69.4 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0