Mengapa Perlu Command Line?
Sebagai developer, command line (terminal) adalah alat utama untuk berinteraksi dengan server, menjalankan script, dan mengelola infrastruktur. GUI tidak selalu tersedia di server production.
Navigasi Dasar
# Lihat direktori saat ini
pwd
# Pindah direktori
cd /var/www/html
cd .. # naik satu level
cd ~ # ke home directory
# Lihat isi direktori
ls # daftar file
ls -la # detail lengkap + hidden files
ls -lh # ukuran human-readable
Manipulasi File & Direktori
# Buat direktori
mkdir -p project/src/components
# Buat file
touch index.html
# Copy & Move
cp file.txt backup/file.txt
mv old-name.txt new-name.txt
# Hapus
rm file.txt
rm -rf directory/ # hati-hati! rekursif & force
Membaca & Mencari File
# Baca isi file
cat config.json
less /var/log/syslog # scroll dengan j/k
# Cari teks dalam file
grep "error" /var/log/app.log
grep -r "TODO" src/ # rekursif di folder
# Cari file
find . -name "*.js" -type f
Pipe & Redirect
# Pipe: output command pertama jadi input command kedua
cat access.log | grep "404" | wc -l
# Redirect output ke file
echo "Hello" > file.txt # overwrite
echo "World" >> file.txt # append
# Redirect error
command 2> error.log
command > output.log 2>&1 # semua ke satu file