도전자허리케인
접속 : 5557   Lv. 62

Category

Profile

Counter

  • 오늘 : 25 명
  • 전체 : 39284 명
  • Mypi Ver. 0.3.1 β
[기본] Solaris Essential 과정 정리 (0) 2013/08/22 PM 09:40
Solaris Essential 과정 정리

1. 운영체제 기본 정보 확인 명령어

uname CMD
# uname -a
# cat /etc/release
[참고] 운영체제 버젼별 정보 확인
서버/스토리지별 정보 확인

date CMD
# rdate time.bora.net
# date +%m%d

cal CMD

2. 디렉토리 이동 관련 명령어

pwd CMD
PS1 변수
cd CMD
경로(PATH)
- 상대경로(Relative PATH) # cd dir1
- 절대경로(Absolute PATH) # cd /dir1

# cd -
# cd ../dir1

3. 파일 종류

일반 파일
디렉토리 파일
링크 파일
하드 링크 파일 (# ln file1 file2)
심볼릭 링크 파일 (ln -s file1 file2)
디바이스 파일
블럭 디바이스 파일
캐릭터 디바이스 파일

4. 매뉴얼 검색 & 패스워드 변경 명령어

man CMD
# man ls
# man -k calendar
# man -l passwd
# man -s 1B ls

# man find | col -b > find.txt

passwd CMD
# passwd [user01]
[참고] 패스워드 변경 규칙

5. 디렉토리 관리 명령어

ls CMD
# ls -l dir1
# ls -ld dir1
OPTIONS: -a, -l, -d, -F, -R, -i, -t, -r

# ls -altr (가장 밑에 있는게 가장 최근파일)
# ls -altr /var/adm
# ls -altr /tmp
# ls -altr /var/sadm/path
# ls -altr /var/sadm/pkg
mkdir CMD
# mkdir -p dir1/dir2/dir3
rmdir CMD
# rm -r dir1 (-r : 하위파일도 전부 지움)

6. 파일 관리 명령어

touch CMD
# touch -t 08301300 file1
cp CMD
# cp file1 file2
# cp file1 dir1
# cp -r dir1 dir2
OPTIONS : -i, -r, -p(속성 정보까지 그대로 카피)
mv CMD
# mv file1 file2
# mv file1 dir1
# mv dir1 dir2
OPTIONS : -i
rm CMD
# rm -rf dir1
# \rm -r dir1 (\ : rm을 해석(alias 한거)하지말고 rm 그 자체로 봐라)

7. 파일 내용 확인 명령어

cat CMD
# cat -n /etc/passwd
# cat file1 file2 > file3
[참고] strings CMD (스트링만 보여주는 명령어, 바이너리 형태 같은거 볼때)
more CMD
# CMD | more
# ps -ef | more
# cat /etc/services | more
# pkginfo | more
# patchadd -p | more
head CMD
alias 쓸때 =양쪽에 공백이 있으면 안된다
# alias pps='ps -ef | head -1 ; ps -ef | grep $1'
# pps java
# pps inetd
tail CMD
# tail -f /var/adm/messages
# tail -f /var/adm/sulog
[참고] # prstat -Z

8. 기타 관리용 명령어
wc CMD
Data Gathering
# cat /etc/passwd | wc -l
# ps -ef | wc -l
# pkginfo | wc -l
# patchadd -p | wc -l

#ps -ef | grep httpd | wc -l
# df -k / | tail -l | awk '{print $5}'
# ftpcount | grep realusers | awk '{print $5}'
[참고] MRTG, CATTI (수집한 데이터를 그래프로 그려주는 툴)
su CMD
# su user01
# su - user01
id CMD
groups CMD

last CMD
who CMD
w CMD (무한루프 돌릴때, 모니터링)
# while true
do
CMD
sleep 2
done

9. 사용자와 통신할 때 사용하는 명령어
mailx CMD
talk CMD
wall CMD

10. 파일 속성 정보 변경 명령어
chown CMD
# chown -R user01:staff dir1
chgrp CMD
chmod CMD
퍼미션 변경 방법
-심볼릭 모드(Symbolic Mode) # chmod u+x file1
-옥탈 모드 (Octal Mode) #chmod 755 file1
파일 & 디렉토리 퍼미션 의미
file ( r / w / x )
dir ( r / w / x )
umask CMD
(관리자) /etc/profile 앵간하면 바꾸지 않는다
(사용자) $HOME/.profile
특수퍼미션(SetUID/SetGID/Sticky Bits게시판처럼동작 내껀 나만 삭제 남껀 못 삭제)
의미
설정
관리

11. 자주 사용되지 않지만 유용한 명령어
cmp/diff CMD
# diff file1 file2
# dircmp dir1 dir2
sort CMD
# CMD | sort -k 3
# CMD | sort -k 3 -r

# df -h -F ufs
# du -sk /var
# cd var ; du -sk * | sort -nr | more

# sort -u file1
# sort file1 | uniq -u
# sort file1 | uniq -d
file CMD
# file *

12. 검색 관련 명령어
grep CMD
# grep OPTIONS PATTERN file1
OPTIONS : -n, -l, -i, -v, -w
PATTERN : * . ^root root$ [abc] [a-c] [^a]

# CMD | grep ineted
# cat /etc/passwd | grep root
# ps -ef | grep root
# pkginfo | grep Apache
# patchadd -p | grep 142205
# svcs -a | grep telnet

[ 참고] egrep / fgrep CMD
# egrep - i '(warn|err|crit|alert)' /var/adm/messages
find CMD
# find / -name core -type f
# find / -user user01 -group class1
# find / -mtime [-7|7|+7]
# find / -perm [-755|755]
# find / -size [-300c|300c|+300c]
# find / -name core -type f -exec rm {} \; ( / : 전체란 말씀)

# find /Log -name "*.log" -type f -mtime +30 -exec rm -f {} \;
# find /Log -mtime -2 -size +1024000000c
# find /source -type f -exec grep -l "Server Error" {} \;

13. 압축과 아카이빙
압축 (Compress)
compress/uncompress CMD
# compress file1 (압축)
# uncompress -c file1.Z (확인)
# uncompress file1.Z (해제)
gzip/gunzip CMD
# gzip file1
# gunzip -c file1.gz
# gunzip file1.gz
bzip/bunzip2 CMD
# bzip2 file1
# bunzip2 -c file1.bz2
# bunzip2 file1.bz2
아카이빙(Archiving)
tar CMD
# tar cvf file.tar file1 file2 file3
# tar tvf file.tar
# tar xvf file.tar

[참고] /was1/* -> /was2
# cd /was1
# tar cvf - . | (cd /was2 ; tar xvf -)

[참고] gtar --exclude
# /usr/sfw/bin/gtar cvzf /backup/all.tar.gz \
--exclude=/test/dir1 \
--absolute-name /test
cpio CMD
# find . | cpio -ocv > file.cpio
# cpio -itv < file.cpio
# cpio -idv < file.cpio
압축 + 아카이빙
zip CMD
# zip file.zip file1 file2 file3
# unzip -l file.zip
# unzip file.zip
jar CMD
# jar cvf file.jar file1 file2 file3
# jar tvf file.jar
# jar xvf file.jar

14. Visual Editor
$HOME/.exrc (vi편집기의 환경설정 파일)
$Home/.vimrc (vim편집기의 환경설정 파일)

15. 콘쉘의 특징
리다이렉션 (Redirection)
---------------------
fd
---------------------
0 stdin
1 stdout
2 stderr
---------------------
redirection stdin
redirection stdout
redirection stderr

# mailx -s "OK: solarisXXX" root@example.com < report.txt
# ./s!crip.sh > file.log 2>&1
# ./configure --perfix=usr/local/appache2 > apache.log 2>&1
$ find / -name core -type f 2>/dev/null
# pkgchk -v SUNWman > SUNWman.log 2>&1
파이프(Pipe)
# CMD | more
# CMD | grep inetd

[참고] tee CMD
# while true
do
CMD | tee -a file.log
sleep 2
done
# s!crip -a file.log | tee /dev/pts/5 | tee /dev/pts/6
콘쉘기능(ksh function)
# set -o (확인)
# set -o vi (온)
# set +o vi (오프)

# set -o noclobber
# set -o vi /* (ㄱ) Command Line Editor (ㄴ) Filename Completion */
# set -o ignoreeof
변수(Variable)
변수의 종류
- 지역변수(Local Variable ) # VAR=5
- 환경변수(Environment Variable) # export VAR=5
- 특수변수(Special Variable) $$ $? $! $0 $1 $2
변수 선언하는 방법
# VAR=5 ; export VAR
# echo $VAR
# unset VAR
export 의미?
시스템/쉘 환경변수
EDITOR/VISUAL(set/env)
PS1/PS2
PATH/MANPATH/LD_LIBRARY_PATH
HOME/PWD/LOGNAME/TERM/SHELL
DISPLAY
메타 문자(Metacharacter)
'', "", ``, \, ;
히스토리(History)
ksh ) $HOME/.sh_history (HISTSIZE, HISTFILE)
bash ) $HOME/bash.history (HISTSIZE, HISTFILE, HISTFILESIZE)
엘리어스(Alias)
# alias cp='cp -i'
# alias
# unalias cp
환경파일(Environment Files)
/etc/profile
$HOME/.profile
$HOME/.kshrc

쉘별 환경 파일
sh ) /etc/profile, ~/.profile
ksh ) /etc/profile, ~/.profile, ~/.kshrc
bash) /etc/profile, ~/.bash_profile, ~/.bahsrc
csh ) /etc/.login, ~/.cshrc, ~/.profile

관리자가 일반 사용자의 환경을 미리 초기화 하기 위해서
(주) /etc/profile
(부) /etc/skel
편리한 기능 설정
쉘변경(ksh -> bash)
HISTTIMEFORMAT 변수(/etc/profile)
언어변경(ko -> C)
coreutil(ls CMD/date CMD/tail CMD)

16. 프로세스 관리
프로세스 정보
/proc/PID(pCMD(ps, pfiles, pstack, ptree, pmap, pargs))
PID, PPID, UID/EUID, Control Terminal
프로세스 관리
프로세스 실행
fg) # ls
bg) # ls &
프로세스 확인
# ps -ef | grep inetd ( # /usr/ucb/ps aux | grep inetd)

[참고] Zombie process
# ps -elf | awk '$2=="Z" {print $0}'
프로세스 종료
# kill [-1|-2|-9|-15] PID PID

[참고] pgrep CMD / pkill CMD

잡 관리
잡 실행
fg ) # ls
bg ) # ls &
잡 확인
# jobs
잡 종료
# kill %1

[참고 ] 프로세스 모니터링
# tail -f /var/adm/messages
# prstat -Z (# top)

[참고] www.junsoft.com(parm)

17. 원격접속 & 파일전송
System V
telnet CMD
[참고] 원격접속시 에러메세지
ftp CMD
# ftp 172.16.9.XXX
root 사용자로 로그인
(ㄱ) 업로드/다운로드 포인터 맞추기(cd/lcd)
(ㄴ) 편리한 기능(bin/hash/prompt)
(ㄷ) 업로드/다운로드(mput/mget)
(ㄹ) 확인/해제(ls/quit)

[참고] FTP 관련 파일들
/etc/ftpd/ftpusers
/etc/shells

[참고] auto_ftp.sh/telnet.sh
[참고] FTP 서비스 접근 제어
[참고] Passive Mode/Active Mode
BSD
미리 인증하는 파일들
/etc/host.equiv
$HOME/.rhosts
rlogin CMD
rsh CMD
rpc CMD
Secure
ssh CMD
scp CMD
sftp CMD
[참고] ssh-keygen -t rsa/dsa

18. ACL (Acess Control List)
getfacl CMD
setfacl CMD

신고

 
X