ABDURROZAK.MY.ID // DEBIAN LINUX SERVER FUNDAMENTAL
MENGUASAI COMMAND LINEDEBIAN LINUX
Volume 03 dari seri Debian Linux Server Fundamental. Panduan komprehensif menguasai command line Linux dari dasar hingga mahir. Setiap command dijelaskan detail dengan syntax, parameter, contoh penggunaan, dan output. Dari navigasi direktori hingga administrasi server, semua dibahas tuntas dengan praktik langsung di terminal.
VOLUME03 / 17
SUB-BAB15
BACA150 MENIT
COMMAND100+
ABDUR ROZAK, S.Kom.
Web Developer & System Administrator - abdurrozak.my.id
VOLUME 03 / 17
LINUX COMMAND LINE MASTERY
Panduan lengkap command line Linux untuk server administration. 15 sub-bab mencakup navigasi direktori, manipulasi file, text processing, pipe & redirect, permission, user management, process management, package management, service management, network commands, hingga praktik administrasi server. Setiap command disertai syntax, parameter, contoh, dan output.
SUB-BAB15LEVELCommand LineWAKTU150 MENIT
01
SUB-BAB 01 TERMINAL
PENGENALAN TERMINAL
Apa Itu Terminal?
Terminal adalah interface berbasis teks untuk berinteraksi dengan sistem operasi. Di Linux, terminal adalah cara paling powerful untuk mengontrol sistem. Hampir semua administrasi server dilakukan via terminal.
TERMINAL EMULATOR
Program GUI yang menyediakan akses ke shell (GNOME Terminal, Konsole, xterm)
SHELL
Program yang menerima & menjalankan command (bash, zsh, fish)
CONSOLE
Terminal fisik (keyboard + monitor), TTY1-TTY6 di Linux
SSH
Remote terminal via network (Secure Shell)
Memahami Prompt
Saat buka terminal, kamu melihat prompt seperti ini:
admin@web-server:~
admin@web-server:~$ _
BAGIAN
ARTI
CONTOH
Username
User yang login
admin
@
Pemisah
@
Hostname
Nama server
web-server
:
Pemisah
:
~
Current directory (~ = home)
~ atau /home/admin
$
Ordinary user
$
#
Root user (superuser)
#
PENTING: Perhatikan simbol di akhir prompt! $ = ordinary user, # = root. Command berbahaya sebagai root bisa merusak sistem!
Shortcut Penting
SHORTCUT
FUNGSI
Tab
Auto-complete command/file/directory
Ctrl + C
Cancel/stop command yang sedang berjalan
Ctrl + Z
Suspend command (bisa dilanjut dengan fg/bg)
Ctrl + D
Logout / EOF
Ctrl + L
Clear screen (seperti clear)
Ctrl + A
Pindah ke awal baris
Ctrl + E
Pindah ke akhir baris
Ctrl + R
Search history command
↑ / ↓
Navigate history command
Ctrl + U
Hapus dari cursor ke awal baris
Ctrl + K
Hapus dari cursor ke akhir baris
Ctrl + W
Hapus kata sebelum cursor
Mendapatkan Bantuan
man
Manual pages - dokumentasi lengkap
mancommand
manual
admin@web-server:~$ man lsLS(1) User Commands LS(1)NAME ls - list directory contentsSYNOPSIS ls [OPTION]... [FILE]...DESCRIPTION List information about the FILEs (the current directory by default). -a, --all do not ignore entries starting with ....Manual page ls(1) line 1 (press h for help or q to quit)_
KEY
FUNGSI
q
Keluar dari man
/
Search dalam manual
n
Next match (setelah search)
Space
Page down
b
Page up
h
Help
--help
Quick help - ringkasan singkat
command--help
bash
admin@web-server:~$ ls --helpUsage: ls [OPTION]... [FILE]...List information about the FILEs (the current directory by default).... -a, --all do not ignore entries starting with . -l use a long listing format -h, --human-readable with -l, print sizes in human readable format..._
whatis
Deskripsi singkat command
whatiscommand
bash
admin@web-server:~$ whatis lsls (1) - list directory contentsls (1p) - list directory contents_
type
Cek jenis command (alias, builtin, external)
typecommand
bash
admin@web-server:~$ type lsls is aliased to `ls --color=auto'admin@web-server:~$ type cdcd is a shell builtinadmin@web-server:~$ type python3python3 is /usr/bin/python3_
TIPS: Gunakan man untuk dokumentasi lengkap, --help untuk ringkasan cepat, whatis untuk deskripsi singkat.
KOMPETENSI SUB-BAB 01
Memahami perbedaan terminal, shell, console
Menghafal shortcut terminal penting
Mampu mendapatkan bantuan dengan man, --help, whatis
02
SUB-BAB 02 NAVIGATION
NAVIGASI DIREKTORI (ls, cd, pwd)
pwd - Print Working Directory
pwd
Tampilkan current directory
pwd [-L|-P]
OPTION
FUNGSI
-L
Logical - tampilkan path dengan symlink (default)
-P
Physical - tampilkan path fisik sebenarnya
bash
admin@web-server:~$ pwd/home/adminadmin@web-server:~$ cd /var/logadmin@web-server:/var/log$ pwd/var/log_
cd - Change Directory
cd
Pindah directory
cd [directory]
PATH
ARTI
CONTOH
cd atau cd ~
Ke home directory
/home/admin
cd ..
Naik 1 level (parent)
dari /var/log ke /var
cd ../..
Naik 2 level
dari /var/log ke /
cd -
Ke directory sebelumnya
toggle between 2 last dirs
cd /path
Absolute path (dari root)
cd /etc/nginx
cd dir
Relative path (dari current)
cd documents
bash
admin@web-server:~$ cd /var/logadmin@web-server:/var/log$ cd ..admin@web-server:/var$ cd -/var/logadmin@web-server:/var/log$ cdadmin@web-server:~$ cd ../..admin@web-server:/$_
ls - List Directory Contents
ls
List isi directory
ls [options] [directory]
OPTION
FUNGSI
-l
Long format (detail: permission, owner, size, date)
PERINGATAN:rm -rf sangat berbahaya! Salah ketik bisa hapus data penting. Selalu double-check path. Pertimbangkan pakai rm -ri untuk safety.
ln - Link
ln
Buat link (hard link atau symlink)
ln [options] target [link_name]
bash
admin@web-server:~$ ln file.txt hardlink.txt# Buat hard linkadmin@web-server:~$ ln -s file.txt symlink.txt# Buat symbolic link (shortcut)admin@web-server:~$ ls -l-rw-r--r-- 2 admin admin 1234 Sep 7 10:30 file.txt-rw-r--r-- 2 admin admin 1234 Sep 7 10:30 hardlink.txtlrwxrwxrwx 1 admin admin 8 Sep 7 10:30 symlink.txt -> file.txt_
KOMPETENSI SUB-BAB 04
Mampu buat directory dengan mkdir (termasuk -p)
Mampu buat file kosong dengan touch
Mampu copy dengan cp (file & directory)
Mampu move/rename dengan mv
Mampu hapus dengan rm
Membedakan hard link dan symlink
05
SUB-BAB 05 VIEWING
VIEWING FILE
cat - Concatenate
cat
Tampilkan isi file atau gabungkan file
cat [options] file
OPTION
FUNGSI
-n
Nomori baris
-b
Nomori baris non-blank
-s
Squeeze blank lines
bash
admin@web-server:~$ cat file.txtLine 1Line 2Line 3admin@web-server:~$ cat -n file.txt 1 Line 1 2 Line 2 3 Line 3admin@web-server:~$ cat file1.txt file2.txt > combined.txt# Gabungkan 2 file ke file baru_
less - Pager
less
Lihat file dengan pager (scroll up/down)
lessfile
KEY
FUNGSI
Space atau f
Page down
b
Page up
g
Go to first line
G
Go to last line
/pattern
Search forward
?pattern
Search backward
n
Next match
N
Previous match
q
Quit
h
Help
less /var/log/syslog
Sep 7 10:30:15 web-server systemd[1]: Started Session 1 of User admin.Sep 7 10:30:16 web-server kernel: [ 123.456] EXT4-fs (sda2): mountedSep 7 10:30:17 web-server sshd[1234]: Server listening on 0.0.0.0 port 22.../var/log/syslog (END)_
head - Awal File
head
Tampilkan awal file
head [options] file
bash
admin@web-server:~$ head /etc/passwdroot:x:0:0:root:/root:/bin/bashdaemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologinbin:x:2:2:bin:/bin:/usr/sbin/nologinsys:x:3:3:sys:/dev:/usr/sbin/nologinsync:x:4:65534:sync:/bin:/bin/syncgames:x:5:60:games:/usr/games:/usr/sbin/nologinman:x:6:12:man:/var/cache/man:/usr/sbin/nologinlp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologinmail:x:8:8:mail:/var/mail:/usr/sbin/nologinnews:x:9:9:news:/var/spool/news:/usr/sbin/nologinadmin@web-server:~$ head -n 5 /etc/passwdroot:x:0:0:root:/root:/bin/bashdaemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologinbin:x:2:2:bin:/bin:/usr/sbin/nologinsys:x:3:3:sys:/dev:/usr/sbin/nologinsync:x:4:65534:sync:/bin:/bin/sync_
tail - Akhir File
tail
Tampilkan akhir file
tail [options] file
OPTION
FUNGSI
-n N
Tampilkan N baris terakhir
-f
Follow - tampilkan baris baru real-time
-F
Like -f, tapi retry jika file di-recreate
bash
admin@web-server:~$ tail -n 5 /var/log/syslogSep 7 10:30:11 web-server systemd[1]: Started Session 1.Sep 7 10:30:12 web-server kernel: [ 123.456] EXT4-fs mountedSep 7 10:30:13 web-server sshd[1234]: Server listening on 0.0.0.0Sep 7 10:30:14 web-server sshd[1234]: Server listening on :: port 22Sep 7 10:30:15 web-server systemd[1]: Started OpenBSD Secure Shelladmin@web-server:~$ tail -f /var/log/syslog# Real-time monitoring - tekan Ctrl+C untuk stopSep 7 10:30:16 web-server kernel: new message...Sep 7 10:30:17 web-server systemd: another message...^C_
TIPS:tail -f sangat berguna untuk monitoring log real-time saat troubleshooting.
KOMPETENSI SUB-BAB 05
Mampu tampilkan isi file dengan cat
Mampu browse file dengan less
Mampu lihat awal file dengan head
Mampu lihat akhir file dengan tail (termasuk -f)
06
SUB-BAB 06 EDITOR
TEXT EDITOR (nano)
nano - Simple Text Editor
nano adalah text editor sederhana yang user-friendly. Cocok untuk pemula karena shortcut ditampilkan di bagian bawah layar.
nano
Edit text file
nano [options] [file]
OPTION
FUNGSI
-l
Tampilkan line numbers
-m
Enable mouse support
-w
Disable line wrapping
-B
Backup file saat save
nano config.txt
GNU nano 6.2 config.txtThis is a config fileLine 2 of the fileLine 3 with some text^G Help ^O Write Out ^W Where Is ^K Cut ^T Execute^X Exit ^R Read File ^\ Replace ^U Paste ^J Justify_
Shortcut Penting nano
SHORTCUT
FUNGSI
Ctrl + O
Save (Write Out)
Ctrl + X
Exit (dengan prompt save jika ada perubahan)
Ctrl + K
Cut line
Ctrl + U
Paste (Uncut)
Ctrl + W
Search (Where Is)
Ctrl + \
Replace
Ctrl + _
Go to line number
Ctrl + G
Help
Alt + A
Start selection (untuk cut/copy)
Alt + 6
Copy selection
Alt + T
Cut selection
TIPS: Untuk editor yang lebih advanced, pelajari vim atau emacs. Tapi untuk pemula, nano sudah cukup untuk sebagian besar tugas.
KOMPETENSI SUB-BAB 06
Mampu buka dan edit file dengan nano
Menghafal shortcut nano penting
Mampu save dan exit dengan benar
07
SUB-BAB 07 SEARCH
SEARCH & FIND
grep - Search Text in Files
grep
Global Regular Expression Print - cari text dalam file
grep [options] patternfile
OPTION
FUNGSI
-i
Case-insensitive
-r atau -R
Recursive (cari di semua file dalam directory)
-n
Tampilkan nomor baris
-v
Invert match (tampilkan baris yang TIDAK match)
-c
Count (hitung jumlah match)
-l
List files with matches
-w
Match whole word
-E
Extended regex
bash
admin@web-server:~$ grep "error" /var/log/syslogSep 7 10:30:15 web-server kernel: error in moduleSep 7 10:30:16 web-server app: error occurredadmin@web-server:~$ grep -i "ERROR" /var/log/syslog# Case-insensitive, match ERROR, error, Error, dlladmin@web-server:~$ grep -rn "error" /var/log//var/log/syslog:15:error in module/var/log/syslog:16:error occurred/var/log/auth.log:5:authentication erroradmin@web-server:~$ grep -c "error" /var/log/syslog15admin@web-server:~$ grep -l "error" /var/log/*/var/log/syslog/var/log/auth.logadmin@web-server:~$ grep -v "info" /var/log/syslog# Tampilkan baris yang TIDAK mengandung "info"_
find - Cari File
find
Cari file berdasarkan kriteria
findpath [options] [expression]
OPTION
FUNGSI
-name pattern
Cari berdasarkan nama (case-sensitive)
-iname pattern
Cari berdasarkan nama (case-insensitive)
-type f
File saja
-type d
Directory saja
-size +N
Ukuran lebih dari N (c=bytes, k=KB, M=MB, G=GB)
-mtime +N
Dimodifikasi lebih dari N hari lalu
-user username
File milik user tertentu
-exec cmd {} \;
Jalankan command pada hasil
bash
admin@web-server:~$ find /home -name "*.txt"/home/admin/file.txt/home/admin/docs/readme.txtadmin@web-server:~$ find / -type f -size +100M/var/log/large-file.log/var/lib/docker/image/...admin@web-server:~$ find /var/log -mtime +7# File yang dimodifikasi lebih dari 7 hari laluadmin@web-server:~$ find /tmp -type f -delete# Hapus semua file di /tmp (HATI-HATI!)admin@web-server:~$ find /home -name "*.log" -exec ls -lh {} \;-rw-r--r-- 1 admin admin 1.2M Sep 7 10:30 /home/admin/app.log_
which & whereis
which
Lokasi executable command
whichcommand
bash
admin@web-server:~$ which python3/usr/bin/python3admin@web-server:~$ which ls/usr/bin/ls_
Mampu cari lokasi executable dengan which dan whereis
08
SUB-BAB 08 PIPE
PIPE & REDIRECT
Pipe (|)
Pipe menghubungkan output satu command sebagai input command berikutnya. Ini memungkinkan kombinasi command untuk tugas kompleks.
|
Pipe - output jadi input command berikutnya
command1 | command2 | command3
bash
admin@web-server:~$ ls -l | grep ".txt"# List semua file, lalu filter hanya yang .txtadmin@web-server:~$ ps aux | grep nginx# List process, cari yang nginxadmin@web-server:~$ cat file.txt | sort | uniq -c | sort -nr# Sort → unik → count → sort by count descendingadmin@web-server:~$ ls -l | sort -k5 -n -r | head -5# Sort by size (kolom 5), numeric, reverse, tampilkan 5 teratas_
Redirection
>, >>, 2>
Redirect output/error ke file
command > file# stdout ke file (overwrite)command >> file# stdout ke file (append)command 2> file# stderr ke filecommand > file 2>&1 # stdout & stderr ke file yang samacommand &> file# stdout & stderr ke file (shortcut)command < file# input dari file
bash
admin@web-server:~$ ls -l > files.txt# Output ls disimpan ke files.txtadmin@web-server:~$ echo "new line" >> files.txt# Tambahkan baris ke akhir fileadmin@web-server:~$ find / -name "*.log" 2> errors.txt# Error (permission denied) disimpan ke errors.txtadmin@web-server:~$ sort file.txt | uniq > unique.txt# Sort file, unik, simpan ke unique.txt_
tee - Output ke Screen DAN File
tee
Output ke screen dan simpan ke file sekaligus
command | teefile
bash
admin@web-server:~$ ls -l | tee files.txt# Tampilkan di screen DAN simpan ke files.txtadmin@web-server:~$ ls -l | tee -a files.txt# -a = append (tambahkan ke file)_
xargs - Execute Command dari Input
xargs
Build dan execute command dari standard input
command | xargscommand
bash
admin@web-server:~$ find . -name "*.log" | xargs rm# Cari file .log, lalu hapus satu per satuadmin@web-server:~$ echo "file1 file2 file3" | xargs touch# Buat 3 file sekaligusadmin@web-server:~$ cat files.txt | xargs -I {} cp {} /backup/# Copy setiap file di files.txt ke /backup/_
KOMPETENSI SUB-BAB 08
Mampu gunakan pipe untuk chaining command
Mampu redirect output/error ke file
Mampu gunakan tee untuk output ke screen dan file
Mampu gunakan xargs untuk execute command dari input
09
SUB-BAB 09 PERMISSION
PERMISSION (chmod, chown, chgrp)
Memahami Permission
permission breakdown
- rwx r-x r--^ ^^^ ^^^ ^^^| | | └─ other (semua orang lain)| | └─ group (group owner)| └─ user (owner)└─ file type (- = file, d = directory, l = symlink)r = read (4)w = write (2)x = execute (1)- = no permission (0)Numeric:rwx = 4+2+1 = 7r-x = 4+0+1 = 5rw- = 4+2+0 = 6r-- = 4+0+0 = 4Contoh: -rwxr-xr-- = 754_
chmod - Change Mode
chmod
Ubah permission file/directory
chmod [options] modefile
Metode 1: Numeric (octal)
bash
admin@web-server:~$ chmod 755 script.sh# 7 = rwx (owner), 5 = r-x (group), 5 = r-x (other)admin@web-server:~$ chmod 644 file.txt# 6 = rw- (owner), 4 = r-- (group), 4 = r-- (other)admin@web-server:~$ chmod 700 private-dir/# Hanya owner yang bisa aksesadmin@web-server:~$ chmod 600 secret.txt# Hanya owner bisa read/write_
Metode 2: Symbolic
bash
admin@web-server:~$ chmod u+x script.sh# u = user (owner), +x = tambah executeadmin@web-server:~$ chmod g-w file.txt# g = group, -w = hapus writeadmin@web-server:~$ chmod o=r file.txt# o = other, =r = set read onlyadmin@web-server:~$ chmod a+x script.sh# a = all (u+g+o), +x = tambah execute untuk semuaadmin@web-server:~$ chmod u=rwx,g=rx,o=r file.txt# Set sekaligus: owner=rwx, group=rx, other=r_
Permission Umum
PERMISSION
NUMERIC
USE CASE
rw-r--r--
644
File biasa
rwxr-xr-x
755
Directory, executable
rw-------
600
File privat
rwx------
700
Directory privat
rw-r-----
640
File group-restricted
rwxrwxr-x
775
Collaborative directory
chown - Change Owner
chown
Ubah owner dan/atau group file
chown [options] owner[:group] file
bash
admin@web-server:~$ sudo chown newuser file.txt# Ubah owner menjadi newuseradmin@web-server:~$ sudo chown newuser:newgroup file.txt# Ubah owner DAN group sekaligusadmin@web-server:~$ sudo chown :newgroup file.txt# Ubah group saja (owner tetap)admin@web-server:~$ sudo chown -R newuser:newgroup directory/# -R = recursive, terapkan ke semua isi directory_
chgrp - Change Group
chgrp
Ubah group file
chgrp [options] groupfile
bash
admin@web-server:~$ sudo chgrp developers project/# Ubah group menjadi developersadmin@web-server:~$ sudo chgrp -R developers project/# -R = recursive_
KOMPETENSI SUB-BAB 09
Memahami sistem permission Linux (rwx)
Mampu gunakan chmod (numeric & symbolic)
Mampu gunakan chown dan chgrp
Tahu permission umum untuk file & directory
10
SUB-BAB 10 USER
USER & GROUP MANAGEMENT
User Management
useradd
Buat user baru
useradd [options] username
OPTION
FUNGSI
-m
Buat home directory
-s /bin/bash
Set default shell
-g group
Set primary group
-G group1,group2
Tambah ke group tambahan
-c "comment"
Full name/comment
bash
admin@web-server:~$ sudo useradd -m -s /bin/bash newuser# Buat user dengan home directory dan bash shelladmin@web-server:~$ sudo useradd -m -s /bin/bash -G sudo,developers john# Buat user john, tambah ke group sudo dan developersadmin@web-server:~$ sudo passwd newuserNew password: ••••••••Retype new password: ••••••••passwd: password updated successfully_
usermod
Modifikasi user
usermod [options] username
bash
admin@web-server:~$ sudo usermod -aG sudo username# Tambah user ke group sudoadmin@web-server:~$ sudo usermod -s /bin/zsh username# Ganti shell useradmin@web-server:~$ sudo usermod -L username# Lock account (tidak bisa login)admin@web-server:~$ sudo usermod -U username# Unlock accountadmin@web-server:~$ sudo usermod -e 2026-12-31 username# Set expiration date_
userdel
Hapus user
userdel [options] username
bash
admin@web-server:~$ sudo userdel username# Hapus user (home directory tetap ada)admin@web-server:~$ sudo userdel -r username# -r = hapus home directory juga_
Group Management
groupadd / groupdel
Buat/hapus group
groupaddgroupnamegroupdelgroupname
bash
admin@web-server:~$ sudo groupadd developers# Buat group baruadmin@web-server:~$ sudo groupdel developers# Hapus group_
Info User & Group
id, whoami, groups
Info user yang login
bash
admin@web-server:~$ whoamiadminadmin@web-server:~$ iduid=1000(admin) gid=1000(admin) groups=1000(admin),27(sudo)admin@web-server:~$ id usernameuid=1001(username) gid=1001(username) groups=1001(username)admin@web-server:~$ groupsadmin sudoadmin@web-server:~$ groups usernameusername : username developers_
top - 10:30:15 up 5 days, 3:15, 1 user, load average: 0.08, 0.03, 0.01Tasks: 120 total, 1 running, 119 sleeping, 0 stopped, 0 zombie%Cpu(s): 2.3 us, 1.0 sy, 0.0 ni, 96.5 id, 0.2 wa, 0.0 hi, 0.0 siMiB Mem : 1987.2 total, 1456.8 free, 220.4 used, 310.0 buff/cacheMiB Swap: 2048.0 total, 2048.0 free, 0.0 used. 1650.4 avail Mem PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 1234 root 20 0 72340 5640 4560 S 0.3 0.3 0:00.45 sshd 1456 admin 20 0 21568 3456 2800 R 0.3 0.2 0:00.12 topCommands:h/? : help q : quit k : kill r : reniceM : sort by MEM P : sort by CPU T : sort by TIME_
KEY
FUNGSI
q
Keluar
k
Kill process (masukkan PID)
r
Renice process (ubah priority)
M
Sort by memory usage
P
Sort by CPU usage
T
Sort by time
h atau ?
Help
Space
Refresh
kill - Terminate Process
kill
Kirim signal ke process
kill [-signal] PID
bash
admin@web-server:~$ kill 1234# Kirim SIGTERM (signal 15) - graceful terminationadmin@web-server:~$ kill -9 1234# Kirim SIGKILL (signal 9) - force killadmin@web-server:~$ kill -SIGTERM 1234# Sama dengan kill 1234_
SIGNAL
NUMBER
DESKRIPSI
SIGTERM
15
Graceful termination (default)
SIGKILL
9
Force kill (tidak bisa di-catch)
SIGHUP
1
Hangup (reload config)
SIGINT
2
Interrupt (Ctrl+C)
SIGSTOP
17
Stop process
SIGCONT
19
Continue stopped process
killall & pkill
killall, pkill
Kill process by name
bash
admin@web-server:~$ killall nginx# Kill semua process bernama nginxadmin@web-server:~$ pkill nginx# Kill process yang match pattern "nginx"admin@web-server:~$ pkill -u username# Kill semua process milik user_
Background & Foreground
bg, fg, jobs
Manage background/foreground process
bash
admin@web-server:~$ long-running-command &[1] 1234# Jalankan di background (& di akhir)admin@web-server:~$ jobs[1]+ Running long-running-command &admin@web-server:~$ fg %1# Bawa job 1 ke foregroundadmin@web-server:~$ Ctrl+Z[1]+ Stopped long-running-command# Suspend process (Ctrl+Z)admin@web-server:~$ bg %1# Lanjutkan di background_
KOMPETENSI SUB-BAB 11
Mampu lihat process dengan ps
Mampu monitor real-time dengan top
Mampu kill process dengan kill/killall/pkill
Mampu manage background/foreground process
12
SUB-BAB 12 PACKAGE
PACKAGE MANAGEMENT (apt)
apt - Advanced Package Tool
apt
Package manager Debian
bash
# Update package listadmin@web-server:~$ sudo apt updateHit:1 http://deb.debian.org/debian bookworm InReleaseHit:2 http://deb.debian.org/debian bookworm-updates InReleaseHit:3 http://security.debian.org bookworm-security InReleaseReading package lists... DoneBuilding dependency tree... Done# Upgrade packagesadmin@web-server:~$ sudo apt upgrade -yReading package lists... DoneThe following packages will be upgraded: package1 package2 package33 upgraded, 0 newly installed, 0 to remove# Install packageadmin@web-server:~$ sudo apt install nginx -yReading package lists... DoneThe following NEW packages will be installed: nginx nginx-common# Remove packageadmin@web-server:~$ sudo apt remove nginx# Remove package (config files tetap ada)admin@web-server:~$ sudo apt purge nginx# Remove package + config files# Autoremove (hapus dependency tidak terpakai)admin@web-server:~$ sudo apt autoremove -y# Search packageadmin@web-server:~$ apt search nginx# Info packageadmin@web-server:~$ apt show nginx# List installed packagesadmin@web-server:~$ apt list --installed_
TIPS: Selalu jalankan apt update sebelum apt install atau apt upgrade untuk memastikan package list terbaru.
KOMPETENSI SUB-BAB 12
Mampu update package list dengan apt update
Mampu upgrade packages dengan apt upgrade
Mampu install dan remove packages
Mampu search dan info package
13
SUB-BAB 13 SERVICE
SERVICE MANAGEMENT (systemctl)
systemctl - Control systemd
systemctl
Control systemd system and service manager
bash
# Start serviceadmin@web-server:~$ sudo systemctl start nginx# Stop serviceadmin@web-server:~$ sudo systemctl stop nginx# Restart serviceadmin@web-server:~$ sudo systemctl restart nginx# Reload configuration (tanpa restart)admin@web-server:~$ sudo systemctl reload nginx# Status serviceadmin@web-server:~$ systemctl status nginx● nginx.service - A high performance web server and a reverse proxy server Loaded: loaded (/lib/systemd/system/nginx.service; enabled) Active: active (running) since Mon 2026-09-07 10:30:15 WIB; 5min ago Docs: man:nginx(8) Process: 1234 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS) Process: 1235 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS) Main PID: 1236 (nginx) Tasks: 3 (limit: 2340) Memory: 5.2M CPU: 123ms CGroup: /system.slice/nginx.service# Enable service (start on boot)admin@web-server:~$ sudo systemctl enable nginxCreated symlink /etc/systemd/system/multi-user.target.wants/nginx.service# Disable service (tidak start on boot)admin@web-server:~$ sudo systemctl disable nginx# List all servicesadmin@web-server:~$ systemctl list-units --type=service# List failed servicesadmin@web-server:~$ systemctl --failed_
journalctl - View Logs
journalctl
View systemd journal logs
bash
# Lihat semua logsadmin@web-server:~$ journalctl# Log untuk service tertentuadmin@web-server:~$ journalctl -u nginx# Real-time logsadmin@web-server:~$ journalctl -f# Logs dari 1 jam terakhiradmin@web-server:~$ journalctl --since "1 hour ago"# Logs hari iniadmin@web-server:~$ journalctl --since today# Logs dengan priority tertentuadmin@web-server:~$ journalctl -p err# err = error, warning, notice, info, debug_
# Lihat IP addressadmin@web-server:~$ ip addr show1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 inet 127.0.0.1/8 scope host lo2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 inet 192.168.1.10/24 brd 192.168.1.255 scope global eth0# Shortcutadmin@web-server:~$ ip a# Lihat routing tableadmin@web-server:~$ ip route showdefault via 192.168.1.1 dev eth0192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.10# Shortcutadmin@web-server:~$ ip r# Lihat link statusadmin@web-server:~$ ip link show_
admin@web-server:~$ traceroute google.comtraceroute to google.com (142.250.1.100), 30 hops max, 60 byte packets 1 192.168.1.1 (192.168.1.1) 1.234 ms 1.123 ms 1.098 ms 2 10.0.0.1 (10.0.0.1) 5.678 ms 5.456 ms 5.321 ms 3 * * * 4 142.250.1.100 (142.250.1.100) 12.345 ms 12.123 ms 12.098 ms_
# 1. Cek system infouname-alsb_release-auptimefree-hdf-h# 2. Cek processtopps aux | grep nginx
# 3. Cek networkip addr showip route showss-tulpn# 4. Cek logsjournalctl-u nginx
journalctl-p err --since"1 hour ago"# 5. Test connectivityping-c 4 8.8.8.8
ping-c 4 google.com
dig google.com
traceroute google.com
# 6. Cek servicesystemctl status nginx
systemctl status ssh
# 7. Cek disk usagedu-sh /var/log/*
du-sh /var/www/*
Checklist Harian Administrator
TUGAS
COMMAND
FREKUENSI
Cek uptime
uptime
Harian
Cek disk usage
df -h
Harian
Cek memory
free -h
Harian
Update sistem
sudo apt update && sudo apt upgrade
Mingguan
Cek logs
journalctl -p err --since "1 day ago"
Harian
Cek service
systemctl --failed
Harian
Backup
Custom backup script
Harian/Mingguan
Security audit
sudo lynis audit system
Bulanan
SELAMAT! Kamu telah menyelesaikan Volume 03 - Linux Command Line Mastery. Dari navigasi direktori hingga administrasi server, kamu sekarang menguasai command line Linux. Di Volume 04, kita akan dalami File System & Storage Management lebih mendalam. Sampai jumpa!
KOMPETENSI SUB-BAB 15
Mampu setup web server dari nol
Mampu setup user & SSH
Mampu monitoring & troubleshooting
Memahami checklist harian administrator
VOLUME 03 SELESAI
SELAMAT!
Kamu telah menyelesaikan Volume 03 - Linux Command Line Mastery. 15 sub-bab dari pengenalan terminal hingga praktik administrasi server. Kamu sekarang menguasai command line Linux dengan 100+ command. Di Volume 04, kita akan dalami File System & Storage Management. Sampai jumpa!