Menu Bar

Kata Mutiara

"Keberhasilan merupakan tetesan dari jeri-payah perjuangan, luka, pengorbanan dan hal-hal yang mengejutkan. Kegagalan merupakan tetesan dari kemalasan, kebekuan, kelemahan, kehinaan dan kerendahan"

ANIMASI TULISAN BERJALAN

Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Monday, June 2, 2025

permission world-writable dalam linux

 penjelasan lengkap tentang syntax berikut:

find / -type f -perm -0002 -exec ls -l {} \;

🔍 Tujuan Umum

Mencari file di seluruh sistem (/) yang memiliki permission world-writable, kemudian menampilkan detail file tersebut dengan ls -l.


🧠 Penjabaran Per Bagian

Bagian PerintahPenjelasan
find /Mulai pencarian dari root direktori (/), artinya mencari ke seluruh sistem.
-type fHanya cari file biasa (bukan direktori, device, atau link).
-perm -0002Cari file yang memiliki permission writable oleh "others" (world-writable). 0002 artinya: bit write (w) untuk "others" aktif. Tanda - di depan artinya minimal permission itu harus ada (bisa juga ada permission lain).
-exec ls -l {} \;Untuk setiap file yang ditemukan, jalankan perintah ls -l terhadap file tersebut. {} akan diganti dengan nama file hasil pencarian. \; adalah penutup dari perintah -exec (harus di-escape dengan \).

📌 Contoh Output

Misalnya, jika file /tmp/test.txt memiliki permission -rw-rw-rw-, maka output:

-rw-rw-rw-  1 root root 0 May 20 21:01 /tmp/test.txt

⚠️ Mengapa Penting (Security)

File yang world-writable (bisa ditulis oleh siapa pun) adalah risiko keamanan, karena:

  • User biasa bisa memodifikasi file penting.

  • Berpotensi dieksploitasi oleh malware atau attacker lokal.


✅ Tips Mitigasi

Untuk menghapus permission w dari others:

chmod o-w /path/to/file

Kalau kamu mau cari juga world-writable direktori, kamu bisa ubah:

find / -type d -perm -0002 -exec ls -ld {} \;

Saturday, May 24, 2025

Linux command line skills

 If you're looking to level up your Linux command line skills, here’s a curated list of advanced Linux commands, tools, and techniques, categorized by functionality:


🔍 File and Text Processing

  1. awk

    awk '{print $2, $1}' file.txt
    
    • Powerful for pattern scanning and processing.

  2. sed

    sed -E 's/([0-9]{3})/\1-/' file.txt
    
    • Stream editor for modifying files or inputs inline.

  3. xargs

    find . -name '*.log' | xargs grep 'ERROR'
    
    • Converts input from stdin into arguments to a command.

  4. cut, paste, tr, sort, uniq, tee

    cut -d':' -f1 /etc/passwd | sort | uniq
    

🧠 System Monitoring and Performance

  1. htop / atop / glances

    • Interactive process viewers.

  2. iotop

    • Shows disk I/O by process.

  3. strace

    strace -p <PID>
    
    • Traces system calls of a process.

  4. lsof

    lsof -i :80
    
    • Lists open files and ports.

  5. watch

    watch -n 2 df -h
    
    • Repeats a command at intervals.


📁 Disk & Filesystem Tools

  1. ncdu

    • Visual disk usage analysis.

  2. df, du

    du -sh * | sort -h
    
  3. mount, umount, lsblk, blkid


🧰 Networking & Sockets

  1. netstat / ss

    ss -tuln
    
  2. nmap

    nmap -sV 192.168.1.1
    
  3. tcpdump

    tcpdump -i eth0 port 80
    
  4. curl, wget, nc (netcat)

    curl -I https://example.com
    nc -vz google.com 80
    

🔐 Permissions, Security, & Users

  1. chmod, chown, setfacl, getfacl

  2. sudo, visudo

  3. usermod, groupadd, passwd

  4. ssh, scp, rsync

    rsync -avz /local/dir/ user@host:/remote/dir/
    

🔄 Automation and Scripting

  1. cron, at

    crontab -e
    
  2. Shell scripting:

    for i in *.log; do gzip "$i"; done
    
  3. trap, set -euo pipefail for robust scripts.


📦 Package Management

  • Debian/Ubuntu: apt, dpkg

  • Red Hat/CentOS: yum, dnf, rpm

  • Arch: pacman


🧠 Cool Pro Tips

  1. Brace expansion:

    mkdir -p project/{src,bin,doc}
    
  2. Process substitution:

    diff <(ls dir1) <(ls dir2)
    
  3. Command chaining:

    cmd1 && cmd2 || echo "cmd1 failed"
    
  4. Parallel execution with & and wait:

    cmd1 & cmd2 & wait
    

If you want a focused guide (e.g. for networking, performance tuning, or scripting), just let me know!

iklan

iklan