[[:FreeBSD-TIP:]] san2@2003.11.11 [Æ÷Æ®, ¼ÒÄÏ] 1. only LISTEN shell> netstat -aLn | awk -F '*.' '{print $2}' | uniq 2. LISTEN and ESTABLISHED shell> netstat -an -f inet -p tcp 3. socket shell> socketstat -4 [µð½ºÅ© »ç¿ë·®] shell> df -m -t ufs [disk] 1. tty cpu Æ÷ÇÔ shell> iostat -c 2 -I -w 2 2. diskbandwidth ÃøÁ¤(2ÃÊ µ¿¾È) shell> iostat -c 2 -w 2 -t da -d ( iostat -d -t da <-- not good) 3. ƯÁ¤ ÆÄƼ¼Ç »ç¿ë·® º¸°í shell> df -m /home 2>/dev/null \ | tail -n1 \ | awk '{printf "Total: %.1fGB, Used: %.1fGB", $2/1024,$3/1024}' 2>/dev/null \ | mail -s '[report] HDD '`hostname` -c sync@wdb.co.kr to@mailhost \ -f network@wdb.co.kr 2>/dev/null or (df -m /home | tail -n1 \ | awk '{printf "Total: %.1fGB, Used: %.1fGB", $2/1024,$3/1024}' \ | mail -s '[report] HDD '`hostname` -c sync@wdb.co.kr to@mailhost \ -f network@wdb.co.kr ) 2>/dev/nulll [ÆÄÀÏ Å©±â ¹× Á¤·Ä] 1. mega-bytes ´ÜÀ§·Î Ãâ·Â(-m ¿É¼ÇÀÌ ¾ø³×¿ä) shell> du -skcP * | awk '{printf "%8.1fM %s\n", $1/1024,$2}' 2. ÇÏÀ§µð·ºÅ丮±îÁö ã¾Æ¼­ °¡ÀåÅ« ÆÄÀϼøÀ¸·Î Á¤·ÄÇϱâ(µð·ºÅ丮 Æ÷ÇÔ) shell> du -akcP * | awk '{printf "%10.1fM %s\n", $1/1024,$2}' | sort -r ÇöÀç µð·ºÅ丮¿¡ ´ëÇÑ ¼­ºêµð·ºÅ丮¸¸ shell> du -s * | awk '{printf "%10.1fM %s\n", $1/1024,$2}' | sort -r ÇöÀç µð·ºÅ丮¿¡ ´ëÇÑ ¸ðµç ¼­ºêµð·ºÅ丮¸¸ shell> du * | awk '{printf "%10.1fM %s\n", $1/1024,$2}' | sort -r 3. IP ÁÖ¼Ò Å©±â¼øÀ¸·Î Á¤·ÄÇϱâ shell> egrep "^[1-9]" hosts.list \ | awk -F"." '{printf "%03d%03d%03d%03d^%s\n", $1,$2,$3,$4,$0}' \ | sort | awk -F"^" '{print $2}' Çé ÆÄÀÌÇÁÀÇ ¾Ð¹Ú°¨.... T.T ipsort() { egrep "^[1-9]" "$1" 2>/dev/null \ | awk -F"." '{printf "%03d%03d%03d%03d^%s\n", $1,$2,$3,$4,$0}' \ | sort | awk -F"^" '{print $2}' } [±âŸ ¸í·É¾î] 1. echo -e ---> printf (FreeBSD ´Â -e ¿É¼ÇÀÌ ¾ø³×¿ä) 2. cp [Linux] -a (same as `-dpR') -d, --no-dereferenc -p, --preserve -R, --recursive -f, --force ex) cp -a [FreeBSD] cp [-R [-H | -L | -P]] [-f | -i | -n] [-pv] source_file target_file cp [-R [-H | -L | -P]] [-f | -i | -n] [-pv] source_file ... target_directory -R directory copy -p cp to preserve ex) cp -Rp (-a ¿É¼Ç°ú -d ¿É¼ÇÀÌ ¾øÀ½) 3. ping -f ¿É¼Ç Àç¹ÌÀֳ׿ä.. :) [FreeBSD] usage: ping [-AQRadfnqrv] [-c count] [-i wait] [-l preload] [-m ttl] [-p pattern] [-P policy] [-s packetsize] [-S src_addr] [-t timeout] [host | [-L] [-I iface] [-T ttl] mcast-group] [Linux] usage: ping [-LRUbdfnqrvV] [-c count] [-i interval] [-w wait] [-p pattern] [-s packetsize] [-t ttl] [-I interface address] [ -T timestamp option ] [ -Q tos ] host -s packetsize IP header data : 20 bytes ICMP header : 8 bytes send packectsize : 56 bytes (ICMP ECHO_REQUEST, -s ¿É¼Ç) ------------------------------ send total : 84 bytes received total : 64 bytes (ICMP ECHO_REPLY = ICMP header + send packectsize) PING localhost.localdomain (127.0.0.1): 56 data bytes FreeBSD - root : 0 bytes µµ °¡´É(À̶§´Â Çì´õ 8 bytes ¸¸ º¸³¿) FreeBSD - account : NA PING localhost.localdomain (127.0.0.1) from 127.0.0.1 : 56(84) bytes of data. Linux - root : 1 bytes ÀÌ»ó¸¸ °¡´É Linux - account : 1 bytes ÀÌ»ó¸¸ °¡´É -i wait (FreeBSD) / -i inerval (Linux - manual page ´Â -i wait ·Î ³ª¿È) µ¿ÀÏÇÑ ¿É¼ÇÀ¸·Î ICMP ECHO ¸Þ½ÃÁö¸¦ º¸³»´Â °£°ÝÀ» ÀÇ¹Ì *ÁÖ) FreeBSD ÀÇ root ¿¡¼­¸¸ 0 ÀÌ °¡´ÉÇÏ°í ³ª¸ÓÁö´Â ¸ðµÎ 1 ÃÊ ÀÌ»óÀ̾î¾ß ÇÔ -t timeout (FreeBSD) / -w timeout (Linux) timeout ÃÊ ÈÄ, ping ÀÌ Á¾·áµÊ( `-i N -c N' Àº `-t N' °ú °°À½) -T ttl (FreeBSD) / -t ttl (Linux) Set the IP Time to Live for multicasted packets. This flag only applies if the ping destination is a multicast address. *ÁÖ) FreeBSD `-m ttl' ¿É¼ÇÀº outgoing ÆÐŶ¿¡ ´ëÇÑ TTL ¼³ÀýÀÓ [FreeBSD] finc /path/to -type f -delete [all] find /path/to -type f -exec rm -f {} \; find /path/to -type f | xargs rm -f [¸ÞÀÏÅ¥ ó¸®] cd /etc/mail make stop find /var/spool/clientmqueue -type f -delete make start [½Ã½ºÅÛ ·Î±×] touch [-c] cron maillog messages sendmail.st wtmp chmod 0600 cron; chmod 0640 maillog; chmod 0640 sendmail.st * -c ¿É¼ÇÀº ÆÄÀÏÀÌ ¾øÀ» °æ¿ì¿¡ »ý¼º Á¢¼Ó ¸·±â route add -host 62.175.107.162 127.0.0.1 -reject ´Ù½Ã Çã¿ë route delete 62.175.107.162