Linux Commands for File & Network Security

 

๐Ÿง Linux Commands for File & Network Security

Security professionals mainly use Linux to:
✅ Protect files
✅ Monitor users
✅ Control permissions
✅ Scan networks
✅ Detect attacks


๐Ÿ” File Security Commands


๐Ÿ“ 1️⃣ List Files with Permissions

ls -l

Shows:

-rwxr-xr--

Owner | Group | Others


๐Ÿ”‘ 2️⃣ Change Permissions

chmod 755 file.sh chmod 600 secret.txt
  • 755 → executable

  • 600 → private file


๐Ÿ‘ค 3️⃣ Change Ownership

chown user:group file.txt

๐Ÿ” 4️⃣ Find Sensitive Files

find / -perm -4000 2>/dev/null

Finds SUID files (security risk).


๐Ÿ“„ 5️⃣ Check File Integrity

sha256sum file.txt

Used to verify file changes.


๐Ÿ—‚️ 6️⃣ Monitor File Changes

stat file.txt

Shows access, modify time.


๐Ÿ”Ž 7️⃣ Search Inside Files

grep "password" file.txt

Finds keywords in files/logs.



๐Ÿ‘ฅ User & Access Security


๐Ÿ‘ค 8️⃣ Check Logged-in Users

who w

๐Ÿ” 9️⃣ Check User Privileges

id sudo -l

๐Ÿšซ ๐Ÿ”Ÿ Lock User Account

passwd -l username


๐ŸŒ Network Security Commands


๐ŸŒ 1️⃣ Check IP & Interfaces

ip a

๐Ÿ“ก 2️⃣ Test Connectivity

ping google.com

๐Ÿ”Ž 3️⃣ Scan Network (Legal use only)

nmap 192.168.1.1

Finds open ports.


๐Ÿ”Œ 4️⃣ Check Open Ports

ss -tulnp netstat -tulnp

Shows listening services.


๐Ÿ“ฅ 5️⃣ Capture Packets

tcpdump -i eth0

Used for traffic analysis.


๐Ÿ”— 6️⃣ Check Connections

whois google.com

Gets domain info.


๐Ÿ”ฅ 7️⃣ Firewall Control (UFW)

ufw status ufw enable ufw allow ssh ufw deny 80

Controls network access.



๐Ÿ“œ Log Monitoring (Security Core)


๐Ÿงพ Check Login Attempts

cat /var/log/auth.log

๐Ÿ” Live Log Monitoring

tail -f /var/log/syslog


⚙️ Process Security


⚡ Check Running Processes

ps aux top

❌ Kill Suspicious Process

kill -9 PID


๐Ÿง  Useful Security Combos


Find writable files:

find / -type f -perm -o+w 2>/dev/null

Check failed logins:

lastb

Check history:

history


๐Ÿ” Best Practices for Security Pros

✔ Use strong permissions
✔ Monitor logs
✔ Limit sudo access
✔ Scan open ports
✔ Enable firewall
✔ Verify file integrity



๐Ÿ“ Exam Short Notes

  • chmod controls permissions.

  • nmap scans ports.

  • tcpdump captures packets.

  • ufw manages firewall.

  • auth.log stores login info.

Comments

Popular posts from this blog

Introduction to Computer

History of Computer

Computer Generation