[[: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

윤진한
08-01-21 10:37
0개
4회
일반문서
[FreeBSD] Tip 모음
댓글목록
등록된 댓글이 없습니다.