π» Mastering the Terminal
Dari GUI enthusiast yang takut Command Line, menjadi Terminal power user yang tidak bisa hidup tanpa CLI.
π Apa Itu Terminal?
Definisi Terminal
Terminal (atau Command Line Interface/CLI) adalah sebuah antarmuka berbasis teks yang memungkinkan Anda berkomunikasi langsung dengan sistem operasi komputer menggunakan perintah tertulis (commands), bukan dengan cara klik-klik menggunakan mouse seperti pada GUI (Graphical User Interface).
Analogi Sederhana:
- GUI = Berbicara dengan komputer menggunakan bahasa gambar (icons, buttons, windows)
- Terminal = Berbicara dengan komputer menggunakan bahasa teks (commands)
βββββββββββββββββββββββββββββββββββββββββββ
β GUI (Graphical User Interface) β
β βββββββββ βββββββββ βββββββββ β
β β π β β π β β ποΈ β β
β βFolder β β File β βTrash β β
β βββββββββ βββββββββ βββββββββ β
β π Click to interact β
βββββββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββββββββββββββββββββββββββββ
β CLI (Command Line Interface) β
β $ mkdir folder β
β $ touch file.txt β
β $ rm file.txt β
β β¨οΈ Type to interact β
βββββββββββββββββββββββββββββββββββββββββββ
Komponen Terminal
1. Shell
Program yang membaca dan mengeksekusi command Anda.
Jenis-jenis Shell:
- Bash - Bourne Again Shell (Linux default)
- Zsh - Z Shell (MacOS default sejak Catalina)
- Fish - Friendly Interactive Shell
- PowerShell - Windows default
# Check shell Anda:
echo $SHELL
# Output: /bin/zsh (MacOS)
# Output: /bin/bash (Linux)
2. Terminal Emulator
Aplikasi yang menampilkan shell (window tempat Anda mengetik).
Contoh:
- Terminal.app (MacOS built-in)
- iTerm2 (MacOS, more features)
- GNOME Terminal (Linux)
- Windows Terminal (Windows)
- Hyper, Alacritty, Kitty (Cross-platform)
Terminal vs GUI: Kapan Pakai Apa?
| Aspek | Terminal (CLI) | GUI |
|---|---|---|
| Speed | β‘ Sangat cepat (kalau sudah hafal) | π’ Lebih lambat (banyak klik) |
| Automation | β Mudah (scripting) | β Sulit/tidak bisa |
| Remote Access | β SSH, lightweight | β Butuh remote desktop, berat |
| Precision | β Exact control | β οΈ Limited options |
| Learning Curve | π Steep (harus hafal command) | π Easy (visual) |
| Resource Usage | π Ringan | π Lebih berat |
| Multitasking | β Multiple commands parallel | β οΈ One window at a time |
Kapan pakai Terminal?
- Development work (npm, git, docker)
- Server management
- Automation & scripting
- Batch operations (process 100 files sekaligus)
- Remote work via SSH
Kapan pakai GUI?
- Casual browsing files
- Image editing
- Video editing
- When you don’t know exact file name/location
Kenapa Developer Harus Belajar Terminal?
1. Developer Tools Built for CLI
Hampir semua development tools modern dirancang untuk CLI:
# Version Control
git clone, git commit, git push
# Package Managers
npm install, pip install, brew install
# Build Tools
webpack, vite, hugo
# Deployment
ssh, docker, kubectl
# Databases
mysql -u root, psql, mongosh
Tanpa Terminal = Tidak bisa pakai tools ini!
2. Server Management
Server production tidak punya GUI. Harus pakai SSH + Terminal.
# Connect to remote server
ssh user@server.example.com
# Deploy website
git pull origin main
npm run build
pm2 restart app
3. Automation
Automate repetitive tasks yang di GUI butuh berjam-jam:
# Resize 1000 images in 1 command
for img in *.jpg; do convert $img -resize 800x600 resized/$img; done
# vs GUI: Open Photoshop β Open image β Resize β Save β Repeat 1000x π
4. Professional Standard
Di dunia profesional, komunikasi sering melalui terminal command:
Code review comments:
“To fix this, run:
npm install --legacy-peer-deps”
Documentation:
Installation
git clone repo npm install npm run dev
Job requirements:
Familiar with Linux command line, Git, Docker CLI
Struktur Dasar Command
Semua command di terminal mengikuti pattern yang sama:
command [options] [arguments]
Contoh:
ls -lah /Users/acarya/Desktop
β β β
β β ββ Argument (what folder to list)
β ββββββ Options/Flags (how to list: l=long, a=all, h=human-readable)
βββββββββ Command (list files)
Breakdown:
- Command: Apa yang ingin dilakukan (
ls,cd,git) - Options/Flags: Modifikasi perilaku command (
-l,--help,-r) - Arguments: Target operasi (file name, folder path, URL)
Contoh lain:
git commit -m "Add new feature"
β β β β
β β β ββ Argument (commit message)
β β βββββ Option (-m = message)
β ββββββββββββ Sub-command
ββββββββββββββββ Main command
curl -X POST https://api.github.com
β β β β
β β β ββ Argument (URL)
β β βββββββ Argument (HTTP method)
β ββββββββββ Option
βββββββββββββββ Command
Navigasi File System di Terminal
Di GUI, Anda lihat folder sebagai icons. Di Terminal, semua adalah path (alamat):
Graphical View (Finder):
π Users
ββ π acaryawibawantra
ββ π projects
ββ π website
ββ π index.html
Terminal View:
/Users/acaryawibawantra/projects/website/index.html
β β β β ββ File
β β β ββββββββββ Folder
β β βββββββββββββββββββ Folder
β ββββββββββββββββββββββββββββββββββββ User home
ββββββββββββββββββββββββββββββββββββββββββ Root
Absolute Path (dari root):
/Users/acaryawibawantra/projects/website/index.html
ββ Starts with / (root)
Relative Path (dari current directory):
./website/index.html # Current folder
../projects/website # Parent folder
~/projects/website # Home folder
Terminal Workflow vs GUI Workflow
Task: Create project structure
GUI Way (5-10 minutes):
- Open Finder
- Navigate to Projects folder
- Right-click β New Folder β Type “my-app”
- Open my-app folder
- Right-click β New Folder β Type “src”
- Repeat for: public, components, utils
- Right-click β New File β “index.html”
- Right-click β New File β “App.js”
- … (repeat for every file)
Terminal Way (10 seconds):
cd ~/projects && \
mkdir -p my-app/{src/{components,utils},public} && \
cd my-app && \
touch src/{App.js,index.js} public/index.html && \
code .
Result:
my-app/
βββ src/
β βββ components/
β βββ utils/
β βββ App.js
β βββ index.js
βββ public/
βββ index.html
2 lines of code vs 20 mouse clicks. Ini power of Terminal! β‘
π― Kenapa Harus Belajar Terminal?
1. Speed & Efficiency
# GUI: Buka Finder β Navigate β Right Click β New Folder β Type name
# Terminal (1 detik):
mkdir project-baru
2. Automation
# Bikin 10 folder sekaligus
mkdir project-{1..10}
# Hasil:
# project-1, project-2, ... project-10
3. Remote Work
# Connect ke server
ssh user@server.com
# Deploy website
git push origin main
4. Developer Tools
npm install # Node.js packages
git clone # Version control
docker run # Containerization
hugo serve # Static site generator
Bottom Line: GUI untuk casual use, Terminal untuk professional work.
π Terminal Basics: Command Essentials
ποΈ Navigation Commands
pwd - Print Working Directory
Lihat di mana posisi Anda sekarang.
pwd
# Output: /Users/acaryawibawantra/projects
Kapan pakai?
- Saat tersesat di folder structure
- Sebelum hapus/modify file (pastikan lokasi benar!)
ls - List Files
Lihat isi folder.
# Basic
ls
# Detailed view (size, permissions, date)
ls -l
# Include hidden files (dimulai dengan .)
ls -a
# Human-readable file sizes
ls -lh
# Combine multiple flags
ls -lah
# Urutkan by last modified
ls -lt
Output Example:
ls -lah
# drwxr-xr-x 5 acarya staff 160B Jan 14 21:30 .
# drwxr-xr-x 8 acarya staff 256B Jan 14 20:15 ..
# -rw-r--r-- 1 acarya staff 2.1K Jan 14 21:45 README.md
# drwxr-xr-x 3 acarya staff 96B Jan 14 21:30 src
Pro Tip: Saya pakai alias ll untuk ls -lah (lebih praktis).
cd - Change Directory
Pindah folder.
# Masuk ke folder
cd projects
# Balik ke parent folder
cd ..
# Balik ke home directory
cd ~
# atau cukup:
cd
# Ke folder sebelumnya
cd -
# Absolute path
cd /Users/acaryawibawantra/Desktop
# Relative path
cd ./src/components
Shortcuts:
~= Home directory (/Users/acaryawibawantra).= Current directory..= Parent directory-= Previous directory
π File Operations
touch - Create File
# Bikin file baru
touch index.html
# Bikin multiple files
touch file1.txt file2.txt file3.txt
# Update timestamp existing file
touch existing-file.md
mkdir - Make Directory
# Bikin folder
mkdir new-folder
# Bikin nested folders sekaligus
mkdir -p parent/child/grandchild
# Bikin multiple folders
mkdir folder1 folder2 folder3
Common Error:
mkdir parent/child
# mkdir: parent: No such file or directory
# Fix: use -p flag
mkdir -p parent/child # β
cp - Copy Files
# Copy file
cp source.txt destination.txt
# Copy folder (recursive)
cp -r folder1 folder2
# Copy multiple files ke folder
cp file1.txt file2.txt /destination/folder/
# Copy dengan konfirmasi (prevent overwrite)
cp -i source.txt dest.txt
mv - Move/Rename
# Rename file
mv old-name.txt new-name.txt
# Move file ke folder lain
mv file.txt /path/to/destination/
# Move multiple files
mv file1.txt file2.txt /destination/
# Rename folder
mv old-folder-name new-folder-name
rm - Remove Files
# β οΈ HATI-HATI! Deletion is permanent!
# Delete file
rm file.txt
# Delete folder (recursive)
rm -r folder-name
# Force delete (no confirmation)
rm -rf folder-name
# Delete with confirmation
rm -i file.txt
β οΈ WARNING: rm -rf / = DELETE EVERYTHING!
Safer Alternative:
# Better: Move to trash instead
# (Mac only)
brew install trash
trash unwanted-file.txt # Recoverable from Trash
π Viewing & Searching
cat - View File Contents
# Print entire file
cat file.txt
# Concatenate multiple files
cat file1.txt file2.txt
# Show line numbers
cat -n file.txt
less / more - View Large Files
# Navigate dengan arrow keys, q untuk quit
less large-file.log
# Older alternative
more file.txt
Controls in less:
Space= Next pageb= Previous page/search-term= Searchq= Quit
head / tail - View Start/End of File
# First 10 lines
head file.txt
# First 20 lines
head -n 20 file.txt
# Last 10 lines
tail file.txt
# Real-time monitoring (great for logs!)
tail -f server.log
grep - Search Inside Files
# Find lines containing "error"
grep "error" log.txt
# Case-insensitive search
grep -i "error" log.txt
# Search in multiple files
grep "TODO" *.js
# Search recursively in all files
grep -r "function" ./src
# Show line numbers
grep -n "import" App.tsx
# Invert match (show lines NOT containing pattern)
grep -v "debug" log.txt
Real Example:
# Find all console.log in project
grep -r "console.log" ./src
find - Search Files by Name
# Find file by name
find . -name "index.html"
# Case-insensitive
find . -iname "README.md"
# Find all .js files
find . -name "*.js"
# Find files modified in last 7 days
find . -mtime -7
# Find and delete
find . -name "*.log" -delete
βοΈ System Commands
echo - Print Text
# Print to terminal
echo "Hello World"
# Write to file (overwrite)
echo "content" > file.txt
# Append to file
echo "more content" >> file.txt
# Print variable
echo $HOME
clear - Clear Terminal
clear
# Shortcut: Cmd + K (Mac)
# Ctrl + L (Linux)
history - Command History
# Show all previous commands
history
# Run previous command
!!
# Run command number 42 from history
!42
# Search history interactively
# Ctrl + R (then type search term)
man - Manual Pages
# Read manual for any command
man ls
man grep
man git
# Navigate: Space (next page), q (quit)
π Advanced Commands
File Permissions
chmod - Change Permissions
# Make file executable
chmod +x script.sh
# Numeric permissions (rwx = 4+2+1 = 7)
chmod 755 file.sh
# 7 = rwx (owner)
# 5 = r-x (group)
# 5 = r-x (others)
# Recursive
chmod -R 755 folder/
Permission Guide:
r= Read (4)w= Write (2)x= Execute (1)
Common combinations:
755= rwxr-xr-x (executable files)644= rw-r–r– (regular files)700= rwx—— (private files)
Process Management
ps - Process Status
# Show running processes
ps
# Detailed view
ps aux
# Find specific process
ps aux | grep "node"
top / htop - System Monitor
# Real-time system stats
top
# Better alternative (install first)
brew install htop
htop
kill - Stop Process
# Kill by PID
kill 1234
# Force kill
kill -9 1234
# Kill by name
killall node
Networking
ping - Test Connection
# Check if host is reachable
ping google.com
# Limit to 5 packets
ping -c 5 google.com
curl - Transfer Data
# Download file
curl https://example.com/file.zip -o file.zip
# API request
curl https://api.github.com/users/acaryawibawantra
# POST request
curl -X POST -d "key=value" https://api.example.com
wget - Download Files
# Download file
wget https://example.com/file.zip
# Download with custom name
wget -O custom-name.zip https://example.com/file.zip
# Resume interrupted download
wget -c https://example.com/large-file.zip
Compression
tar - Archive Files
# Create archive
tar -czf archive.tar.gz folder/
# Extract archive
tar -xzf archive.tar.gz
# List contents without extracting
tar -tzf archive.tar.gz
Flags meaning:
c= createx= extractz= gzip compressionf= filev= verbose (show progress)
zip / unzip
# Create zip
zip -r archive.zip folder/
# Extract zip
unzip archive.zip
# Extract to specific folder
unzip archive.zip -d destination/
π¨ Terminal Customization
Oh My Zsh (MacOS)
Install:
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
Popular Themes:
# Edit ~/.zshrc
nano ~/.zshrc
# Change theme
ZSH_THEME="robbyrussell" # Default
ZSH_THEME="agnoster" # Powerline style
ZSH_THEME="powerlevel10k/powerlevel10k" # Most popular
Apply changes:
source ~/.zshrc
Aliases (Shortcuts)
Edit ~/.zshrc or ~/.bashrc:
# Navigation
alias ..="cd .."
alias ...="cd ../.."
alias home="cd ~"
alias desktop="cd ~/Desktop"
alias projects="cd ~/projects"
# List files
alias ll="ls -lah"
alias la="ls -a"
# Git shortcuts
alias gs="git status"
alias ga="git add ."
alias gc="git commit -m"
alias gp="git push"
alias gl="git log --oneline --graph"
# NPM shortcuts
alias ni="npm install"
alias nrd="npm run dev"
alias nrb="npm run build"
# Safety aliases
alias rm="rm -i" # Confirm before delete
alias cp="cp -i" # Confirm before overwrite
alias mv="mv -i" # Confirm before overwrite
# Productivity
alias c="clear"
alias h="history"
alias myip="curl ifconfig.me" # Get public IP
# Project specific
alias blog="cd ~/acaryawibawantra.xyz && code ."
alias serve="hugo serve"
Activate:
source ~/.zshrc
Now you can:
# Instead of:
cd ~/projects/acaryawibawantra.xyz
# Just type:
blog
π‘ Tips & Tricks
1. Tab Completion β‘
# Type first few letters, then press Tab
cd proj[Tab]
# Auto-completes to: cd projects/
# Double Tab shows all options
ls proj[Tab][Tab]
# Shows: project-1/ project-2/ project-baru/
2. Command History Search π
# Press Ctrl + R, then type keyword
# Example: search "git commit"
(reverse-i-search)`git': git commit -m "Add feature"
# Press Enter to run
# Press Ctrl + R again to cycle through matches
3. Piping Commands π
# Chain commands together
ls | grep ".md" # List only .md files
cat file.txt | grep "error" | wc -l # Count error lines
ps aux | grep "node" | awk '{print $2}' # Get PIDs of Node processes
4. Output Redirection π
# Save output to file
ls -la > files.txt
# Append to file
echo "New line" >> files.txt
# Redirect errors
command 2> errors.log
# Redirect both output and errors
command &> all-output.log
# Discard output
command > /dev/null
5. Background Processes βοΈ
# Run in background
long-running-command &
# Bring to foreground
fg
# List background jobs
jobs
# Stop current process (Ctrl + Z), then:
bg # Continue in background
6. Multiple Commands π
# Run sequentially
command1; command2; command3
# Run only if previous succeeds (AND)
command1 && command2 && command3
# Run if previous fails (OR)
command1 || command2
# Example:
mkdir new-project && cd new-project && npm init -y
7. Wildcards π
# * = any characters
rm *.log # Delete all .log files
# ? = single character
ls file?.txt # Matches: file1.txt, fileA.txt
# {} = multiple patterns
cp file.{txt,md,json} backup/
# Range
rm file{1..10}.txt # Delete file1.txt to file10.txt
8. Keyboard Shortcuts β¨οΈ
Navigation:
Ctrl + A= Start of lineCtrl + E= End of lineCtrl + U= Delete line before cursorCtrl + K= Delete line after cursorCtrl + W= Delete word before cursorCtrl + L= Clear screen (same asclear)
Control:
Ctrl + C= Cancel current commandCtrl + D= Exit terminal (same asexit)Ctrl + Z= Suspend processCtrl + R= Search history
9. Quick File Edit βοΈ
# Open file in default editor
nano file.txt # Beginner-friendly
vim file.txt # Advanced
code file.txt # VS Code (if installed)
# Quick one-liner edit
echo "new content" > file.txt
10. Disk Usage πΎ
# Check disk space
df -h
# Check folder size
du -sh folder/
# Find largest files
du -ah . | sort -rh | head -20
π Common Errors & Solutions
β “Permission Denied”
# Error
bash: ./script.sh: Permission denied
# Solution
chmod +x script.sh
./script.sh
β “Command Not Found”
# Error
zsh: command not found: git
# Solutions:
# 1. Install the tool
brew install git
# 2. Check if it's installed
which git
# 3. Add to PATH
export PATH=$PATH:/path/to/tool
β “No Such File or Directory”
# Error
cd projects
# cd: no such file or directory: projects
# Solutions:
# 1. Check spelling
ls # See available folders
# 2. Use full path
cd ~/projects
# 3. Check if you're in right directory
pwd
β Accidentally Deleted File
# Prevention: Use trash instead
brew install trash
trash file.txt # Moves to Trash (recoverable)
# If already deleted with rm:
# Sorry, it's gone π’
# Lesson: Always backup important files!
π Learning Resources
Beginner-Friendly:
- Explain Shell - Paste command, get explanation
- Linux Journey - Interactive tutorial
- Command Line Challenge - Practice problems
Interactive:
Reference:
- DevHints Bash Cheat Sheet
- TLDR Pages - Simplified man pages
π My Current Terminal Setup
Tools I Use Daily:
- Shell: Zsh with Oh My Zsh
- Theme: Powerlevel10k
- Terminal App: iTerm2 (Mac) / Built-in Terminal
- Plugins:
zsh-autosuggestions(command suggestions)zsh-syntax-highlighting(syntax colors)git(git aliases)npm(npm completion)
Must-Have CLI Tools:
brew install git # Version control
brew install node # JavaScript runtime
brew install hugo # Static site generator
brew install tree # Directory visualization
brew install tldr # Simplified man pages
brew install bat # Better cat with syntax highlighting
brew install fzf # Fuzzy finder
π¬ Final Thoughts
Terminal dulu vs sekarang:
Dulu (2024):
# Me: *nervously types*
ls
# *Nothing bad happened, phew*
Sekarang (2026):
# Me: *rapid fire commands*
cd ~/projects && \
mkdir new-app && \
cd new-app && \
npm init -y && \
npm i next react && \
code . && \
echo "π Let's build!"
What I Learned:
- β‘ Practice > Theory - Just use it daily
- π₯ Break things - That’s how you learn
- π Google is your friend - No one memorizes everything
- π οΈ Customize - Make it YOUR workflow
- π€ Share knowledge - Teach others what you learn
π Quick Reference Cheat Sheet
# NAVIGATION
pwd # Print current directory
ls -lah # List files (detailed + hidden)
cd folder # Change directory
cd .. # Go up one level
cd ~ # Go home
# FILES
touch file.txt # Create file
mkdir folder # Create folder
cp file1 file2 # Copy
mv old new # Move/rename
rm file # Delete file
rm -rf folder # Delete folder
# VIEWING
cat file # View entire file
less file # View file (scrollable)
head -n 20 file # First 20 lines
tail -f file # Last lines (real-time)
# SEARCHING
grep "text" file # Search in file
find . -name "*.js" # Find files
# SYSTEM
ps aux # Running processes
kill PID # Stop process
df -h # Disk space
top # System monitor
# GIT (Bonus!)
git status # Check status
git add . # Stage all files
git commit -m "msg" # Commit
git push # Push to remote
git pull # Pull from remote
git log --oneline # View commits
Download this post as PDF: [Coming soon]
Questions? Drop them in the comments or reach out on GitHub!
Last updated: January 14, 2026
Keep coding, keep learning, keep typing those commands! β‘π»