ABDURROZAK
HOME ABOUT ME MICROSITE KONTAK PERSEMBAHAN HELP
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-BAB15 LEVELCommand Line WAKTU150 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:~$ _
BAGIANARTICONTOH
UsernameUser yang loginadmin
@Pemisah@
HostnameNama serverweb-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

SHORTCUTFUNGSI
TabAuto-complete command/file/directory
Ctrl + CCancel/stop command yang sedang berjalan
Ctrl + ZSuspend command (bisa dilanjut dengan fg/bg)
Ctrl + DLogout / EOF
Ctrl + LClear screen (seperti clear)
Ctrl + APindah ke awal baris
Ctrl + EPindah ke akhir baris
Ctrl + RSearch history command
↑ / ↓Navigate history command
Ctrl + UHapus dari cursor ke awal baris
Ctrl + KHapus dari cursor ke akhir baris
Ctrl + WHapus kata sebelum cursor

Mendapatkan Bantuan

man
Manual pages - dokumentasi lengkap
man command
manual
admin@web-server:~$ man ls LS(1) User Commands LS(1) NAME ls - list directory contents SYNOPSIS 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)_
KEYFUNGSI
qKeluar dari man
/Search dalam manual
nNext match (setelah search)
SpacePage down
bPage up
hHelp
--help
Quick help - ringkasan singkat
command --help
bash
admin@web-server:~$ ls --help Usage: 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
whatis command
bash
admin@web-server:~$ whatis ls ls (1) - list directory contents ls (1p) - list directory contents_
type
Cek jenis command (alias, builtin, external)
type command
bash
admin@web-server:~$ type ls ls is aliased to `ls --color=auto' admin@web-server:~$ type cd cd is a shell builtin admin@web-server:~$ type python3 python3 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]
OPTIONFUNGSI
-LLogical - tampilkan path dengan symlink (default)
-PPhysical - tampilkan path fisik sebenarnya
bash
admin@web-server:~$ pwd /home/admin admin@web-server:~$ cd /var/log admin@web-server:/var/log$ pwd /var/log_

cd - Change Directory

cd
Pindah directory
cd [directory]
PATHARTICONTOH
cd atau cd ~Ke home directory/home/admin
cd ..Naik 1 level (parent)dari /var/log ke /var
cd ../..Naik 2 leveldari /var/log ke /
cd -Ke directory sebelumnyatoggle between 2 last dirs
cd /pathAbsolute path (dari root)cd /etc/nginx
cd dirRelative path (dari current)cd documents
bash
admin@web-server:~$ cd /var/log admin@web-server:/var/log$ cd .. admin@web-server:/var$ cd - /var/log admin@web-server:/var/log$ cd admin@web-server:~$ cd ../.. admin@web-server:/$_

ls - List Directory Contents

ls
List isi directory
ls [options] [directory]
OPTIONFUNGSI
-lLong format (detail: permission, owner, size, date)
-aAll - termasuk hidden files (diawali .)
-hHuman-readable (size: KB, MB, GB)
-tSort by time (terbaru di atas)
-SSort by size (terbesar di atas)
-rReverse sort
-RRecursive - list semua subdirectory
-dDirectory saja (bukan isi)
-iTampilkan inode number
--color=autoWarnai output (directory=biru, exec=hijau)
bash
admin@web-server:~$ ls Desktop Documents Downloads Music Pictures Videos admin@web-server:~$ ls -la total 44 drwxr-xr-x 6 admin admin 4096 Sep 7 10:30 . drwxr-xr-x 3 root root 4096 Sep 7 09:00 .. -rw------- 1 admin admin 220 Sep 7 09:00 .bash_history -rw-r--r-- 1 admin admin 3771 Sep 7 09:00 .bashrc drwxr-xr-x 2 admin admin 4096 Sep 7 09:00 Desktop drwxr-xr-x 2 admin admin 4096 Sep 7 09:00 Documents admin@web-server:~$ ls -lh /var/log total 2.1M -rw-r--r-- 1 root root 45K Sep 7 10:30 syslog -rw-r----- 1 root adm 12K Sep 7 10:30 auth.log -rw-rw-r-- 1 root utmp 28K Sep 7 10:30 wtmp admin@web-server:~$ ls -lt total 44 drwxr-xr-x 2 admin admin 4096 Sep 7 10:30 Downloads drwxr-xr-x 2 admin admin 4096 Sep 7 10:25 Documents drwxr-xr-x 2 admin admin 4096 Sep 7 09:00 Desktop admin@web-server:~$ ls -lS total 44 drwxr-xr-x 2 admin admin 4096 Sep 7 10:30 Downloads drwxr-xr-x 2 admin admin 4096 Sep 7 10:25 Documents drwxr-xr-x 2 admin admin 4096 Sep 7 09:00 Desktop_

Memahami Output ls -l

output breakdown
-rw-r--r-- 1 admin admin 4096 Sep 7 10:30 file.txt ^^^^^^^^^^ ^ ^^^^^ ^^^^^ ^^^^ ^^^^^^^^^^^ ^^^^^^^^ | | | | | | | | | | | | | └─ nama file | | | | | └─ tanggal modifikasi | | | | └─ ukuran (bytes) | | | └─ group owner | | └─ user owner | └─ jumlah hard links └─ permission (rwxrwxrwx)

Permission Breakdown

permission
- 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)
TIPS: Kombinasi ls -lah adalah yang paling sering dipakai - menampilkan semua file dengan detail dan ukuran human-readable.
KOMPETENSI SUB-BAB 02
  • Mampu gunakan pwd untuk cek current directory
  • Mampu navigasi dengan cd (absolute, relative, ~, -, ..)
  • Mampu gunakan ls dengan berbagai option
  • Memahami output ls -l dan permission
03
SUB-BAB 03 INFO

INFO FILE & SISTEM

file - Identifikasi Tipe File

file
Identifikasi tipe file
file [options] filename
bash
admin@web-server:~$ file /etc/passwd /etc/passwd: ASCII text admin@web-server:~$ file /bin/ls /bin/ls: ELF 64-bit LSB pie executable, x86-64 admin@web-server:~$ file /var/log /var/log: directory admin@web-server:~$ file image.png image.png: PNG image data, 800 x 600, 8-bit/color RGBA_

stat - Detail File

stat
Detail info file (permission, size, time, inode)
stat filename
bash
admin@web-server:~$ stat /etc/passwd File: /etc/passwd Size: 2034 Blocks: 8 IO Block: 4096 regular file Device: 801h/2049d Inode: 131234 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2026-09-07 10:30:15.123456789 +0700 Modify: 2026-09-01 08:15:30.987654321 +0700 Change: 2026-09-01 08:15:30.987654321 +0700 Birth: -_

df - Disk Free

df
Lihat disk usage filesystem
df [options]
OPTIONFUNGSI
-hHuman-readable (KB, MB, GB)
-HHuman-readable (SI units, 1000-based)
-TTampilkan filesystem type
-iTampilkan inode usage
-t typeFilter by filesystem type
bash
admin@web-server:~$ df -h Filesystem Size Used Avail Use% Mounted on tmpfs 393M 1.4M 392M 1% /run /dev/sda2 19G 3.2G 15G 18% / tmpfs 2.0G 0 2.0G 0% /dev/shm tmpfs 5.0M 0 5.0M 0% /run/lock /dev/sda1 512M 5.8M 507M 2% /boot/efi tmpfs 393M 52K 393M 1% /run/user/1000 admin@web-server:~$ df -hT Filesystem Type Size Used Avail Use% Mounted on tmpfs tmpfs 393M 1.4M 392M 1% /run /dev/sda2 ext4 19G 3.2G 15G 18% / /dev/sda1 vfat 512M 5.8M 507M 2% /boot/efi_

du - Disk Usage

du
Lihat ukuran directory/file
du [options] [path]
OPTIONFUNGSI
-hHuman-readable
-sSummary (total saja)
-aAll files (bukan hanya directory)
--max-depth=NDepth level
bash
admin@web-server:~$ du -sh /var/log 45M /var/log admin@web-server:~$ du -sh /* 7.1M /bin 72M /boot 4.0K /cdrom 4.0K /dev 8.2M /etc 2.1G /home 650M /usr 380M /var admin@web-server:~$ du -sh /var/* --max-depth=0 12K /var/backups 45M /var/cache 45M /var/log 12M /var/lib_

free - Memory Usage

free
Lihat memory (RAM & swap) usage
free [options]
bash
admin@web-server:~$ free -h total used free shared buff/cache available Mem: 1.9Gi 220Mi 1.4Gi 4.0Mi 320Mi 1.6Gi Swap: 2.0Gi 0B 2.0Gi_

uptime - System Uptime

uptime
Lihat uptime & load average
uptime
bash
admin@web-server:~$ uptime 10:30:15 up 5 days, 3:15, 1 user, load average: 0.08, 0.03, 0.01_
FIELDARTI
10:30:15Current time
up 5 days, 3:15Uptime (sudah nyala 5 hari 3 jam 15 menit)
1 userJumlah user yang login
load averageAverage load (1, 5, 15 menit terakhir)
KOMPETENSI SUB-BAB 03
  • Mampu identifikasi tipe file dengan file
  • Mampu lihat detail file dengan stat
  • Mampu cek disk usage dengan df dan du
  • Mampu cek memory dengan free
  • Mampu cek uptime & load average
04
SUB-BAB 04 FILE OPS

MANIPULASI FILE & DIRECTORY

mkdir - Make Directory

mkdir
Buat directory baru
mkdir [options] directory
OPTIONFUNGSI
-pBuat parent directory jika belum ada
-mSet permission saat buat
-vVerbose (tampilkan pesan)
bash
admin@web-server:~$ mkdir projects admin@web-server:~$ mkdir -p projects/web/frontend mkdir: created directory 'projects/web' mkdir: created directory 'projects/web/frontend' admin@web-server:~$ mkdir -m 755 scripts admin@web-server:~$ ls -ld scripts drwxr-xr-x 2 admin admin 4096 Sep 7 10:30 scripts_

touch - Buat File Kosong

touch
Buat file kosong atau update timestamp
touch [options] filename
bash
admin@web-server:~$ touch file.txt admin@web-server:~$ touch file1.txt file2.txt file3.txt admin@web-server:~$ ls -l file.txt -rw-r--r-- 1 admin admin 0 Sep 7 10:30 file.txt_

cp - Copy

cp
Copy file atau directory
cp [options] source destination
OPTIONFUNGSI
-r atau -RRecursive (untuk directory)
-iInteractive (tanya sebelum overwrite)
-vVerbose (tampilkan progress)
-pPreserve attributes (permission, timestamp)
-aArchive (sama dengan -dR --preserve=all)
-uUpdate (copy hanya jika source lebih baru)
bash
admin@web-server:~$ cp file.txt backup.txt admin@web-server:~$ cp -r projects/ backup-projects/ admin@web-server:~$ cp -i file.txt existing.txt cp: overwrite 'existing.txt'? y admin@web-server:~$ cp -v file.txt /tmp/ 'file.txt' -> '/tmp/file.txt'_

mv - Move/Rename

mv
Move atau rename file/directory
mv [options] source destination
bash
admin@web-server:~$ mv old.txt new.txt # Rename file admin@web-server:~$ mv file.txt /tmp/ # Move file ke /tmp/ admin@web-server:~$ mv -i file.txt existing.txt mv: overwrite 'existing.txt'? y_

rm - Remove

rm
Hapus file atau directory
rm [options] filename
OPTIONFUNGSI
-r atau -RRecursive (untuk directory)
-fForce (tidak tanya konfirmasi)
-iInteractive (tanya sebelum hapus)
-vVerbose (tampilkan progress)
-rfRecursive + Force (HATI-HATI!)
bash
admin@web-server:~$ rm file.txt admin@web-server:~$ rm -r directory/ admin@web-server:~$ rm -i file.txt rm: remove regular file 'file.txt'? y admin@web-server:~$ rm -rf directory/ # HATI-HATI! Hapus tanpa tanya!_
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 link admin@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.txt lrwxrwxrwx 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
OPTIONFUNGSI
-nNomori baris
-bNomori baris non-blank
-sSqueeze blank lines
bash
admin@web-server:~$ cat file.txt Line 1 Line 2 Line 3 admin@web-server:~$ cat -n file.txt 1 Line 1 2 Line 2 3 Line 3 admin@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)
less file
KEYFUNGSI
Space atau fPage down
bPage up
gGo to first line
GGo to last line
/patternSearch forward
?patternSearch backward
nNext match
NPrevious match
qQuit
hHelp
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): mounted Sep 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/passwd root:x:0:0:root:/root:/bin/bash daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin bin:x:2:2:bin:/bin:/usr/sbin/nologin sys:x:3:3:sys:/dev:/usr/sbin/nologin sync:x:4:65534:sync:/bin:/bin/sync games:x:5:60:games:/usr/games:/usr/sbin/nologin man:x:6:12:man:/var/cache/man:/usr/sbin/nologin lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin mail:x:8:8:mail:/var/mail:/usr/sbin/nologin news:x:9:9:news:/var/spool/news:/usr/sbin/nologin admin@web-server:~$ head -n 5 /etc/passwd root:x:0:0:root:/root:/bin/bash daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin bin:x:2:2:bin:/bin:/usr/sbin/nologin sys:x:3:3:sys:/dev:/usr/sbin/nologin sync:x:4:65534:sync:/bin:/bin/sync_

tail - Akhir File

tail
Tampilkan akhir file
tail [options] file
OPTIONFUNGSI
-n NTampilkan N baris terakhir
-fFollow - tampilkan baris baru real-time
-FLike -f, tapi retry jika file di-recreate
bash
admin@web-server:~$ tail -n 5 /var/log/syslog Sep 7 10:30:11 web-server systemd[1]: Started Session 1. Sep 7 10:30:12 web-server kernel: [ 123.456] EXT4-fs mounted Sep 7 10:30:13 web-server sshd[1234]: Server listening on 0.0.0.0 Sep 7 10:30:14 web-server sshd[1234]: Server listening on :: port 22 Sep 7 10:30:15 web-server systemd[1]: Started OpenBSD Secure Shell admin@web-server:~$ tail -f /var/log/syslog # Real-time monitoring - tekan Ctrl+C untuk stop Sep 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]
OPTIONFUNGSI
-lTampilkan line numbers
-mEnable mouse support
-wDisable line wrapping
-BBackup file saat save
nano config.txt
GNU nano 6.2 config.txt This is a config file Line 2 of the file Line 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

SHORTCUTFUNGSI
Ctrl + OSave (Write Out)
Ctrl + XExit (dengan prompt save jika ada perubahan)
Ctrl + KCut line
Ctrl + UPaste (Uncut)
Ctrl + WSearch (Where Is)
Ctrl + \Replace
Ctrl + _Go to line number
Ctrl + GHelp
Alt + AStart selection (untuk cut/copy)
Alt + 6Copy selection
Alt + TCut 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] pattern file
OPTIONFUNGSI
-iCase-insensitive
-r atau -RRecursive (cari di semua file dalam directory)
-nTampilkan nomor baris
-vInvert match (tampilkan baris yang TIDAK match)
-cCount (hitung jumlah match)
-lList files with matches
-wMatch whole word
-EExtended regex
bash
admin@web-server:~$ grep "error" /var/log/syslog Sep 7 10:30:15 web-server kernel: error in module Sep 7 10:30:16 web-server app: error occurred admin@web-server:~$ grep -i "ERROR" /var/log/syslog # Case-insensitive, match ERROR, error, Error, dll admin@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 error admin@web-server:~$ grep -c "error" /var/log/syslog 15 admin@web-server:~$ grep -l "error" /var/log/* /var/log/syslog /var/log/auth.log admin@web-server:~$ grep -v "info" /var/log/syslog # Tampilkan baris yang TIDAK mengandung "info"_

find - Cari File

find
Cari file berdasarkan kriteria
find path [options] [expression]
OPTIONFUNGSI
-name patternCari berdasarkan nama (case-sensitive)
-iname patternCari berdasarkan nama (case-insensitive)
-type fFile saja
-type dDirectory saja
-size +NUkuran lebih dari N (c=bytes, k=KB, M=MB, G=GB)
-mtime +NDimodifikasi lebih dari N hari lalu
-user usernameFile 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.txt admin@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 lalu admin@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
which command
bash
admin@web-server:~$ which python3 /usr/bin/python3 admin@web-server:~$ which ls /usr/bin/ls_
whereis
Lokasi binary, source, dan manual page
whereis command
bash
admin@web-server:~$ whereis python3 python3: /usr/bin/python3 /usr/lib/python3 /usr/share/man/man1/python3.1.gz_
KOMPETENSI SUB-BAB 07
  • Mampu cari text dalam file dengan grep
  • Mampu cari file dengan find
  • 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 .txt admin@web-server:~$ ps aux | grep nginx # List process, cari yang nginx admin@web-server:~$ cat file.txt | sort | uniq -c | sort -nr # Sort → unik → count → sort by count descending admin@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 file command > file 2>&1 # stdout & stderr ke file yang sama command &> file # stdout & stderr ke file (shortcut) command < file # input dari file
bash
admin@web-server:~$ ls -l > files.txt # Output ls disimpan ke files.txt admin@web-server:~$ echo "new line" >> files.txt # Tambahkan baris ke akhir file admin@web-server:~$ find / -name "*.log" 2> errors.txt # Error (permission denied) disimpan ke errors.txt admin@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 | tee file
bash
admin@web-server:~$ ls -l | tee files.txt # Tampilkan di screen DAN simpan ke files.txt admin@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 | xargs command
bash
admin@web-server:~$ find . -name "*.log" | xargs rm # Cari file .log, lalu hapus satu per satu admin@web-server:~$ echo "file1 file2 file3" | xargs touch # Buat 3 file sekaligus admin@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 = 7 r-x = 4+0+1 = 5 rw- = 4+2+0 = 6 r-- = 4+0+0 = 4 Contoh: -rwxr-xr-- = 754_

chmod - Change Mode

chmod
Ubah permission file/directory
chmod [options] mode file

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 akses admin@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 execute admin@web-server:~$ chmod g-w file.txt # g = group, -w = hapus write admin@web-server:~$ chmod o=r file.txt # o = other, =r = set read only admin@web-server:~$ chmod a+x script.sh # a = all (u+g+o), +x = tambah execute untuk semua admin@web-server:~$ chmod u=rwx,g=rx,o=r file.txt # Set sekaligus: owner=rwx, group=rx, other=r_

Permission Umum

PERMISSIONNUMERICUSE CASE
rw-r--r--644File biasa
rwxr-xr-x755Directory, executable
rw-------600File privat
rwx------700Directory privat
rw-r-----640File group-restricted
rwxrwxr-x775Collaborative 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 newuser admin@web-server:~$ sudo chown newuser:newgroup file.txt # Ubah owner DAN group sekaligus admin@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] group file
bash
admin@web-server:~$ sudo chgrp developers project/ # Ubah group menjadi developers admin@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
OPTIONFUNGSI
-mBuat home directory
-s /bin/bashSet default shell
-g groupSet primary group
-G group1,group2Tambah 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 shell admin@web-server:~$ sudo useradd -m -s /bin/bash -G sudo,developers john # Buat user john, tambah ke group sudo dan developers admin@web-server:~$ sudo passwd newuser New 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 sudo admin@web-server:~$ sudo usermod -s /bin/zsh username # Ganti shell user admin@web-server:~$ sudo usermod -L username # Lock account (tidak bisa login) admin@web-server:~$ sudo usermod -U username # Unlock account admin@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
groupadd groupname groupdel groupname
bash
admin@web-server:~$ sudo groupadd developers # Buat group baru admin@web-server:~$ sudo groupdel developers # Hapus group_

Info User & Group

id, whoami, groups
Info user yang login
bash
admin@web-server:~$ whoami admin admin@web-server:~$ id uid=1000(admin) gid=1000(admin) groups=1000(admin),27(sudo) admin@web-server:~$ id username uid=1001(username) gid=1001(username) groups=1001(username) admin@web-server:~$ groups admin sudo admin@web-server:~$ groups username username : username developers_
KOMPETENSI SUB-BAB 10
  • Mampu menambah, modifikasi, dan hapus user
  • Mampu menambah, modifikasi, dan hapus group
  • Mampu cek info user dan group
11
SUB-BAB 11 PROCESS

PROCESS MANAGEMENT

ps - Process Status

ps
Lihat process yang berjalan
ps [options]
OPTIONFUNGSI
auxSemua process, semua user, dengan detail
-efFull format, semua process
-u usernameProcess milik user tertentu
bash
admin@web-server:~$ ps aux USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 1 0.0 0.4 169344 11520 ? Ss 10:00 0:02 /sbin/init root 2 0.0 0.0 0 0 ? S 10:00 0:00 [kthreadd] root 456 0.0 0.5 72340 5640 ? Ss 10:00 0:00 /usr/sbin/sshd admin 1234 0.0 0.3 21568 3456 pts/0 Ss 10:30 0:00 -bash admin 1456 0.0 0.2 38120 3200 pts/0 R+ 10:35 0:00 ps aux admin@web-server:~$ ps aux | grep nginx root 1234 0.0 0.5 72340 5640 ? Ss 10:00 0:00 nginx: master www-data 1235 0.0 0.3 72540 3456 ? S 10:00 0:00 nginx: worker_

top - Real-time Process Monitor

top
Real-time process monitor (interactive)
top
top
top - 10:30:15 up 5 days, 3:15, 1 user, load average: 0.08, 0.03, 0.01 Tasks: 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 si MiB Mem : 1987.2 total, 1456.8 free, 220.4 used, 310.0 buff/cache MiB 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 top Commands: h/? : help q : quit k : kill r : renice M : sort by MEM P : sort by CPU T : sort by TIME_
KEYFUNGSI
qKeluar
kKill process (masukkan PID)
rRenice process (ubah priority)
MSort by memory usage
PSort by CPU usage
TSort by time
h atau ?Help
SpaceRefresh

kill - Terminate Process

kill
Kirim signal ke process
kill [-signal] PID
bash
admin@web-server:~$ kill 1234 # Kirim SIGTERM (signal 15) - graceful termination admin@web-server:~$ kill -9 1234 # Kirim SIGKILL (signal 9) - force kill admin@web-server:~$ kill -SIGTERM 1234 # Sama dengan kill 1234_
SIGNALNUMBERDESKRIPSI
SIGTERM15Graceful termination (default)
SIGKILL9Force kill (tidak bisa di-catch)
SIGHUP1Hangup (reload config)
SIGINT2Interrupt (Ctrl+C)
SIGSTOP17Stop process
SIGCONT19Continue stopped process

killall & pkill

killall, pkill
Kill process by name
bash
admin@web-server:~$ killall nginx # Kill semua process bernama nginx admin@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 foreground admin@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 list admin@web-server:~$ sudo apt update Hit:1 http://deb.debian.org/debian bookworm InRelease Hit:2 http://deb.debian.org/debian bookworm-updates InRelease Hit:3 http://security.debian.org bookworm-security InRelease Reading package lists... Done Building dependency tree... Done # Upgrade packages admin@web-server:~$ sudo apt upgrade -y Reading package lists... Done The following packages will be upgraded: package1 package2 package3 3 upgraded, 0 newly installed, 0 to remove # Install package admin@web-server:~$ sudo apt install nginx -y Reading package lists... Done The following NEW packages will be installed: nginx nginx-common # Remove package admin@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 package admin@web-server:~$ apt search nginx # Info package admin@web-server:~$ apt show nginx # List installed packages admin@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 service admin@web-server:~$ sudo systemctl start nginx # Stop service admin@web-server:~$ sudo systemctl stop nginx # Restart service admin@web-server:~$ sudo systemctl restart nginx # Reload configuration (tanpa restart) admin@web-server:~$ sudo systemctl reload nginx # Status service admin@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 nginx Created 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 services admin@web-server:~$ systemctl list-units --type=service # List failed services admin@web-server:~$ systemctl --failed_

journalctl - View Logs

journalctl
View systemd journal logs
bash
# Lihat semua logs admin@web-server:~$ journalctl # Log untuk service tertentu admin@web-server:~$ journalctl -u nginx # Real-time logs admin@web-server:~$ journalctl -f # Logs dari 1 jam terakhir admin@web-server:~$ journalctl --since "1 hour ago" # Logs hari ini admin@web-server:~$ journalctl --since today # Logs dengan priority tertentu admin@web-server:~$ journalctl -p err # err = error, warning, notice, info, debug_
KOMPETENSI SUB-BAB 13
  • Mampu start/stop/restart/reload service
  • Mampu enable/disable service
  • Mampu cek status service
  • Mampu lihat logs dengan journalctl
14
SUB-BAB 14 NETWORK

NETWORK COMMANDS

ip - Network Configuration

ip
Show/manipulate routing, network devices, interfaces
bash
# Lihat IP address admin@web-server:~$ ip addr show 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 inet 127.0.0.1/8 scope host lo 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 inet 192.168.1.10/24 brd 192.168.1.255 scope global eth0 # Shortcut admin@web-server:~$ ip a # Lihat routing table admin@web-server:~$ ip route show default via 192.168.1.1 dev eth0 192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.10 # Shortcut admin@web-server:~$ ip r # Lihat link status admin@web-server:~$ ip link show_

Connectivity Testing

ping
Test connectivity ke host
bash
admin@web-server:~$ ping 8.8.8.8 PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data. 64 bytes from 8.8.8.8: icmp_seq=1 ttl=117 time=12.3 ms 64 bytes from 8.8.8.8: icmp_seq=2 ttl=117 time=11.8 ms ^C --- 8.8.8.8 ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 1001ms rtt min/avg/max/mdev = 11.8/12.0/12.3/0.2 ms admin@web-server:~$ ping -c 4 google.com # -c 4 = kirim 4 packet saja_
traceroute
Lihat route ke tujuan
bash
admin@web-server:~$ traceroute google.com traceroute 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_
dig, nslookup
DNS lookup
bash
admin@web-server:~$ dig google.com ; <<>> DiG 9.18 <<>> google.com ;; ANSWER SECTION: google.com. 300 IN A 142.250.1.100 admin@web-server:~$ nslookup google.com Server: 8.8.8.8 Address: 8.8.8.8#53 Non-authoritative answer: Name: google.com Address: 142.250.1.100_
ss, netstat
Lihat network connections & ports
bash
admin@web-server:~$ ss -tulpn Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port Process tcp LISTEN 0 128 0.0.0.0:22 0.0.0.0:* users:(("sshd",pid=456)) tcp LISTEN 0 128 0.0.0.0:80 0.0.0.0:* users:(("nginx",pid=1234)) admin@web-server:~$ netstat -tulpn # netstat sudah deprecated, gunakan ss_
KOMPETENSI SUB-BAB 14
  • Mampu lihat IP address dan routing dengan ip
  • Mampu test connectivity dengan ping
  • Mampu trace route dengan traceroute
  • Mampu DNS lookup dengan dig/nslookup
  • Mampu lihat network connections dengan ss
15
SUB-BAB 15 PRAKTIK

PRAKTIK ADMINISTRASI

Skenario 1: Setup Web Server

BASH
# 1. Update sistem sudo apt update && sudo apt upgrade -y # 2. Install nginx sudo apt install nginx -y # 3. Start & enable nginx sudo systemctl start nginx sudo systemctl enable nginx # 4. Cek status sudo systemctl status nginx # 5. Cek port sudo ss -tulpn | grep :80 # 6. Test dari browser # Buka http://server-ip # 7. Edit default page sudo nano /var/www/html/index.html # 8. Allow di firewall sudo ufw allow 'Nginx HTTP'

Skenario 2: Setup User & SSH

BASH
# 1. Buat user baru sudo useradd -m -s /bin/bash -G sudo newuser # 2. Set password sudo passwd newuser # 3. Install SSH server sudo apt install openssh-server -y # 4. Start & enable SSH sudo systemctl start ssh sudo systemctl enable ssh # 5. Edit SSH config (security) sudo nano /etc/ssh/sshd_config # Ubah: Port 2222, PermitRootLogin no # 6. Restart SSH sudo systemctl restart ssh # 7. Allow SSH di firewall sudo ufw allow 2222/tcp # 8. Test SSH dari client ssh -p 2222 newuser@server-ip

Skenario 3: Monitoring & Troubleshooting

BASH
# 1. Cek system info uname -a lsb_release -a uptime free -h df -h # 2. Cek process top ps aux | grep nginx # 3. Cek network ip addr show ip route show ss -tulpn # 4. Cek logs journalctl -u nginx journalctl -p err --since "1 hour ago" # 5. Test connectivity ping -c 4 8.8.8.8 ping -c 4 google.com dig google.com traceroute google.com # 6. Cek service systemctl status nginx systemctl status ssh # 7. Cek disk usage du -sh /var/log/* du -sh /var/www/*

Checklist Harian Administrator

TUGASCOMMANDFREKUENSI
Cek uptimeuptimeHarian
Cek disk usagedf -hHarian
Cek memoryfree -hHarian
Update sistemsudo apt update && sudo apt upgradeMingguan
Cek logsjournalctl -p err --since "1 day ago"Harian
Cek servicesystemctl --failedHarian
BackupCustom backup scriptHarian/Mingguan
Security auditsudo lynis audit systemBulanan
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!
SUB-BAB15 COMMAND100+ NEXTFile System
ABDURROZAK.MY.ID // TERHUBUNG

JARINGAN SOSIAL

Temukan saya di berbagai platform digital