기타

[스크랩] unix command 관련 정리 된 것을 가져옴

xerxer 2010. 3. 23. 09:19

SUNOS 공통


1>    인터페이스 정보 및 설정방법

인터페이스 확인시 -> #ifconfig –a

인터페이스 아이피 할당 -> ifconfig hme0 inet 192.168.10.1 netmask 255.255.255.0 up


2>    CPU IDLE 타임 보는 방법

#vmstat 1


3>    디폴트 라우팅 및 라우팅테이블 넣는 방법 및 확인 방법


#route add net default 10.1.1.1 1

#route add net 200.1.1.0 –netmask 255.255.255.0 10.2.2.1 1

#netstat –rnv


4>    네트워크 트래픽 및 상태 보는 방법

#netstat –i 1


5>    가동시간 보는방법

#uptime


6>    dmesg보는 방법

#dmesg | more


7>    프로세스 보는 방법

#ps –ef | more

#/usr/ucb/ps aux | more


8>    리부팅 방법

#sync

#reboot


9>    시스템정보보는 방법

#showrev

#uname –a

#hosted

#hostname

#prtconf

#psrinfo

#prtmem


10>메모리 및 CPU를 많이 차지하는 프로세스 보는 방법


#prstat

#/usr/ucb/ps aux more

#ps -ef -o pcpu -o comm | sort –nr


11> 디스크 파티션 보는 방법

#df -k


12> 디스크 정보 보는 방법

#format


13> snoop사용하는 방법

#snoop –d hme0 192.168.1.1 à 192.168.1.1을 가진 패킷 모니터링

#snoop –d hme0 | grep 192.168.1.1 à 위와같음

#snoop –d hme0 from 192.168.1.1 to 10.10.10.1 à 192.168.1.1 에서 10.10.10.1번으로 가는 패킷 모니터링

#snoop –d hme0 from 192.168.1.1

#snoop –d hme0 to 192.169.1.1

#snoop –v(verbose mode 패킷 감시)

#snoop –V(summary mode 패킷 감시)

#snoop –d hme0 192.168.1.1 –o test.txt(모니터링한 패킷을 저장)

#snoop –i test.txt(저장파일을 읽어들일 때 사용)


14> find명령어 사용법

#find . -name "*.html" è 특정 문자열 검색

#find . -mtime –5 * è 특정일동안 변경된 파일 찾기(5일동안 수정된 파일 검색)

#find . -mtime +30 * è 30일동안 수정되지 않은 파일 검색

# find /  -mount -size +10000k è file size가 10m이상이 파일 검색


15>ndd 명령어 사용법

#ndd –get /dev/ip \?

#ndd –get /dev/hme \?

#ndd –get /dev/ip ip_forwarding

#ndd –get /dev/hme link_mode link_speed linkstatus



16> shared memory삭제하는 방법

shared  memory를 차지하고 있는 프로세스 보기

#ipcs –am


프로세스 삭제하기

#ipcrm –m [ID]


17> core파일 보는 방법

/var/crash/”hostname”밑의 core파일 보는방법(crash core)

# adb -k unix.0 vmcore.0

$<msgbuf


#iscda unix.0 vmcore.0


system core파일 보는법

#pstack core파일


#crash –d core파일


18> tar 명령어 사용하는 방법

tar cvf conf.tar * è 압축하는 방법

tar xvf conf.tar è 압축한거 푸는 방법


19> file size확인 하는 방법

#du -k


20> core file 없애는 방법

find / -name core -exec rm {} \;


21> 시스템 커널정보 보는 명령어

#isainfo –v


22> ln명령어 사용법

ln –s /opt/SECUREWORKS/3.0/logs/spool /opt/SECUREWORKS/3.0/spool


è 이 예는 3.0/spool을 logs/spool로 링크를 걸어 놓은 것이고 하는 방법은

logs밑에 spool디렉토리를 만든 위처럼 명령어를 치면된다 위 명령어를 실행하기전에

3.0밑에 spool이라는 디렉토리가 없어야 함 이 디렉토리는 위 명령어를 치면 자동으로 생김 


23> binary file 보는 명령어

#strings


24> netstat 명령어 사용법

netstat –rnv è 라우팅

netstat –np è ARP테에블

netstat –ak iprb0 è 인터페이스 정보

netstat –i 1 è 실시간 패킷 모니터링

netstat –I hme0 1 è 인터페이스별 실시간 패킷 모니터링


25> spool에 쌓인 대량의 파일 지우는 방법

지우려고 하는 디렉토리로 이동

# find ./ -name “MI*” -exec rm {} \;

# find ./ -name “MD*” -exec rm {} \;


26> SUN OS에서 NTP설정하는 방법

1. /etc/inet/ntp.client를 /etc/inet/ntp.conf로 copy한 후  다음과 같이 설정합니다.


만약, NTP 서버가 172.17.17.17 이라면...



  # cp /etc/inet/ntp.clinet /etc/inet/ntp.conf



# @(#)ntp.client        1.2     96/11/06 SMI

#

# /etc/inet/ntp.client

#

# An example file that could be copied over to /etc/inet/ntp.conf; it

# provides a configuration for a host that passively waits for a server

# to provide NTP packets on the ntp multicast net.

#


#multicastclient 224.0.1.1

server 172.17.17.17



27> 백업하는 방법

full backupdㄹ 할 때 :

#ufsdump 0ucf /dev/rmt/0

복구시키는 방법

#ufsrestore if /dev/rmt/0


28> 이더넷(ethernet) 디바이스의 종류



이더넷 디바이스의 종류

sparc >>>>>>>>>>>>>>>>>>>>>>>>>

bge SUNW,bge Gigabit Ethernet driver for Broadcom BCM5704
ce Cassini Gigabit-Ethernet device driver
dman SUNW,dman Sun Fire 15K management network device driver
dmfe Davicom Fast Ethernet driver for Davicom DM9102A
eri eri Fast-Ethernet device driver
ge GEM Gigabit-Ethernet device driver
hme SUNW,hme Fast-Ethernet device driver
idn inter-domain network device driver
le Am7990 (LANCE) Ethernet device driver
qfe SUNW,qfe Quad Fast-Ethernet device driver
scman SUNW,scman Sun Fire 15K management network device driver

i386pc >>>>>>>>>>>>>>>>>>>>>>>>>>

sk98sol SysKonnect Gigabit Ethernet SK-98xx device driver
spwr SMC EtherPower II 10/100 (9432) Ethernet device driver
dnet Ethernet driver for DEC 21040, 21041, 21140 Ethernet cards
e1000g Intel Gigabit, 82542, 82543, 82544, 82540 based NICs
elx 3COM EtherLink III Ethernet device driver
elxl 3Com Ethernet device driver
ieef Intel Ethernet device driver
iprb Intel 82557, 82558, 82559 controlled NICs
pcn AMD PCnet Ethernet controller device driver


29>프로세스 FULL 정보 보기

ps -ef | grep <process name>
은 80자로 프로세서 정보만 볼수 있다

프로세서 모든 정보를 보기 위해 다음과 같이 사용한다.
/usr/ucb/ps -auxww | grep <process name>
Gives the full listing of the process (long listing)


30>프로세스 FULL리스트 보기


/usr/ucb/ps –auxww | more


31>  솔라리스 로그정보 파일 위치

/var/adm/message~

/var/adm/utmpx

/var/adm/wtmpx

/var/log/syslog

/var/adm/sulog


31>mtu 설정하기

# ifconfig hme0 129.46.66.2 netmask 255.255.255.0 mtu 256


32>hostname바꾸기

A.       /etc/hosts

2. /etc/nodename

3. /etc/hostname.xx0 ---> ethernet card의 종류에 따라
네임이 틀립니다.
예) hostname.le0
hostname.hme0
hostname.eri0

4. /etc/net/ticlts/hosts

5. /etc/net/ticots/hosts

6. /etc/net/ticotsord/hosts


33>솔라리스 X86 serial(com1)으로 콘솔 사용후 다시 모니터와 키보드로 바꾸려면


eeprom input-device=ttya
eeprom output-device=ttya
eeprom ttya-mode=9600,8,N,1,-

ttya는 COM1 이고 ttyb는 COM2 입니다.

설정사항은

/boot/solaris/bootenv.rc에서 확인할수 있습니다.


다시 원래대로 바꾸려면


eeprom input-device=keyboard

eeprom output-device=screen


34>cron 사용하기

1. cron 명령은 지정된 날짜와 시간에 일정 작업을 주기적으로 수행하기 위해 사용되며 각 사용자별 로 /var/spool/cron/crontabs 디렉토리에 사용자 ID와 같은 이름의 crontab 화일을 만들어 cron job을 지정할 수 있다.

cron 명령은 시스템이 부팅되면서 /etc/rc2.d/S75cron 스크립트에 의해서 daemon 형태로 수행된다.

2. 각 사용자 별로 crontab 화일을 만드는 방법은 아래와 같이 "crontab -e" 명령을 실행하면 된다.

% crontab -e

위 와 같이 명령을 실행하면 "vi" editor mode로 들어가 crontab 화일을 수정할수 있게 되는데, 만약 "vi" mode로 들어가지 않으면 "EDITOR" 환경변수를 vi로 변경 후 crontab 명령을 다시 수행한다.

2.1 csh을 사용하는 경우

% setenv EDITOR vi
% crontab -e

2.2 sh이나 ksh을 사용하는 경우

$ EDITOR=vi
$ export EDITOR
$ crontab -e

3. crontab 화일의 내용을 정의 하는 format은 아래와 같다.

분 시 일 월 요일 실행할 명령

분 : 0-59
시 : 0-23
일 : 1-31
월 : 1-12
요일 : 0-6( 0: 일요일)

예) 매주 일요일 오전 3:15에 /var 디렉토리에 있는 core 화일을 지우는 작업

15 3 * * 0 find /var -name core 2>/dev/null | xargs rm -f

매월 1일 오후 6시에 시스템 down message 보내기

0 18 1 * * wall "System Will be down"

4. /etc/cron.d/cron.allow 화일이나 /etc/cron.d/cron.deny 화일을 이용하여 시스템 관리자는 각 사용자별로 crontab 화일에 대한 access 권한을 제한 할 수 있다.

4.1 crontab을 access 할 수 있는 사용자

- /etc/cron.d/cron.allow 화일이 존재하는 경우, 그 화일 안에 지정된 사용자

- /etc/cron.d/cron.allow 화일이 없는 경우, /etc/cron.d/cron.deny 화일안에 지정되지 않은 사용자

4.2 crontab을 access 할 수 없는 사용자

- /etc/cron.d/cron.allow 화일이 존재하는 경우, 그 화일 않에 지정되지 않은 사용자

- /etc/cron.d/cron.allow 화일이 없는 경우, /etc/cron.d/cron.deny 화일에 지정된 사용자

- /etc/cron.d/cron.allow와 /etc/cron.d/cron.deny 화일이 모두 없는 경우,
root를 제외한 모든 사용자

4.3 OS가 설치되면 기본적으로 /etc/cron.d/cron.deny이 생성되고 그 안에 아래의 사용자들이 지정된다.

daemon
bin
smtp
nuucp
listen
nobody
noaccess

/etc/cron.d/cron.allow와 /etc/cron.d/cron.deny 화일에 사용자를 지정할 때는 위와 같이 한줄에 한명씩 사용자를 지정한다.

5. cron에 관련된 환경은 /etc/default/cron 화일에 정의 할 수 있다.

% cat /etc/default/cron

CRONLOG=YES
PATH=/usr/bin:/usr/ucb:


SUNOS-SPARC


1> 인터페이스 속도 조절 방법


/etc/system 파일에서 변경법

set dev/

set hme:hme_adv_autoneg_cap=0

set hme:hme_adv_100T4_cap=0

set hme:hme_adv_100fdx_cap=1
set hme:hme_adv_100hdx_cap=0

set hme:hme_adv_10fdx_cap=0

set hme:hme_adv_10hdx_cap=0


명령어로 바꾸는 방법


ndd –set /dev/hme instance 1

ndd -set /dev/hme adv_autoneg_cap 0

ndd -set /dev/hme adv_100T4_cap 0
ndd -set /dev/hme adv_100fdx_cap 1
ndd -set /dev/hme adv_100hdx_cap 0
ndd -set /dev/hme adv_10fdx_cap 0

ndd -set /dev/hme adv_10hdx_cap 0






SUNOS-X86


1> 인터페이스 속도 조절 방법

/kernel/drv/iprb.conf


모든인터페이스 속도 동일 지정

full-duplex=1;

speed=100;


각각의 인터페이스 선택하여 속도 지정

ForceSpeedDuplex=5,4,3;

출처 : 주의 장막이 어찌 그리 사랑스러운지요
글쓴이 : 민 원글보기
메모 :