1
==============================================================================
#!/bin/ksh
IP=""
ID=""
PASS=""
SRC_PATH="/home/ems2/bin"
echo "----------------------------------"
echo "[$IP]와 FTP통신 하기"
echo "ID=$ID, PASSWORD=$PASS"
echo "----------------------------------"
echo "=> FTP 파일 전송(s) or 수신(r) : "\\c
read sor
LIST=""
TEMP_PATH=""
getNput=""
if [ "$sor" = "S" ] || [ "$sor" = "s" ]
then
echo "=> FTP로 전송 할 파일들 입력 : "\\c
read LIST
TEMP_PATH="./"
getNput="mput"
else
echo "=> FTP로 수신 할 파일들 입력 : "\\c
read LIST
echo "=> FTP로 수신 할 패스 입력(default : /home/ems2/bin) : "\\c
read TEMP_PATH
getNput="mget"
fi
if [ -n "$TEMP_PATH" ]
then
SRC_PATH=$TEMP_PATH
fi
ftp -n $IP << EOF
user $ID $PASS
prompt
passive
hash
bin
cd $SRC_PATH
$getNput $LIST
bye
EOF
echo "전송 완료!!"
PERM="755"
if [ "$sor" = "R" ] || [ "$sor" = "r" ]
then
echo "=> 수신한 파일들의 퍼미션 입력(default : 755) : "\\c
read TEMP_PERM
if [ -n "$TEMP_PATH" ]
then
PERM=$TEMP_PERM
fi
chmod $PERM $LIST
fi
exit 0
==============================================================================
2
==============================================================================
#!/bin/sh
IP=""
ID=""
PASS=""
SRC_PATH="/supp1/webapps/ims_domain/ims/ims_webapps/pid/server"
/home/wlogic81/nam/pid_monitor/.ws_01a_pid.sh > /home/wlogic81/nam/pid_monitor/logs/ws_01a_`date +%Y%m%d`.xml;
cp /home/wlogic81/nam/pid_monitor/logs/ws_01a_`date +%Y%m%d`.xml /home/wlogic81/nam/pid_monitor/ws_01a.xml;
ftp -n -v $IP << EOF
user $ID $PASS
prompt
passive
hash
bin
cd $SRC_PATH
mput ws_01a.xml
bye
EOF
==============================================================================
3
==============================================================================
#!/bin/sh
FILENAME=/hom
for user in $(cut -d: -f1 $FILENAME)
do
aaa=$user // 오늘날짜를 aaa라는 변수에 담아요
done
/usr/kerberos/bin/ftp -vn << END // crontab에서는 ftp라고 부르면 오류나요. 파일이 실제 존재하는 곳
open 211.xx.xx.xx
user user_id "password"
as
hash
prompt
lcd /home/uploading //업로드하려는 파일이 존재하는 폴더 (서버상에서)
put upfile_${aaa}.txt // upfile_20080721.txt 오늘날짜라면..
bye
END
==============================================================================
4 : 기타 순차 출력 방법
==============================================================================
#!/bin/sh
##cnt=1
##while [ $cnt -lt `cat list.txt | wc -l` ]
##do
#echo $cnt
## echo `cat -n list.txt | grep $cnt`
## cnt=`expr $cnt + 1`
## echo
# if [ $cnt == `cat list.txt | grep $cnt` ]
# then
# echo ""
# fi
##done
for line in `cat list.txt | tr -d '1'`;
do
echo $line
done
==============================================================================
2009. 7. 27.
2009. 7. 19.
[Windows] Console Command
명령어 ----------------------------------------------------------------
clipbrd (클립보드에 복사된 내용 표시)
control (제어판)
winver (윈도우 버전확인)
osk 화상키보드
pbrush 또는 mspaint (그림판)
ping 사이트주소(핑테스트 해당 사이트의 인터넷연결 유무 확인)
explorer 탐색기
shutdown -i : GUI화면으로 시스템 종료, 재부팅 가능
shutdown -a : 종료 설정 중지
netstat : 인터넷 접속 상황
ipconfig /all : ip주소,게이트웨이,서브넷마스크,
DNS서버주소,physical주소
dxdiag : 다이렉트 - X 상태 정보 화면
cleanmgr.exe : 디스크 정리
regedit : 레지스트리 편집기
mstsc.exe : 원격 데스크톱 연결
netsetup.exe : 네트워크 설정 마법사
실행창 명령어
일반명령어
calc (계산기)
charmap 문자표
cleanmgr 디스크정리
dfrg.msc 디스크 조각모음
dxdiag (다이렉트X 진단도구 및 그래픽과 사운드의 세부정보를 보여줌)
eudcedit 사용자 정의 문자 편집기
magnify 돋보기
mobsync 동기화
msconfig(시작프로그램 제어등 많은기능 제공)
msinfo32 시스템정보
mstsc 원격 데스크톱 연결
netstat -na(현재 열린포트와 TCP/IP 프로토콜정보를 보여줌)
열린포트로 트라이목마형 바이러스 침투 유무확인가능
notepad 메모장
ntbackup 백업 및 복원 마법사
regedit(레지스트리 편집기)
sfc(시스템 파일 검사기)
-시스템 파일을 검사한후 깨지거난 손실된 파일을 원본 압축파일에서 찾아서 복원시켜줌 . 단,
윈2000에서는 cmd실행 후 sfc사용 - 마지막 설정된 값을 다음 윈도우부팅시 곧바로 실행됨[수정]
sndrec32 녹음기
sndvol32 (시스템 사운드 등록정보,볼륨조절)
sysedit(autoexec.bat, config.sys, win.ini, system.ini 시스템구성편집기)
systray(사운드 볼륨설정 노란색 스피커 아이콘을 트라이목록에 띄움)
telnet open 사이트주소(텔넷접속명령어)
tourstart (윈도우 기능안내 html 문서표시)
wab 주소록
winipcfg(인터넷에 접속된 자신의 아이피 주소를 보여줌) 단, 윈2000은 ipconfig로 변경됨
winmine (지뢰찾기)
wmplayer (윈도우 미디어 플레이어)
wordpad 워드패드
wscui.cpl 보안센터
wupdmgr 윈도우업데이트
MSC명령어
certmgr.msc : 인증서 관리
ciadv.msc : 인덱싱 서비스
compmgmt.msc : 컴퓨터 관리
devmgmt.msc : 장치관리자
dfrg.msc : 디스크 조각 모음
diskmgmt.msc : 디스크 관리
eventvwr.msc : 이벤트 뷰어 (이벤트 로그)
fsmgmt.msc : 공유 폴더 (공유 폴더 관리)
gpedit.msc : 그룹 정책
lusrmgr.msc : 로컬 사용자 및 그룹
ntmsmgr.msc : Removable Storage
ntmsoprq.msc : 이동식 저장소 운영자 요청
perfmon.msc : 성능
rsop.msc : 정책의 결과 집합
secpol.msc : 로컬 보안 설정
services.msc : 서비스
wmimgmt.msc : WMI 서비스 구성
comexp.msc : comexp 구성 요소 서비스
control userpasswords2 : 사용자 계정
gpedit.msc : 도메인 또는 액티브 디렉토리나 PC에 저장되어 있는
조직 단위에 연결된 그룹정책개체를 편집하는
'로컬 컴퓨터 정책'을 연다.
clipbrd (클립보드에 복사된 내용 표시)
control (제어판)
winver (윈도우 버전확인)
osk 화상키보드
pbrush 또는 mspaint (그림판)
ping 사이트주소(핑테스트 해당 사이트의 인터넷연결 유무 확인)
explorer 탐색기
shutdown -i : GUI화면으로 시스템 종료, 재부팅 가능
shutdown -a : 종료 설정 중지
netstat : 인터넷 접속 상황
ipconfig /all : ip주소,게이트웨이,서브넷마스크,
DNS서버주소,physical주소
dxdiag : 다이렉트 - X 상태 정보 화면
cleanmgr.exe : 디스크 정리
regedit : 레지스트리 편집기
mstsc.exe : 원격 데스크톱 연결
netsetup.exe : 네트워크 설정 마법사
실행창 명령어
일반명령어
calc (계산기)
charmap 문자표
cleanmgr 디스크정리
dfrg.msc 디스크 조각모음
dxdiag (다이렉트X 진단도구 및 그래픽과 사운드의 세부정보를 보여줌)
eudcedit 사용자 정의 문자 편집기
magnify 돋보기
mobsync 동기화
msconfig(시작프로그램 제어등 많은기능 제공)
msinfo32 시스템정보
mstsc 원격 데스크톱 연결
netstat -na(현재 열린포트와 TCP/IP 프로토콜정보를 보여줌)
열린포트로 트라이목마형 바이러스 침투 유무확인가능
notepad 메모장
ntbackup 백업 및 복원 마법사
regedit(레지스트리 편집기)
sfc(시스템 파일 검사기)
-시스템 파일을 검사한후 깨지거난 손실된 파일을 원본 압축파일에서 찾아서 복원시켜줌 . 단,
윈2000에서는 cmd실행 후 sfc사용 - 마지막 설정된 값을 다음 윈도우부팅시 곧바로 실행됨[수정]
sndrec32 녹음기
sndvol32 (시스템 사운드 등록정보,볼륨조절)
sysedit(autoexec.bat, config.sys, win.ini, system.ini 시스템구성편집기)
systray(사운드 볼륨설정 노란색 스피커 아이콘을 트라이목록에 띄움)
telnet open 사이트주소(텔넷접속명령어)
tourstart (윈도우 기능안내 html 문서표시)
wab 주소록
winipcfg(인터넷에 접속된 자신의 아이피 주소를 보여줌) 단, 윈2000은 ipconfig로 변경됨
winmine (지뢰찾기)
wmplayer (윈도우 미디어 플레이어)
wordpad 워드패드
wscui.cpl 보안센터
wupdmgr 윈도우업데이트
MSC명령어
certmgr.msc : 인증서 관리
ciadv.msc : 인덱싱 서비스
compmgmt.msc : 컴퓨터 관리
devmgmt.msc : 장치관리자
dfrg.msc : 디스크 조각 모음
diskmgmt.msc : 디스크 관리
eventvwr.msc : 이벤트 뷰어 (이벤트 로그)
fsmgmt.msc : 공유 폴더 (공유 폴더 관리)
gpedit.msc : 그룹 정책
lusrmgr.msc : 로컬 사용자 및 그룹
ntmsmgr.msc : Removable Storage
ntmsoprq.msc : 이동식 저장소 운영자 요청
perfmon.msc : 성능
rsop.msc : 정책의 결과 집합
secpol.msc : 로컬 보안 설정
services.msc : 서비스
wmimgmt.msc : WMI 서비스 구성
comexp.msc : comexp 구성 요소 서비스
control userpasswords2 : 사용자 계정
gpedit.msc : 도메인 또는 액티브 디렉토리나 PC에 저장되어 있는
조직 단위에 연결된 그룹정책개체를 편집하는
'로컬 컴퓨터 정책'을 연다.
2009. 6. 11.
캐리지 리턴 문자 없애기
vi
:%s/^M//g
find `pwd` -name "*.*" | xargs grep "^M"
find `pwd` -name "*.*" -exec perl -pi -e 's/^M//g' {} \; -print
:%s/^M//g
find `pwd` -name "*.*" | xargs grep "^M"
find `pwd` -name "*.*" -exec perl -pi -e 's/^M//g' {} \; -print
2009. 5. 21.
[Shell] 구구단 및 별 출력 스크립트
[1] 구구단 출력
#!/bin/bash
dan=2
while [ $dan -lt 10 ]
do
echo " $dan 단"
echo "======"
num=1
while [ $num -lt 10 ]
do
answer=`expr $dan \* $num`
if [ $answer -lt 10 ]; then
answer=" $answer"
fi
echo "${dan}x${num}=${answer}"
num=`expr $num + 1`
done
dan=`expr $dan + 1`
echo ""
done
출력 :
2 단
======
2x1= 2
2x2= 4
2x3= 6
2x4= 8
2x5=10
2x6=12
2x7=14
2x8=16
2x9=18
.....
9 단
======
9x1= 9
9x2=18
9x3=27
9x4=36
9x5=45
9x6=54
9x7=63
9x8=72
9x9=81
[2] 구구단 출력 가로
#!/bin/bash
echo ""
num=1
while [ $num -lt 10 ]
do
dan=2
while [ $dan -lt 6 ]
do
answer=`expr $dan \* $num`
if [ $answer -lt 10 ]; then
answer=" $answer"
fi
echo -n "${dan}x${num}=${answer} "
dan=`expr $dan + 1`
done
num=`expr $num + 1`
echo ""
done
echo ""
num=1
while [ $num -lt 10 ]
do
dan=6
while [ $dan -lt 10 ]
do
answer=`expr $dan \* $num`
if [ $answer -lt 10 ]; then
answer=" $answer"
fi
echo -n "${dan}x${num}=${answer} "
dan=`expr $dan + 1`
done
num=`expr $num + 1`
echo ""
done
echo ""
출력 :
2x1= 2 3x1= 3 4x1= 4 5x1= 5
2x2= 4 3x2= 6 4x2= 8 5x2=10
2x3= 6 3x3= 9 4x3=12 5x3=15
2x4= 8 3x4=12 4x4=16 5x4=20
2x5=10 3x5=15 4x5=20 5x5=25
2x6=12 3x6=18 4x6=24 5x6=30
2x7=14 3x7=21 4x7=28 5x7=35
2x8=16 3x8=24 4x8=32 5x8=40
2x9=18 3x9=27 4x9=36 5x9=45
6x1= 6 7x1= 7 8x1= 8 9x1= 9
6x2=12 7x2=14 8x2=16 9x2=18
6x3=18 7x3=21 8x3=24 9x3=27
6x4=24 7x4=28 8x4=32 9x4=36
6x5=30 7x5=35 8x5=40 9x5=45
6x6=36 7x6=42 8x6=48 9x6=54
6x7=42 7x7=49 8x7=56 9x7=63
6x8=48 7x8=56 8x8=64 9x8=72
6x9=54 7x9=63 8x9=72 9x9=81
[3] 별 출력
#!/bin/bash
echo ""
echo -n "Number : "
read su
echo ""
i=1
while [ $i -le $su ]
do
j=1
while [ $j -le $i ]
do
echo -n "*"
j=`expr $j + 1`
done
i=`expr $i + 1`
echo ""
done
echo ""
출력 :
Number : 10
*
**
***
****
*****
******
*******
********
*********
**********
[4] 별 출력
#!/bin/bash
echo ""
echo -n "Number : "
read su
echo ""
i=1
while [ $i -le $su ]
do
j=1
k=`expr $su - $i`
while [ $j -le $su ]
do
if [ $j -le $k ]
then
echo -n " "
else
echo -n "*"
fi
j=`expr $j + 1`
done
i=`expr $i + 1`
echo ""
done
echo ""
출력 :
Number : 10
*
**
***
****
*****
******
*******
********
*********
**********
[5] 별 출력
#!/bin/bash
echo ""
echo -n "Number : "
read su
echo ""
i=1
while [ $i -le $su ]
do
j=1
k=`expr $su - $i`
l=`expr $su + $i - 1`
while [ $j -le $l ]
do
if [ $j -le $k ]
then
echo -n " "
else
echo -n "*"
fi
j=`expr $j + 1`
done
i=`expr $i + 1`
echo ""
done
echo ""
출력 :
Number : 10
*
***
*****
*******
*********
***********
*************
***************
*****************
*******************
[6] 별 출력
#!/bin/bash
echo ""
echo -n "Number : "
read su
echo ""
i=1
while [ $i -le $su ]
do
j=1
k=`expr $su - $i + 1`
while [ $j -le $k ]
do
echo -n "*"
j=`expr $j + 1`
done
i=`expr $i + 1`
echo ""
done
echo ""
출력 :
Number : 10
**********
*********
********
*******
******
*****
****
***
**
*
[7] 별 출력
#!/bin/bash
echo ""
echo -n "Number : "
read su
echo ""
i=1
while [ $i -le $su ]
do
j=1
while [ $j -le $su ]
do
if [ $j -lt $i ]
then
echo -n " "
else
echo -n "*"
fi
j=`expr $j + 1`
done
i=`expr $i + 1`
echo ""
done
echo ""
출력 :
Number : 10
**********
*********
********
*******
******
*****
****
***
**
*
[8] 별 출력
#!/bin/bash
echo ""
echo -n "Number : "
read su
echo ""
i=1
while [ $i -le $su ]
do
j=1
k=`expr $su \* 2 - $i`
while [ $j -le $k ]
do
if [ $j -lt $i ]
then
echo -n " "
else
echo -n "*"
fi
j=`expr $j + 1`
done
i=`expr $i + 1`
echo ""
done
echo ""
출력 :
Number : 10
*******************
*****************
***************
*************
***********
*********
*******
*****
***
*
[9] 별 출력
#!/bin/bash
echo ""
echo -n "Number : "
read su
echo ""
i=1
while [ $i -le $su ]
do
j=1
k=`expr $su - $i`
l=`expr $su - 1 + $i`
while [ $j -le $l ]
do
if [ $j -le $k ]
then
echo -n " "
else
echo -n "*"
fi
j=`expr $j + 1`
done
i=`expr $i + 1`
echo ""
done
i=1
while [ $i -le $su ]
do
j=1
k=`expr $su \* 2 - $i - 1`
while [ $j -le $k ]
do
if [ $j -le $i ]
then
echo -n " "
else
echo -n "*"
fi
j=`expr $j + 1`
done
i=`expr $i + 1`
echo ""
done
echo ""
출력 :
Number : 10
*
***
*****
*******
*********
***********
*************
***************
*****************
*******************
*****************
***************
*************
***********
*********
*******
*****
***
*
#!/bin/bash
dan=2
while [ $dan -lt 10 ]
do
echo " $dan 단"
echo "======"
num=1
while [ $num -lt 10 ]
do
answer=`expr $dan \* $num`
if [ $answer -lt 10 ]; then
answer=" $answer"
fi
echo "${dan}x${num}=${answer}"
num=`expr $num + 1`
done
dan=`expr $dan + 1`
echo ""
done
출력 :
2 단
======
2x1= 2
2x2= 4
2x3= 6
2x4= 8
2x5=10
2x6=12
2x7=14
2x8=16
2x9=18
.....
9 단
======
9x1= 9
9x2=18
9x3=27
9x4=36
9x5=45
9x6=54
9x7=63
9x8=72
9x9=81
[2] 구구단 출력 가로
#!/bin/bash
echo ""
num=1
while [ $num -lt 10 ]
do
dan=2
while [ $dan -lt 6 ]
do
answer=`expr $dan \* $num`
if [ $answer -lt 10 ]; then
answer=" $answer"
fi
echo -n "${dan}x${num}=${answer} "
dan=`expr $dan + 1`
done
num=`expr $num + 1`
echo ""
done
echo ""
num=1
while [ $num -lt 10 ]
do
dan=6
while [ $dan -lt 10 ]
do
answer=`expr $dan \* $num`
if [ $answer -lt 10 ]; then
answer=" $answer"
fi
echo -n "${dan}x${num}=${answer} "
dan=`expr $dan + 1`
done
num=`expr $num + 1`
echo ""
done
echo ""
출력 :
2x1= 2 3x1= 3 4x1= 4 5x1= 5
2x2= 4 3x2= 6 4x2= 8 5x2=10
2x3= 6 3x3= 9 4x3=12 5x3=15
2x4= 8 3x4=12 4x4=16 5x4=20
2x5=10 3x5=15 4x5=20 5x5=25
2x6=12 3x6=18 4x6=24 5x6=30
2x7=14 3x7=21 4x7=28 5x7=35
2x8=16 3x8=24 4x8=32 5x8=40
2x9=18 3x9=27 4x9=36 5x9=45
6x1= 6 7x1= 7 8x1= 8 9x1= 9
6x2=12 7x2=14 8x2=16 9x2=18
6x3=18 7x3=21 8x3=24 9x3=27
6x4=24 7x4=28 8x4=32 9x4=36
6x5=30 7x5=35 8x5=40 9x5=45
6x6=36 7x6=42 8x6=48 9x6=54
6x7=42 7x7=49 8x7=56 9x7=63
6x8=48 7x8=56 8x8=64 9x8=72
6x9=54 7x9=63 8x9=72 9x9=81
[3] 별 출력
#!/bin/bash
echo ""
echo -n "Number : "
read su
echo ""
i=1
while [ $i -le $su ]
do
j=1
while [ $j -le $i ]
do
echo -n "*"
j=`expr $j + 1`
done
i=`expr $i + 1`
echo ""
done
echo ""
출력 :
Number : 10
*
**
***
****
*****
******
*******
********
*********
**********
[4] 별 출력
#!/bin/bash
echo ""
echo -n "Number : "
read su
echo ""
i=1
while [ $i -le $su ]
do
j=1
k=`expr $su - $i`
while [ $j -le $su ]
do
if [ $j -le $k ]
then
echo -n " "
else
echo -n "*"
fi
j=`expr $j + 1`
done
i=`expr $i + 1`
echo ""
done
echo ""
출력 :
Number : 10
*
**
***
****
*****
******
*******
********
*********
**********
[5] 별 출력
#!/bin/bash
echo ""
echo -n "Number : "
read su
echo ""
i=1
while [ $i -le $su ]
do
j=1
k=`expr $su - $i`
l=`expr $su + $i - 1`
while [ $j -le $l ]
do
if [ $j -le $k ]
then
echo -n " "
else
echo -n "*"
fi
j=`expr $j + 1`
done
i=`expr $i + 1`
echo ""
done
echo ""
출력 :
Number : 10
*
***
*****
*******
*********
***********
*************
***************
*****************
*******************
[6] 별 출력
#!/bin/bash
echo ""
echo -n "Number : "
read su
echo ""
i=1
while [ $i -le $su ]
do
j=1
k=`expr $su - $i + 1`
while [ $j -le $k ]
do
echo -n "*"
j=`expr $j + 1`
done
i=`expr $i + 1`
echo ""
done
echo ""
출력 :
Number : 10
**********
*********
********
*******
******
*****
****
***
**
*
[7] 별 출력
#!/bin/bash
echo ""
echo -n "Number : "
read su
echo ""
i=1
while [ $i -le $su ]
do
j=1
while [ $j -le $su ]
do
if [ $j -lt $i ]
then
echo -n " "
else
echo -n "*"
fi
j=`expr $j + 1`
done
i=`expr $i + 1`
echo ""
done
echo ""
출력 :
Number : 10
**********
*********
********
*******
******
*****
****
***
**
*
[8] 별 출력
#!/bin/bash
echo ""
echo -n "Number : "
read su
echo ""
i=1
while [ $i -le $su ]
do
j=1
k=`expr $su \* 2 - $i`
while [ $j -le $k ]
do
if [ $j -lt $i ]
then
echo -n " "
else
echo -n "*"
fi
j=`expr $j + 1`
done
i=`expr $i + 1`
echo ""
done
echo ""
출력 :
Number : 10
*******************
*****************
***************
*************
***********
*********
*******
*****
***
*
[9] 별 출력
#!/bin/bash
echo ""
echo -n "Number : "
read su
echo ""
i=1
while [ $i -le $su ]
do
j=1
k=`expr $su - $i`
l=`expr $su - 1 + $i`
while [ $j -le $l ]
do
if [ $j -le $k ]
then
echo -n " "
else
echo -n "*"
fi
j=`expr $j + 1`
done
i=`expr $i + 1`
echo ""
done
i=1
while [ $i -le $su ]
do
j=1
k=`expr $su \* 2 - $i - 1`
while [ $j -le $k ]
do
if [ $j -le $i ]
then
echo -n " "
else
echo -n "*"
fi
j=`expr $j + 1`
done
i=`expr $i + 1`
echo ""
done
echo ""
출력 :
Number : 10
*
***
*****
*******
*********
***********
*************
***************
*****************
*******************
*****************
***************
*************
***********
*********
*******
*****
***
*
2009. 5. 20.
grep, egrep, fgrep
grep, egrep, fgrep
grep(egrep, fgrep) [option] “pattern” filename
-i : 대소문자 구별을 하지 않는다.
-v : pattern 을 포함하지 않는 행만 출력한다.
-n : 행번호를 출력한다.
-l : 파일명만 출력한다.
-c : 패턴과 일치하는 라인의 갯수만 보여준다.
grep : 강력한 패턴 매칭 템플릿을 정의하기 위해 "정규 표현식"을 사용할 수 있다.
egrep [옵션] "패턴|패턴|..." [대상파일들] : 확장된 정규 표현식을 사용하며, 찾아낼 패턴을 여러개 지정할 수 있다. '|'기호는 불린 연산자 "OR"에 해당하므로, 정해진 패턴들에 포함되는 모든 라인을 보여준다.
fgrep [옵션] 패턴 [대상파일들] : 패턴과 정확히 일치하는 것만을 찾아 준다.
많은 시스템 관리 명령들과 파이프(pipe)를 이용해서 사용할 수 있다. 흔히 사용하는 것은 프로세스 확인이다.
$ ps aux | grep httpd
위와 같이 현재 시스템의 프로세스중 httpd 만 검색해 낸다.
만일 pipe 를 이용하여 검색할경우 검색 패턴이 한개 이상일 경우엔 egrep을 이용하여 검색할수 있다.
$ ps aux | egrep 'httpd|mysql'
$ grep -v "^[ ^I]*$" 파일명 //공백을 제거한 파일 내용 살펴보기
$ grep -v "^#*$" 파일명 //주석을 제거한 파일 내용 살펴보기
만일 현재 디렉토리와 그 하위 디렉토리까지 grep 패턴 검색을 하고자 할땐 find 명령을 이용하면 된다.
$ find . -exec grep "pattern" {} \;
grep(egrep, fgrep) [option] “pattern” filename
-i : 대소문자 구별을 하지 않는다.
-v : pattern 을 포함하지 않는 행만 출력한다.
-n : 행번호를 출력한다.
-l : 파일명만 출력한다.
-c : 패턴과 일치하는 라인의 갯수만 보여준다.
grep : 강력한 패턴 매칭 템플릿을 정의하기 위해 "정규 표현식"을 사용할 수 있다.
egrep [옵션] "패턴|패턴|..." [대상파일들] : 확장된 정규 표현식을 사용하며, 찾아낼 패턴을 여러개 지정할 수 있다. '|'기호는 불린 연산자 "OR"에 해당하므로, 정해진 패턴들에 포함되는 모든 라인을 보여준다.
fgrep [옵션] 패턴 [대상파일들] : 패턴과 정확히 일치하는 것만을 찾아 준다.
많은 시스템 관리 명령들과 파이프(pipe)를 이용해서 사용할 수 있다. 흔히 사용하는 것은 프로세스 확인이다.
$ ps aux | grep httpd
위와 같이 현재 시스템의 프로세스중 httpd 만 검색해 낸다.
만일 pipe 를 이용하여 검색할경우 검색 패턴이 한개 이상일 경우엔 egrep을 이용하여 검색할수 있다.
$ ps aux | egrep 'httpd|mysql'
$ grep -v "^[ ^I]*$" 파일명 //공백을 제거한 파일 내용 살펴보기
$ grep -v "^#*$" 파일명 //주석을 제거한 파일 내용 살펴보기
만일 현재 디렉토리와 그 하위 디렉토리까지 grep 패턴 검색을 하고자 할땐 find 명령을 이용하면 된다.
$ find . -exec grep "pattern" {} \;
2009. 4. 22.
VIM 이미 읽은 파일의 인코딩 변경하기
출처 : http://kldp.org/node/32987
VIM 이미 읽은 파일의 인코딩 변경하기 (charset encoding)
The image verification code you entered is incorrect.
kwon37xi 씀 (금, 2004/04/02 - 10:19am) 강좌
요즌 페도라에서 UTF-8 로 사용하다보니 한글 인코딩 문제에 자주 부딪힙니다.
특히 텍스트 파일 읽을 때 짜증이 이만저만이 아닙니다.
암튼, VIM 에서 파일을 읽어보니 문자 인코딩이 깨져 있을 때, 다음과 같이 하면 곧바로 인코딩을 바꿔서 화면에 표시합니다.
:e ++enc=euc-kr
이 상태에서... 파일의 인코딩을 바꿔서 저장하려면
:set fileencoding=utf-8
한뒤에 :w 해보세요. euc-kr 이던 파일이 utf-8 로 저장됩니다.
MS949 를 시도해봤는데 안되더군요. UHC 로 해야 MS-Windows 의 확장한글코드가 되는것 같습니다. - 맞는건가요? 확실치 않아서리...
VIM 이미 읽은 파일의 인코딩 변경하기 (charset encoding)
The image verification code you entered is incorrect.
kwon37xi 씀 (금, 2004/04/02 - 10:19am) 강좌
요즌 페도라에서 UTF-8 로 사용하다보니 한글 인코딩 문제에 자주 부딪힙니다.
특히 텍스트 파일 읽을 때 짜증이 이만저만이 아닙니다.
암튼, VIM 에서 파일을 읽어보니 문자 인코딩이 깨져 있을 때, 다음과 같이 하면 곧바로 인코딩을 바꿔서 화면에 표시합니다.
:e ++enc=euc-kr
이 상태에서... 파일의 인코딩을 바꿔서 저장하려면
:set fileencoding=utf-8
한뒤에 :w 해보세요. euc-kr 이던 파일이 utf-8 로 저장됩니다.
MS949 를 시도해봤는데 안되더군요. UHC 로 해야 MS-Windows 의 확장한글코드가 되는것 같습니다. - 맞는건가요? 확실치 않아서리...
리눅스 환경에서 한글 설정하는 방법
[Ctrl + Alt + T] 키를 눌러 터미널을 엽니다.
언어 환경설정 파일을 수정합니다.
참고1 : http://wiki.eeeuser.com/howto:changelanguage
참고2 : http://www.chitsol.com/455
참고3 : http://debianusers.org/DebianWiki/wiki.php/%C3%CA%BA%B8%B0%A3%B4%DC%C7%D1%B1%DB%B0%A1%C0%CC%B5%E5
로케일 설정을 담당하는 /etc/locale.gen 을 수정합니다.
sudo vi /etc/locale.gen
ko_KR.UTF-8 UTF-8
다음 명령을 실행합니다
sudo locale-gen
sudo update-locale LANG=ko_KR.UTF-8
-> 이 명령을 실행하면 /etc/default/locale 이라는 파일이 생성됩니다.
한글 입력기 설치를 위해 프로그램 설치 저장소를 추가합니다. 앞으로 다양한 응용프로그램 설치시에도 이용됩니다.
sudo vi /etc/apt/sources.list
deb http://xnv4.xandros.com/xs2.0/upkg-srv2 etch main contrib non-free
deb http://dccamirror.xandros.com/dccri/ dccri-3.0 main
deb http://www.geekconnection.org/ xandros4 main
아래의 명령을 순서대로 실행하여 입력기인 scim과 한글 폰트를 설치합니다.
wget http://download.tuxfamily.org/eeepcrepos/key.asc
sudo apt-key add key.asc
sudo apt-get update
sudo apt-get install scim scim-hangul scim-tables-ko ttf-alee ttf-unfonts
작업이 완료되면 재부팅을 합니다.
다중언어입력기 SCIM의 환경을 설정합니다.
오른쪽 아래의 트레이영역에서 입력기 아이콘(input method 라고 풍선도움말이 표시됨)에서 오른쪽 마우스를 클릭하여 SCIM 설정을 선택합니다.
[입력기엔진] -> [전체 설정] -> [설치된 입력기 서비스들:] 에서
[한국어] - [두벌식]과 [한자]만 선택하고(또는 각 개인이 사용하는 자판 형식) 나머지는 모두 선택을 해제 합니다.
설정을 적용하고 환경설정을 끝냅니다.
영어 입력 상태에서 한글 입력을 할려면 왼쪽 Ctrl + Space 키를 누르면 입력 상태가 전환됩니다. 반대의 경우도 같습니다.
** 콘솔에서 한글이 표시 되지 않고 영어가 표시되게 설정하는 방법입니다.
참고1 : http://kldp.org/node/78712
참고2 : http://safari.oreilly.com/0596526784/using_initialization_files_correctly
vi .bashrc (만약 전체 사용자에게 동일하기 적용할려면 /etc/bash.bashrc 파일을 맨 끝에 아래 내용을 추가하면 됩니다.)
export LANGUAGE="ko_KR:ko:en_GB:en"
export LC_MESSAGES="POSIX"
export LC_ALL=""
locate 명령으로 설정된 값을 확인합니다.
LANG=ko_KR.UTF-8
LC_CTYPE="ko_KR.UTF-8"
LC_NUMERIC="ko_KR.UTF-8"
LC_TIME="ko_KR.UTF-8"
LC_COLLATE="ko_KR.UTF-8"
LC_MONETARY="ko_KR.UTF-8"
LC_MESSAGES=POSIX
LC_PAPER="ko_KR.UTF-8"
LC_NAME="ko_KR.UTF-8"
LC_ADDRESS="ko_KR.UTF-8"
LC_TELEPHONE="ko_KR.UTF-8"
LC_MEASUREMENT="ko_KR.UTF-8"
LC_IDENTIFICATION="ko_KR.UTF-8"
LC_ALL=
언어 환경설정 파일을 수정합니다.
참고1 : http://wiki.eeeuser.com/howto:changelanguage
참고2 : http://www.chitsol.com/455
참고3 : http://debianusers.org/DebianWiki/wiki.php/%C3%CA%BA%B8%B0%A3%B4%DC%C7%D1%B1%DB%B0%A1%C0%CC%B5%E5
로케일 설정을 담당하는 /etc/locale.gen 을 수정합니다.
sudo vi /etc/locale.gen
ko_KR.UTF-8 UTF-8
다음 명령을 실행합니다
sudo locale-gen
sudo update-locale LANG=ko_KR.UTF-8
-> 이 명령을 실행하면 /etc/default/locale 이라는 파일이 생성됩니다.
한글 입력기 설치를 위해 프로그램 설치 저장소를 추가합니다. 앞으로 다양한 응용프로그램 설치시에도 이용됩니다.
sudo vi /etc/apt/sources.list
deb http://xnv4.xandros.com/xs2.0/upkg-srv2 etch main contrib non-free
deb http://dccamirror.xandros.com/dccri/ dccri-3.0 main
deb http://www.geekconnection.org/ xandros4 main
아래의 명령을 순서대로 실행하여 입력기인 scim과 한글 폰트를 설치합니다.
wget http://download.tuxfamily.org/eeepcrepos/key.asc
sudo apt-key add key.asc
sudo apt-get update
sudo apt-get install scim scim-hangul scim-tables-ko ttf-alee ttf-unfonts
작업이 완료되면 재부팅을 합니다.
다중언어입력기 SCIM의 환경을 설정합니다.
오른쪽 아래의 트레이영역에서 입력기 아이콘(input method 라고 풍선도움말이 표시됨)에서 오른쪽 마우스를 클릭하여 SCIM 설정을 선택합니다.
[입력기엔진] -> [전체 설정] -> [설치된 입력기 서비스들:] 에서
[한국어] - [두벌식]과 [한자]만 선택하고(또는 각 개인이 사용하는 자판 형식) 나머지는 모두 선택을 해제 합니다.
설정을 적용하고 환경설정을 끝냅니다.
영어 입력 상태에서 한글 입력을 할려면 왼쪽 Ctrl + Space 키를 누르면 입력 상태가 전환됩니다. 반대의 경우도 같습니다.
** 콘솔에서 한글이 표시 되지 않고 영어가 표시되게 설정하는 방법입니다.
참고1 : http://kldp.org/node/78712
참고2 : http://safari.oreilly.com/0596526784/using_initialization_files_correctly
vi .bashrc (만약 전체 사용자에게 동일하기 적용할려면 /etc/bash.bashrc 파일을 맨 끝에 아래 내용을 추가하면 됩니다.)
export LANGUAGE="ko_KR:ko:en_GB:en"
export LC_MESSAGES="POSIX"
export LC_ALL=""
locate 명령으로 설정된 값을 확인합니다.
LANG=ko_KR.UTF-8
LC_CTYPE="ko_KR.UTF-8"
LC_NUMERIC="ko_KR.UTF-8"
LC_TIME="ko_KR.UTF-8"
LC_COLLATE="ko_KR.UTF-8"
LC_MONETARY="ko_KR.UTF-8"
LC_MESSAGES=POSIX
LC_PAPER="ko_KR.UTF-8"
LC_NAME="ko_KR.UTF-8"
LC_ADDRESS="ko_KR.UTF-8"
LC_TELEPHONE="ko_KR.UTF-8"
LC_MEASUREMENT="ko_KR.UTF-8"
LC_IDENTIFICATION="ko_KR.UTF-8"
LC_ALL=
VNC 서버 설정
1. VNC 서버 설치
yum install vnc-server
service vncserver start
2. 설정
/etc/sysconfig/vncserver
* root로 원격에서 접속가능하게 설정하기
VNCSERVERS="2:root"
VNCSERVERARGS[2]="-geometry 800x600 -nolisten tcp -nohttpd"
* 패스워드 설정
vncpasswd 명령을 실행
* 그놈으로 VNC 원격 열기
~/.vnc/xstartup 수정
#!/bin/sh
# Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER
# exec /etc/X11/xinit/xinitrc
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
#xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#twm &
export GTK_IM_MODULE=scim <- 한글 입력을 위해
gnome-session & <- 그놈 데스크탑 실행
3. 클라이언트 접속
UltraVNC를 설치하여 UltraVNC Viewer 를 실행
VNC Server : 에 www.junix.pe.kr:2 를 입력하고 vncpasswd에서 지정한 암호 입력
yum install vnc-server
service vncserver start
2. 설정
/etc/sysconfig/vncserver
* root로 원격에서 접속가능하게 설정하기
VNCSERVERS="2:root"
VNCSERVERARGS[2]="-geometry 800x600 -nolisten tcp -nohttpd"
* 패스워드 설정
vncpasswd 명령을 실행
* 그놈으로 VNC 원격 열기
~/.vnc/xstartup 수정
#!/bin/sh
# Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER
# exec /etc/X11/xinit/xinitrc
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
#xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#twm &
export GTK_IM_MODULE=scim <- 한글 입력을 위해
gnome-session & <- 그놈 데스크탑 실행
3. 클라이언트 접속
UltraVNC를 설치하여 UltraVNC Viewer 를 실행
VNC Server : 에 www.junix.pe.kr:2 를 입력하고 vncpasswd에서 지정한 암호 입력
logwatch 7.2.1 on fc5
1. 설치
yum install logwatch
2. 설정
vi /etc/logwatch/conf/logwatch.conf
########################################################
# This was written and is maintained by:
# Kirk Bauer
#
# Please send all comments, suggestions, bug reports,
# etc, to kirk@kaybee.org.
#
########################################################
# NOTE:
# All these options are the defaults if you run logwatch with no
# command-line arguments. You can override all of these on the
# command-line.
# You can put comments anywhere you want to. They are effective for the
# rest of the line.
# this is in the format of = . Whitespace at the beginning
# and end of the lines is removed. Whitespace before and after the = sign
# is removed. Everything is case *insensitive*.
# Yes = True = On = 1
# No = False = Off = 0
# Default Log Directory
# All log-files are assumed to be given relative to this directory.
LogDir = /var/log
# You can override the default temp directory (/tmp) here
TmpDir = /var/cache/logwatch
# Default person to mail reports to. Can be a local account or a
# complete email address.
MailTo = jongjun 보고서를 받을 메일 계정
# Default person to mail reports from. Can be a local account or a
# complete email address.
MailFrom = Logwatch
# If set to 'Yes', the report will be sent to stdout instead of being
# mailed to above person.
Print = Yes
# if set, the results will be saved in instead of mailed
# or displayed.
#Save = /tmp/logwatch
# Use archives? If set to 'Yes', the archives of logfiles
# (i.e. /var/log/messages.1 or /var/log/messages.1.gz) will
# be searched in addition to the /var/log/messages file.
# This usually will not do much if your range is set to just
# 'Yesterday' or 'Today'... it is probably best used with
# Archives = Yes
# Range = All
# The default time range for the report...
# The current choices are All, Today, Yesterday
Range = yesterday
# The default detail level for the report.
# This can either be Low, Med, High or a number.
# Low = 0
# Med = 5
# High = 10
Detail = Low
# The 'Service' option expects either the name of a filter
# (in /usr/share/logwatch/scripts/services/*) or 'All'.
# The default service(s) to report on. This should be left as All for
# most people.
Service = All
# You can also disable certain services (when specifying all)
Service = "-zz-network" # Prevents execution of zz-network service, which
# prints useful network configuration info.
# If you only cared about FTP messages, you could use these 2 lines
# instead of the above:
#Service = ftpd-messages # Processes ftpd messages in /var/log/messages
#Service = ftpd-xferlog # Processes ftpd messages in /var/log/xferlog
# Maybe you only wanted reports on PAM messages, then you would use:
#Service = pam_pwdb # PAM_pwdb messages - usually quite a bit
#Service = pam # General PAM messages... usually not many
# You can also choose to use the 'LogFile' option. This will cause
# logwatch to only analyze that one logfile.. for example:
#LogFile = messages
# will process /var/log/messages. This will run all the filters that
# process that logfile. This option is probably not too useful to
# most people. Setting 'Service' to 'All' above analyizes all LogFiles
# anyways...
#
# By default we assume that all Unix systems have sendmail or a sendmail-like system.
# The mailer code Prints a header with To: From: and Subject:.
# At this point you can change the mailer to any thing else that can handle that output
# stream. TODO test variables in the mailer string to see if the To/From/Subject can be set
# From here with out breaking anything. This would allow mail/mailx/nail etc..... -mgt
mailer = "sendmail -t"
#
# With this option set to 'Yes', only log entries for this particular host
# (as returned by 'hostname' command) will be processed. The hostname
# can also be overridden on the commandline (with --hostname option). This
# can allow a log host to process only its own logs, or Logwatch can be
# run once per host included in the logfiles.
#
# The default is to report on all log entries, regardless of its source host.
# Note that some logfiles do not include host information and will not be
# influenced by this setting.
#
#HostLimit = Yes
# vi: shiftwidth=3 tabstop=3 et
3. 보고서 작성
/usr/sbin/logwatch 실행
4. 확인
Logwatch로 부터 jongjun으로 온 메일 확인
yum install logwatch
2. 설정
vi /etc/logwatch/conf/logwatch.conf
########################################################
# This was written and is maintained by:
# Kirk Bauer
#
# Please send all comments, suggestions, bug reports,
# etc, to kirk@kaybee.org.
#
########################################################
# NOTE:
# All these options are the defaults if you run logwatch with no
# command-line arguments. You can override all of these on the
# command-line.
# You can put comments anywhere you want to. They are effective for the
# rest of the line.
# this is in the format of
# and end of the lines is removed. Whitespace before and after the = sign
# is removed. Everything is case *insensitive*.
# Yes = True = On = 1
# No = False = Off = 0
# Default Log Directory
# All log-files are assumed to be given relative to this directory.
LogDir = /var/log
# You can override the default temp directory (/tmp) here
TmpDir = /var/cache/logwatch
# Default person to mail reports to. Can be a local account or a
# complete email address.
MailTo = jongjun 보고서를 받을 메일 계정
# Default person to mail reports from. Can be a local account or a
# complete email address.
MailFrom = Logwatch
# If set to 'Yes', the report will be sent to stdout instead of being
# mailed to above person.
Print = Yes
# if set, the results will be saved in
# or displayed.
#Save = /tmp/logwatch
# Use archives? If set to 'Yes', the archives of logfiles
# (i.e. /var/log/messages.1 or /var/log/messages.1.gz) will
# be searched in addition to the /var/log/messages file.
# This usually will not do much if your range is set to just
# 'Yesterday' or 'Today'... it is probably best used with
# Archives = Yes
# Range = All
# The default time range for the report...
# The current choices are All, Today, Yesterday
Range = yesterday
# The default detail level for the report.
# This can either be Low, Med, High or a number.
# Low = 0
# Med = 5
# High = 10
Detail = Low
# The 'Service' option expects either the name of a filter
# (in /usr/share/logwatch/scripts/services/*) or 'All'.
# The default service(s) to report on. This should be left as All for
# most people.
Service = All
# You can also disable certain services (when specifying all)
Service = "-zz-network" # Prevents execution of zz-network service, which
# prints useful network configuration info.
# If you only cared about FTP messages, you could use these 2 lines
# instead of the above:
#Service = ftpd-messages # Processes ftpd messages in /var/log/messages
#Service = ftpd-xferlog # Processes ftpd messages in /var/log/xferlog
# Maybe you only wanted reports on PAM messages, then you would use:
#Service = pam_pwdb # PAM_pwdb messages - usually quite a bit
#Service = pam # General PAM messages... usually not many
# You can also choose to use the 'LogFile' option. This will cause
# logwatch to only analyze that one logfile.. for example:
#LogFile = messages
# will process /var/log/messages. This will run all the filters that
# process that logfile. This option is probably not too useful to
# most people. Setting 'Service' to 'All' above analyizes all LogFiles
# anyways...
#
# By default we assume that all Unix systems have sendmail or a sendmail-like system.
# The mailer code Prints a header with To: From: and Subject:.
# At this point you can change the mailer to any thing else that can handle that output
# stream. TODO test variables in the mailer string to see if the To/From/Subject can be set
# From here with out breaking anything. This would allow mail/mailx/nail etc..... -mgt
mailer = "sendmail -t"
#
# With this option set to 'Yes', only log entries for this particular host
# (as returned by 'hostname' command) will be processed. The hostname
# can also be overridden on the commandline (with --hostname option). This
# can allow a log host to process only its own logs, or Logwatch can be
# run once per host included in the logfiles.
#
# The default is to report on all log entries, regardless of its source host.
# Note that some logfiles do not include host information and will not be
# influenced by this setting.
#
#HostLimit = Yes
# vi: shiftwidth=3 tabstop=3 et
3. 보고서 작성
/usr/sbin/logwatch 실행
4. 확인
Logwatch로 부터 jongjun으로 온 메일 확인
피드 구독하기:
글 (Atom)