Wednesday, December 17, 2008

Quik Note: iptables

  • iptables -t filter -nL display all the chain rules
  • iptables -nL
  • iptables -t nat -L show all chain rules NAT-table
  • iptables -t filter -F clear all the rules in the chain of filter-table
  • iptables -t nat -F clear all the rules in the chain of NAT-table
  • iptables -t filter -X remove all user-chain rules in filter-table
  • iptables -t filter -A INPUT -p tcp --dport telnet -j ACCEPT allow telnet incoming connection
  • iptables -t filter -A OUTPUT -p tcp --dport http -j DROP block http outcoming connection
  • iptables -t filter -A FORWARD -p tcp --dport pop3 -j ACCEPT allow forwarding

Sunday, December 7, 2008

Quik Note: Monitoring and debugging

  • ps -eafw display running processes and resources that they use
  • ps -e -o pid,args --forest display PIDs and process as a tree
  • pstree display process tree
  • kill -TERM 98989 complete correctly the process with PID 98989
  • kill -1 98989 make the process with PID 98989 reread configuration file
  • lsof -p 98989 display files opened by process with PID 98989
  • lsof /home/user1 display opened file from home user1 directory
  • strace -c ls >/dev/null display syscalls list that take and gave ls
  • strace -f -e open ls >/dev/null display library's syscalls
  • watch -n1 'cat /proc/interrupts' display interrupts in real time
  • last reboot display system reboot history
  • last user1 display login's history user1
  • lsmod display loaded kernel mdule
  • free -m dysplay RAM state in mb
  • smartctl -A /dev/hda control hard drive /dev/hda with SMART
  • smartctl -i /dev/hda check SMART accessibility on hard drive /dev/hda
  • tail /var/log/dmesg print 10 last write from kernel load log
  • tail /var/log/messages print last 10 write from system log