블로그 이미지
22Hz 22Hz

카테고리

분류 전체보기 (109)
모의해킹 침해대응 전문가 과정 (99)
리눅스 설정 (10)
Total
Today
Yesterday

달력

« » 2024.11
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30

공지사항

태그목록

최근에 올라온 글

=================================메모=================================

# yum -y install gcc //gcc 설치
열심히 따라할것
먼저하다가 사고치지말것
꼭 외우라는건 반드시 외울것



echo "|---> ~/.bashrc read"

# .bashrc

# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi

#
# Specific Configuration
#
export PS1='[\u@\h \w]\$ '
alias ls='ls --color=tty -h'
alias pps='ps -ef | head -1 ; ps -ef | grep $1'
alias vi='/usr/bin/vim'
alias grep='grep -i --color'
alias a='cd /test && rm -rf /test/*'
alias b='cp /etc/passwd file1 ; cp file1 file2 ; cp file1 file3'
alias c='clear'

. ~/.bashrc

=================================복습=================================

쉘의 특성
 파이프
  # CMD | more
  # CMD | grep xinetd
 쉘 자체의 기능
  # set -o
  # set -o vi
  # set +o vi
 변수(Variable)
  변수의 종류
  -지역변수
  -환경변수
  -특수변수 : $$, $?, $!, $*, $#, $1, $2, $3, ...
  변수 선언 방법
  export 의미
  시스템 환경변수 set, env
   PS1, PS2
   PATH
   HISTIMEFORMAT
   HOME, PWD, LOGNAME, TERM, LANG, USER, UID
 쉘 메타캐릭터
 히스토리
 앨리어스
 환경파일

프로세스 관리
 프로세스 정보
 프로세스 관리1

=================================강의=================================

프로세스 관리
 프로세스 정보
 프로세스 관리1
  프로세스 실행
   fg) # gedit
   bg) # gedit &
  프로세스 확인
   # ps -ef | grep xinetd
   # ps aux | grep xinetd
  프로세스 종료
   # kill -[1|2|9|15] PID
   [참고] killall CMD //리눅스 전용
   [참고] pgrep/pkill CMD  
 잡 관리
  잡 실행
   fg) # gedit
   bg) # gedit &
  잡 확인
   # jobs
  잡 종료
   # kill %1 //Job ID를 지정할 수 있다
 프로세스 모니터링(in 프로세스 확인)
  top CMD
  (TUI) # top   (GUI) # gnome-system-monitor
  (TUI) # tail -f file.log (GUI) # gnome-system-

  [참고] top/ntop/iotop //network, disk i/o 모니터링 가능한 툴
 프로세스 관리 기타 명령어(in 프로세스 확인)
  lsof CMD
   # lsof  (# lsof | grep /tmp)
   # lsof -i
   # lsof -p PID
   # lsof -c sshd (# lsof | grep '^sshd')
  pmap CMD
   # pmap PID
  pstree CMD
  pwdx CMD
  nice/renice CMD
   # nice  -(-20 ~ 19) CMD
   # renice (-20 ~ 20) PID

   # nice -10 /root/bin/backup.sh &
   # renice 10 PID

원격접속과 파일전송 명령어
 파일 전송
  scp CMD
   # scp file1 172.16.9.252:/tmp
   # scp 172.16.9.252:/tmp/file1 /test
   # scp -r 172.16.9.252:/tmp/* /test
  sftp CMD
 원격 접속
  ssh CMD
   # ssh 172.16.9.252
   # ssh 172.16.9.252 CMD

=================================실습=================================

(2) 프로세스 정보 확인

[명령어 형식]
# ps    /* 현재 터미널에서 실행된 프로세스의 간략한 정보 확인 */
# ps -l   /* 현재 터미널에서 실행된 프로세스의 자세한 정보 확인 */
# ps -a   /* 사용자 프로세스에 대한 간략한 정보 확인 */
# ps -U <사용자명>  (# ps -U user01, # ps -U user01,user02,user03)
   /* 특정한 사용자가 실행시킨 프로세스의 간략한 정보 확인 */
# ps -t pts/5   /* 특정한 터미널에서 실행시킨 프로세스의 간략한 정보 확인 */

# ps aux | grep xinetd (# ps -ef | grep xinetd)
# ps -aux | grep xinetd


[EX] ps 명령어 실습

# ps /* 자신을 포함하여 자신이 실행한 프로세스를 확인 */
[root@linux220 ~]# ps
  PID TTY          TIME CMD
 4671 pts/1    00:00:00 bash
 4716 pts/1    00:00:00 ps

# ps -U root /* root 사용자가 사용하는 프로세스 정보를 보여줌 */
# ps /* 현재 터미널에서 실행된 프로세스의 간략한 정보 확인 */
# ps -t pts/3 /* 터미널창 번호를 확인 후에 해당 터미널의 프로세스 정보를 확인 */

# ps a /* 다른 사용자의 프로세스 상태도 표시 */
[root@linux220 ~]# ps a
  PID TTY      STAT   TIME COMMAND
 4249 tty1     Ss+    0:00 /sbin/mingetty tty1
 4250 tty2     Ss+    0:00 /sbin/mingetty tty2
 4251 tty3     Ss+    0:00 /sbin/mingetty tty3
 4261 tty4     Ss+    0:00 /sbin/mingetty tty4
 4271 tty5     Ss+    0:00 /sbin/mingetty tty5
 4273 tty6     Ss+    0:00 /sbin/mingetty tty6
 4355 tty7     Ss+    0:00 /usr/bin/Xorg :0 -br -audit 0 -auth /var/gdm/:0.Xauth -nolisten tcp vt7
 4671 pts/1    Ss     0:00 bash
 4720 pts/1    R+     0:00 ps a

# ps -ef | less /* 모든 프로세스 리스트를 출력하면서 모든 정보를 함께 출력 함 */
# ps aux | less  /* a : 다른 사용자의 프로세스 상태도 표시
      x : 화면에 보이지 않는 프로세스까지 모두 표시
      u : 프로세스를 사용한 사용자와 실행 시간까지 표시 */

[참고] ps aux를 통해 명령어 출력시 나오는 헤더부분 설명
user는 프로세스 소유자의 이름, ( u 옵션 )
PID는 프로세스 식별자 번호
%CPU : 마지막 1분 동안 프로세스가 사용한 CPU 점유율 ( u 옵션 )
%MAN : 마지막 1분 동안 프로세스가 사용한 메모리의 점유율 ( u,v 옵션 )
       -u 옵션으로 사용자의 ID나 이름을 지정하여 지정한 사용자의 프로세스만을 살펴 볼수 있다.
VSZ : 가상 메모리에 적재된 프로세스의 kb단위 크기
START는 프로세스가 시작된 시간

STAT 필드의 상태
-D : 디스크 입출력 대기 상태로 interrupts를 걸 수 없는 상태
-R : 실행중
-S : 짧은 sleep 상태
-T : 정지 상태
-Z : 좀비 상태
-W : 상주한 페이지가 없는 프로세스
-< : 높은 우선권 프로세스
-N : 낮은 우선권 프로세스
-L : 페이지가 락이 걸린 상태



프로세스를 죽이는 명령 - kill

(명령어 형식)
# kill PID (# kill -15 PID, # kill -TERM PID)
# kill PID PID PID
# kill -9 PID (# kill -KILL PID)
# kill -2 PID (# kill –INT PID)

[참고] 일반적으로 많이 쓰이는 시그널(Signal)
시그널 번호  시그널  이름  설 명
1   SIGHUP   프로세스 재시작(HangUp)  (EX: # kill -1 450)
2   SIGINT   인터럽트(Interrupt, <Ctrl + C>) (EX: # kill –2 450)
9   SIGKILL  강제 종료(force exit signal)  (EX: # kill -9 450)
15   SIGTERM  정상 종료(exit), 기본 시그널  (EX: # kill -15 450)
kill 명령에 아무 신호도 입력하지 않으면 15번 신호인 SIGTERM을 보낸다. (기본값)

[root@linux220 ~]# kill -l
 1) SIGHUP       2) SIGINT       3) SIGQUIT      4) SIGILL
 5) SIGTRAP      6) SIGABRT      7) SIGBUS       8) SIGFPE
 9) SIGKILL     10) SIGUSR1     11) SIGSEGV     12) SIGUSR2
13) SIGPIPE     14) SIGALRM     15) SIGTERM     16) SIGSTKFLT
17) SIGCHLD     18) SIGCONT     19) SIGSTOP     20) SIGTSTP
21) SIGTTIN     22) SIGTTOU     23) SIGURG      24) SIGXCPU
25) SIGXFSZ     26) SIGVTALRM   27) SIGPROF     28) SIGWINCH
29) SIGIO       30) SIGPWR      31) SIGSYS      34) SIGRTMIN
35) SIGRTMIN+1  36) SIGRTMIN+2  37) SIGRTMIN+3  38) SIGRTMIN+4
39) SIGRTMIN+5  40) SIGRTMIN+6  41) SIGRTMIN+7  42) SIGRTMIN+8
43) SIGRTMIN+9  44) SIGRTMIN+10 45) SIGRTMIN+11 46) SIGRTMIN+12
47) SIGRTMIN+13 48) SIGRTMIN+14 49) SIGRTMIN+15 50) SIGRTMAX-14
51) SIGRTMAX-13 52) SIGRTMAX-12 53) SIGRTMAX-11 54) SIGRTMAX-10
55) SIGRTMAX-9  56) SIGRTMAX-8  57) SIGRTMAX-7  58) SIGRTMAX-6
59) SIGRTMAX-5  60) SIGRTMAX-4  61) SIGRTMAX-3  62) SIGRTMAX-2
63) SIGRTMAX-1  64) SIGRTMAX

실무에 나가면 3번(SIGQUIT), 8번(SIGFPE) 시그널도 쓰인다고 한다



[EX] kill 명령어 실습

[root@linux220 ~]# ps -ef | grep sendmail
root      4086     1  0 16:01 ?        00:00:00 sendmail: accepting connections
smmsp     4094     1  0 16:01 ?        00:00:00 sendmail: Queue runner@01:00:00 for /var/spool/clientmqueue
root      4784  4671  0 16:37 pts/1    00:00:00 grep -i --color sendmail
[root@linux220 ~]# kill 4086
[root@linux220 ~]# ps -ef | grep sendmail
smmsp     4094     1  0 16:01 ?        00:00:00 sendmail: Queue runner@01:00:00 for /var/spool/clientmqueue
root      4787  4671  0 16:38 pts/1    00:00:00 grep -i --color sendmail

[root@linux220 ~]# service sendmail restart
sm-client을 종료 중:                                       [  OK  ]
sendmail를 종료 중:                                        [실패]
sendmail (을)를 시작 중:                                   [  OK  ]
sm-client를 시작 중:                                       [  OK  ]
[root@linux220 ~]# ps -ef | grep sendmail
root      4818     1  0 16:38 ?        00:00:00 sendmail: accepting connections
smmsp     4826     1  0 16:38 ?        00:00:00 sendmail: Queue runner@01:00:00 for /var/spool/clientmqueue
root      4830  4671  0 16:38 pts/1    00:00:00 grep -i --color sendmail
[root@linux220 ~]# kill -9 4826
[root@linux220 ~]# ps -ef | grep sendmail
root      4818     1  0 16:38 ?        00:00:00 sendmail: accepting connections
root      4833  4671  0 16:38 pts/1    00:00:00 grep -i --color sendmail

[root@linux220 ~]# service sendmail restart
sm-client을 종료 중:                                       [실패]
sendmail를 종료 중:                                        [  OK  ]
sendmail (을)를 시작 중:                                   [  OK  ]
sm-client를 시작 중:                                       [  OK  ]
[root@linux220 ~]# ps -ef | grep sendmail
root      4864     1  0 16:40 ?        00:00:00 sendmail: accepting connections
smmsp     4872     1  0 16:40 ?        00:00:00 sendmail: Queue runner@01:00:00 for /var/spool/clientmqueue
root      4876  4671  0 16:40 pts/1    00:00:00 grep -i --color sendmail
[root@linux220 ~]# kill -1 4872
[root@linux220 ~]# ps -ef | grep sendmail
root      4864     1  0 16:40 ?        00:00:00 sendmail: accepting connections
smmsp     4878     1  0 16:40 ?        00:00:00 sendmail: Queue runner@01:00:00 for /var/spool/clientmqueue
root      4881  4671  0 16:40 pts/1    00:00:00 grep -i --color sendmail

[root@linux220 ~]# service httpd restart
httpd 를 정지 중:                                          [실패]
httpd (을)를 시작 중:                                      [  OK  ]
[root@linux220 ~]# ps -ef | grep httpd
root      4899     1  0 16:41 ?        00:00:00 /usr/sbin/httpd
apache    4901  4899  0 16:41 ?        00:00:00 /usr/sbin/httpd
apache    4902  4899  0 16:41 ?        00:00:00 /usr/sbin/httpd
apache    4903  4899  0 16:41 ?        00:00:00 /usr/sbin/httpd
apache    4904  4899  0 16:41 ?        00:00:00 /usr/sbin/httpd
apache    4905  4899  0 16:41 ?        00:00:00 /usr/sbin/httpd
apache    4906  4899  0 16:41 ?        00:00:00 /usr/sbin/httpd
apache    4907  4899  0 16:41 ?        00:00:00 /usr/sbin/httpd
apache    4908  4899  0 16:41 ?        00:00:00 /usr/sbin/httpd
root      4910  4671  0 16:41 pts/1    00:00:00 grep -i --color httpd
[root@linux220 ~]# kill -15 4899 4901 4902 4903 4904 ...
[root@linux220 ~]# killall httpd
[root@linux220 ~]# kill `ps -ef | grep httpd | grep -v grep | awk '{print $2}'`

[root@linux220 ~]# ps -ef | grep httpd | grep -v grep
root      4899     1  0 16:41 ?        00:00:00 /usr/sbin/httpd
apache    4901  4899  0 16:41 ?        00:00:00 /usr/sbin/httpd
apache    4902  4899  0 16:41 ?        00:00:00 /usr/sbin/httpd
apache    4903  4899  0 16:41 ?        00:00:00 /usr/sbin/httpd
apache    4904  4899  0 16:41 ?        00:00:00 /usr/sbin/httpd
apache    4905  4899  0 16:41 ?        00:00:00 /usr/sbin/httpd
apache    4906  4899  0 16:41 ?        00:00:00 /usr/sbin/httpd
apache    4907  4899  0 16:41 ?        00:00:00 /usr/sbin/httpd
apache    4908  4899  0 16:41 ?        00:00:00 /usr/sbin/httpd
[root@linux220 ~]# ps -ef | grep httpd | grep -v grep | awk '{print $2}'
4899
4901
4902
4903
4904
4905
4906
4907
4908



프로세스 모니터링

(1) top 명령 (ps와 같은 명령어 - 차이점? top은 실시간 모니터링)

[참고] 서버에 접속하여 시스템 모니터링

[TERM1] (TUI) # top (GUI) # gnome-system-monitor
[TERM2] (TUI) # tail -f /var/log/messages (GUI) # gnome-system-log

실시간으로 프로세스의 상태나 CPU, 메모리, 접속한 사용자의 수 등을 알 수 있게 된다.
시스템의 성능을 확인하려 할 때 많이 사용하게 된다.

그림1

기본설정
명령어 수행 시간 간격(time interval)은 3 ~ 4초
CPU 사용량별로 정열(Sorting)

(명령어 형식)
# top
# top -u oracle /* 해당 사용자의 프로세스 정보를 실시간 모니터링 */
# top -p PID1,PID2,PID3 /* 해당 번호의 프로세스 정보를 실시간 모니터링 */


[EX1] top 명령어 기본 사용방법 실습
# top -h (# top --help)

# top

그림2

(첫 번째 줄) 시스템의 현재 시간과 시스템이 부팅된 후 작동한 시간, 현재 사용자 수를 보여주며,
             loadaverage는 CPU 로드의 평균 값을 보여준다.
(두 번째 줄) 시스템에 동작중인 프로세스의 상태를 보여준다.
(세 번째 줄) CPU의 상태를 보여준다
(네 번째 / 다섯 번째 줄)
             총 사용 가능 메모리, 사용된 메모리, 사용할 수 있는 메모리,
             공유 메모리, 버퍼로 사용된 메모리, 스왑 메모리등 메모리에 관한 정보를 보여준다.
             각각의 시스템 자원에 따른 프로세스의 점유율을 확인 할 수 있다.

기본적으로 cpu 사용량으로 sort 되어 있음

h help

Help for Interactive Commands - procps version 3.2.7
Window 1:Def: Cumulative mode Off.  System: Delay 3.0 secs; Secure mode Off.

  Z,B       Global: 'Z' change color mappings; 'B' disable/enable bold
  l,t,m     Toggle Summaries: 'l' load avg; 't' task/cpu stats; 'm' mem info
  1,I       Toggle SMP view: '1' single/separate states; 'I' Irix/Solaris mode

  f,o     . Fields/Columns: 'f' add or remove; 'o' change display order
  F or O  . Select sort field
  <,>     . Move sort field: '<' next col left; '>' next col right
  R,H     . Toggle: 'R' normal/reverse sort; 'H' show threads
  c,i,S   . Toggle: 'c' cmd name/line; 'i' idle tasks; 'S' cumulative time
  x,y     . Toggle highlights: 'x' sort field; 'y' running tasks
  z,b     . Toggle: 'z' color/mono; 'b' bold/reverse (only if 'x' or 'y')
  u       . Show specific user only
  n or #  . Set maximum tasks displayed

  k,r       Manipulate tasks: 'k' kill; 'r' renice
  d or s    Set update interval
  W         Write configuration file
  q         Quit
          ( commands shown with '.' require a visible task display window )
Press 'h' or '?' for help with Windows,
any other key to continue

F 눌러서 sorting 기준 변경 가능


[EX2] 사용자 별로 모니터링

(명령어 형식)
# top -u root
# top -u oracle
# top -u wasuser

[TERM1] root 사용자 윈도우
# top -u fedora

[TERM2] fedora 사용자 윈도우
# telnet localhost
fedora 사용자로 로그인
$ id
$ bash -----> 관리자 윈도우 확인
$ ksh -----> 관리자 윈도우 확인
$ vi /etc/passwd
$ exit
$ exit
$ exit

그림3


[EX3] 몇개의 프로세스만 모니터링

(명령어 형식)
# top -p 1
# top -p 1,PID


[EX4] 모니터링 툴 종류

# top - Display Linux tasks
# free - Display amount of free and used memory in the system
# /usr/bin/baobab - A graphical tool to analyse disk usage
# /usr/bin/xload - System load average display for X
# /usr/bin/gnome-system-monitor - System monitor
# /usr/bin/gnome-system-log - /var/logs/messages log viewer

[root@linux220 ~]# gnome-
gnome-about                              gnome-pilot-make-password
gnome-about-me                           gnome-power-inhibit-test
gnome-accessibility-keyboard-properties  gnome-power-manager
gnome-at-properties                      gnome-power-preferences
gnome-audio-profiles-properties          gnome-screensaver
gnome-background-properties              gnome-screensaver-command
gnome-calculator                         gnome-screensaver-preferences
gnome-cd                                 gnome-screenshot
gnome-character-map                      gnome-search-tool
gnome-control-center                     gnome-session
gnome-default-applications-properties    gnome-session-properties
gnome-default-printer                    gnome-session-remove
gnome-desktop-item-edit                  gnome-session-save
gnome-dictionary                         gnome-sound-properties
gnome-display-properties                 gnome-system-log
gnome-doc-prepare                        gnome-system-monitor
gnome-eject                              gnome-terminal
gnome-file-share-properties              gnome-text-editor
gnome-font-properties                    gnome-theme-manager
gnome-font-viewer                        gnome-theme-thumbnailer
gnome-help                               gnome-thumbnail-font
gnome-keybinding-properties              gnome-typing-monitor
gnome-keyboard-properties                gnome-ui-properties
gnome-keyring-daemon                     gnome-umount
gnome-mount                              gnome-volume-control
gnome-mouse-properties                   gnome-volume-manager
gnome-network-preferences                gnome-volume-properties
gnome-open                               gnome-window-properties
gnome-panel                              gnome-wm
gnome-panel-screenshot                  
[root@linux220 ~]# gnome-system-
gnome-system-log      gnome-system-monitor 



[EX5] 시스템 모니터링(CPU/MEM)

[root@linux220 ~]# mkdir -p /root/bin
[root@linux220 ~]# cd /root/bin
[root@linux220 ~/bin]# scp 172.16.9.252:/root/shell/* /root/bin
The authenticity of host '172.16.9.252 (172.16.9.252)' can't be established.
RSA key fingerprint is e2:f0:f8:a2:47:3b:b4:7c:ae:65:38:0e:31:bf:1f:84.
Are you sure you want to continue connecting (yes/no)? y
Please type 'yes' or 'no': yes
Warning: Permanently added '172.16.9.252' (RSA) to the list of known hosts.
root@172.16.9.252's password:
CoffeeTime.txt                                                               100%  840     0.8KB/s   00:00   
CoffeeTime2.txt                                                              100% 1423     1.4KB/s   00:00   
bomb.sh                                                                      100%   49     0.1KB/s   00:00   
bomb_exec.sh                                                                 100%  277     0.3KB/s   00:00   
cow.txt                                                                      100%  250     0.2KB/s   00:00   
cow2.txt                                                                     100%  256     0.3KB/s   00:00   
cow3.txt                                                                     100%  256     0.3KB/s   00:00   
cpu.sh                                                                       100%  261     0.3KB/s   00:00   
cpu2.sh                                                                      100%  194     0.2KB/s   00:00   
cpu3.sh                                                                      100%  303     0.3KB/s   00:00   
disk_exhaust.c                                                               100%  226     0.2KB/s   00:00   
dog.txt                                                                      100%  196     0.2KB/s   00:00   
dog2.txt                                                                     100%  232     0.2KB/s   00:00   
dog3.txt                                                                     100%  229     0.2KB/s   00:00   
mailling.sh                                                                  100%  888     0.9KB/s   00:00   
mem                                                                          100% 5141     5.0KB/s   00:00   
mem.c                                                                        100%  264     0.3KB/s   00:00   
network.sh                                                                   100%  338     0.3KB/s   00:00   
proc_count.sh                                                                100%   97     0.1KB/s   00:00   
telnet.sh                                                                    100%  330     0.3KB/s   00:00   



cpu.sh
그림4, 그림5

cpu2.sh
그림6, 그림7

cpu3.sh
그림8, 그림9

mem.c
그림10

disk_exhaust.c



(2) lsof(List Open File) 명령어

프로세스에 의해 열려진 파일들에 대한 정보를 볼 수 있다.
특정 파일을 접근하고 있는 프로세스인지 특정 포트로 접속한 사용자를 확인 할 때 유용한 프로세스이다.

[명령어 형식]
# lsof
# lsof -p <PID번호>
# lsof -c <데몬명>

[root@linux220 ~]# ps -ef | grep sendmail
root      4864     1  0 16:40 ?        00:00:00 sendmail: accepting connections
smmsp     4878     1  0 16:40 ?        00:00:00 sendmail: Queue runner@01:00:00 for /var/spool/clientmqueue
root      8620  8601  0 17:54 pts/1    00:00:00 grep -i --color sendmail
[root@linux220 ~]# lsof -p 4864
COMMAND   PID USER   FD   TYPE     DEVICE    SIZE    NODE NAME
sendmail 4864 root  cwd    DIR        8,1    4096 3434270 /var/spool/mqueue
sendmail 4864 root  rtd    DIR        8,1    4096       2 /
sendmail 4864 root  txt    REG        8,1  806460  275046 /usr/sbin/sendmail.sendmail
sendmail 4864 root  mem    REG        8,1         7457978 /lib/libcrypt-2.5.so (path inode=7456539)
sendmail 4864 root  mem    REG        8,1   99060  273686 /usr/lib/libsasl2.so.2.0.22
sendmail 4864 root  mem    REG        8,1   53756  275649 /usr/lib/liblber-2.3.so.0.2.31
sendmail 4864 root  mem    REG        8,1    7748 7457987 /lib/libcom_err.so.2.1
sendmail 4864 root  mem    REG        8,1  157304  273660 /usr/lib/libk5crypto.so.3.1
sendmail 4864 root  mem    REG        8,1         7457969 /lib/libdl-2.5.so (path inode=7456541)
sendmail 4864 root  mem    REG        8,1         7457970 /lib/libpthread-2.5.so (path inode=7456559)
sendmail 4864 root  mem    REG        8,1   93508 7457986 /lib/libselinux.so.1
sendmail 4864 root  mem    REG        8,1   16832  360815 /usr/lib/sasl2/libcrammd5.so.2.0.22
sendmail 4864 root  mem    REG        8,1   14372  360701 /usr/lib/sasl2/libanonymous.so.2.0.22
sendmail 4864 root  mem    REG        8,1   14848  360761 /usr/lib/sasl2/libplain.so.2.0.22
sendmail 4864 root  mem    REG        8,1 1011184 7457993 /lib/libdb-4.3.so
sendmail 4864 root  mem    REG        8,1  610836  273661 /usr/lib/libkrb5.so.3.3
sendmail 4864 root  mem    REG        8,1  245376 7457985 /lib/libsepol.so.1
sendmail 4864 root  mem    REG        8,1   47172  360819 /usr/lib/sasl2/libdigestmd5.so.2.0.22
sendmail 4864 root  mem    REG        8,1         7457954 /lib/ld-2.5.so (path inode=7456528)
sendmail 4864 root  mem    REG        8,1  190712  273662 /usr/lib/libgssapi_krb5.so.2.2
sendmail 4864 root  mem    REG        8,1  240584  270215 /usr/lib/libldap-2.3.so.0.2.31
sendmail 4864 root  mem    REG        8,1   32824 7456716 /lib/libwrap.so.0.7.6
sendmail 4864 root  mem    REG        8,1         7457968 /lib/libc-2.5.so (path inode=7456535)
sendmail 4864 root  mem    REG        8,1    7880 7457983 /lib/libkeyutils-1.2.so
sendmail 4864 root  mem    REG        8,1   14752  360757 /usr/lib/sasl2/liblogin.so.2.0.22
sendmail 4864 root  mem    REG        8,1   15496  278087 /usr/lib/libhesiod.so.0.0.0
sendmail 4864 root  mem    REG        8,1  905200  360823 /usr/lib/sasl2/libsasldb.so.2.0.22
sendmail 4864 root  mem    REG        8,1         7456552 /lib/libnss_files-2.5.so (path inode=7456551)
sendmail 4864 root  mem    REG        8,1  293108 7457989 /lib/libssl.so.0.9.8e
sendmail 4864 root  mem    REG        8,1         7457982 /lib/libnsl-2.5.so (path inode=7456545)
sendmail 4864 root  mem    REG        8,1   33680  273659 /usr/lib/libkrb5support.so.0.1
sendmail 4864 root  mem    REG        8,1         7457984 /lib/libresolv-2.5.so (path inode=7456561)
sendmail 4864 root  mem    REG        8,1   75028   65602 /usr/lib/libz.so.1.2.3
sendmail 4864 root  mem    REG        8,1 1296932 7457988 /lib/libcrypto.so.0.9.8e
sendmail 4864 root    0r   CHR        1,3            1646 /dev/null
sendmail 4864 root    1w   CHR        1,3            1646 /dev/null
sendmail 4864 root    2w   CHR        1,3            1646 /dev/null
sendmail 4864 root    3u  unix 0xf258ee40           18051 socket
sendmail 4864 root    4u  IPv4      18052             TCP localhost.localdomain:smtp (LISTEN)
sendmail 4864 root    5wW  REG        8,1      33 3435270 /var/run/sendmail.pid


[root@linux220 ~]# lsof -i //현재 사용하고 있는 모든 소켓 상태를 확인 가능
COMMAND    PID   USER   FD   TYPE DEVICE SIZE NODE NAME
portmap   3705    rpc    3u  IPv4   8708       UDP *:sunrpc
portmap   3705    rpc    4u  IPv4   8717       TCP *:sunrpc (LISTEN)
rpc.statd 3746   root    3u  IPv4   8837       UDP *:957
rpc.statd 3746   root    6u  IPv4   8820       UDP *:954
rpc.statd 3746   root    7u  IPv4   8892       TCP *:960 (LISTEN)
hpiod     3950   root    0u  IPv4  10927       TCP localhost.localdomain:2208 (LISTEN)
python    3955   root    4u  IPv4  10945       TCP localhost.localdomain:2207 (LISTEN)
cupsd     3977   root    4u  IPv4  11016       TCP localhost.localdomain:ipp (LISTEN)
cupsd     3977   root    6u  IPv4  11019       UDP *:ipp
xinetd    3991   root    5u  IPv4  11085       TCP *:telnet (LISTEN)
avahi-dae 4182  avahi   13u  IPv4  11504       UDP *:mdns
avahi-dae 4182  avahi   14u  IPv6  11505       UDP *:mdns
avahi-dae 4182  avahi   15u  IPv4  11506       UDP *:56077
avahi-dae 4182  avahi   16u  IPv6  11507       UDP *:55056
sendmail  4864   root    4u  IPv4  18052       TCP localhost.localdomain:smtp (LISTEN)
httpd     4899   root    4u  IPv6  18270       TCP *:http (LISTEN)
httpd     4899   root    6u  IPv6  18275       TCP *:https (LISTEN)
httpd     4901 apache    4u  IPv6  18270       TCP *:http (LISTEN)
httpd     4901 apache    6u  IPv6  18275       TCP *:https (LISTEN)
httpd     4902 apache    4u  IPv6  18270       TCP *:http (LISTEN)
httpd     4902 apache    6u  IPv6  18275       TCP *:https (LISTEN)
httpd     4903 apache    4u  IPv6  18270       TCP *:http (LISTEN)
httpd     4903 apache    6u  IPv6  18275       TCP *:https (LISTEN)
httpd     4904 apache    4u  IPv6  18270       TCP *:http (LISTEN)
httpd     4904 apache    6u  IPv6  18275       TCP *:https (LISTEN)
httpd     4905 apache    4u  IPv6  18270       TCP *:http (LISTEN)
httpd     4905 apache    6u  IPv6  18275       TCP *:https (LISTEN)
httpd     4906 apache    4u  IPv6  18270       TCP *:http (LISTEN)
httpd     4906 apache    6u  IPv6  18275       TCP *:https (LISTEN)
httpd     4907 apache    4u  IPv6  18270       TCP *:http (LISTEN)
httpd     4907 apache    6u  IPv6  18275       TCP *:https (LISTEN)
httpd     4908 apache    4u  IPv6  18270       TCP *:http (LISTEN)
httpd     4908 apache    6u  IPv6  18275       TCP *:https (LISTEN)
sshd      8529   root    3u  IPv6 164390       TCP *:ssh (LISTEN)


[root@linux220 ~]# ssh root@172.16.9.252
root@172.16.9.252's password:
Last login: Wed Apr 20 17:56:23 2016 from 172.16.6.204
[linux252@~]#  lsof -i@172.16.9.252
COMMAND   PID  USER   FD   TYPE  DEVICE SIZE/OFF NODE NAME
named    4146 named   21u  IPv4   10024      0t0  TCP linux252.example.com:domain (LISTEN)
named    4146 named  513u  IPv4   10023      0t0  UDP linux252.example.com:domain
ntpd     4632   ntp   23u  IPv4   13218      0t0  UDP linux252.example.com:ntp
nmbd    14773  root   16u  IPv4 1703377      0t0  UDP linux252.example.com:netbios-ns
nmbd    14773  root   17u  IPv4 1703378      0t0  UDP linux252.example.com:netbios-dgm
sshd    30673  root    3u  IPv4 2770886      0t0  TCP linux252.example.com:ssh->172.16.6.229:37478 (ESTABLISHED)
sshd    30708  root    3u  IPv4 2775559      0t0  TCP linux252.example.com:ssh->172.16.6.200:56786 (ESTABLISHED)
sshd    30712  root    3u  IPv4 2775584      0t0  TCP linux252.example.com:ssh->172.16.6.249:44787 (ESTABLISHED)
sshd    30738  root    3u  IPv4 2775657      0t0  TCP linux252.example.com:ssh->172.16.6.207:38941 (ESTABLISHED)
sshd    30740  root    3u  IPv4 2775682      0t0  TCP linux252.example.com:ssh->172.16.6.224:42207 (ESTABLISHED)
sshd    30742  root    3u  IPv4 2775711      0t0  TCP linux252.example.com:ssh->172.16.6.226:51533 (ESTABLISHED)
sshd    30794  root    3u  IPv4 2775895      0t0  TCP linux252.example.com:ssh->172.16.6.225:58355 (ESTABLISHED)
sshd    30820  root    3u  IPv4 2775970      0t0  TCP linux252.example.com:ssh->172.16.6.214:55465 (ESTABLISHED)
sshd    30822  root    3u  IPv4 2775990      0t0  TCP linux252.example.com:ssh->ns1.linux215.1.16.172.in-addr.arpa:37253 (ESTABLISHED)
sshd    30848  root    3u  IPv4 2776070      0t0  TCP linux252.example.com:ssh->172.16.6.220:52092 (ESTABLISHED)
sshd    30850  root    3u  IPv4 2776097      0t0  TCP linux252.example.com:ssh->172.16.6.205:52797 (ESTABLISHED)
sshd    30852  root    3u  IPv4 2776117      0t0  TCP linux252.example.com:ssh->172.16.6.210:49774 (ESTABLISHED)
sshd    30854  root    3u  IPv4 2776149      0t0  TCP linux252.example.com:ssh->172.16.6.208:48337 (ESTABLISHED)
sshd    30856  root    3u  IPv4 2776174      0t0  TCP linux252.example.com:ssh->172.16.6.217:49906 (ESTABLISHED)
sshd    30858  root    3u  IPv4 2776199      0t0  TCP linux252.example.com:ssh->172.16.6.216:55602 (ESTABLISHED)
sshd    30884  root    3u  IPv4 2776272      0t0  TCP linux252.example.com:ssh->172.16.6.209:39253 (ESTABLISHED)
sshd    30887  root    3u  IPv4 2776297      0t0  TCP linux252.example.com:ssh->172.16.6.218:41942 (ESTABLISHED)
sshd    30937  root    3u  IPv4 2776442      0t0  TCP linux252.example.com:ssh->172.16.6.204:47412 (ESTABLISHED)
sshd    30988  root    3u  IPv4 2776967      0t0  TCP linux252.example.com:ssh->172.16.6.203:59064 (ESTABLISHED)
sshd    31038  root    3u  IPv4 2777110      0t0  TCP linux252.example.com:ssh->172.16.6.222:48034 (ESTABLISHED)
sshd    31039  sshd    3u  IPv4 2777110      0t0  TCP linux252.example.com:ssh->172.16.6.222:48034 (ESTABLISHED)
sshd    31168  root    3u  IPv4 2778217      0t0  TCP linux252.example.com:ssh->172.16.6.223:60886 (ESTABLISHED)
sshd    31173  root    3u  IPv4 2778327      0t0  TCP linux252.example.com:ssh->172.16.6.213:46232 (ESTABLISHED)
sshd    31204  root    3u  IPv4 2778838      0t0  TCP linux252.example.com:ssh->172.16.6.202:55859 (ESTABLISHED)
sshd    31205  sshd    3u  IPv4 2778838      0t0  TCP linux252.example.com:ssh->172.16.6.202:55859 (ESTABLISHED)


[root@linux220 ~]# lsof -c sshd | more //특정 데몬이 사용하고 있는 모든 파일의 정보 출력
COMMAND  PID USER   FD   TYPE DEVICE    SIZE    NODE NAME
sshd    8529 root  cwd    DIR    8,1    4096       2 /
sshd    8529 root  rtd    DIR    8,1    4096       2 /
sshd    8529 root  txt    REG    8,1  408576 1340939 /usr/sbin/sshd
sshd    8529 root  mem    REG    8,1  190712  273662 /usr/lib/libgssapi_krb5.so.2.2
sshd    8529 root  mem    REG    8,1  610836  273661 /usr/lib/libkrb5.so.3.3
sshd    8529 root  mem    REG    8,1    7880 7457983 /lib/libkeyutils-1.2.so
sshd    8529 root  mem    REG    8,1   98532  273688 /usr/lib/libnssutil3.so
sshd    8529 root  mem    REG    8,1   15556  273685 /usr/lib/libplc4.so
sshd    8529 root  mem    REG    8,1  228028  273683 /usr/lib/libnspr4.so
sshd    8529 root  mem    REG    8,1  135928 7456559 /lib/libpthread-2.5.so
sshd    8529 root  mem    REG    8,1   50848 7456551 /lib/libnss_files-2.5.so
sshd    8529 root  mem    REG    8,1   11460  273684 /usr/lib/libplds4.so
sshd    8529 root  mem    REG    8,1   97220 7456701 /lib/libaudit.so.0.0.0
sshd    8529 root  mem    REG    8,1  107924 7456545 /lib/libnsl-2.5.so
sshd    8529 root  mem    REG    8,1   32824 7456716 /lib/libwrap.so.0.7.6
sshd    8529 root  mem    REG    8,1  245376 7457985 /lib/libsepol.so.1
sshd    8529 root  mem    REG    8,1   43616 7456539 /lib/libcrypt-2.5.so
sshd    8529 root  mem    REG    8,1   93508 7457986 /lib/libselinux.so.1
sshd    8529 root  mem    REG    8,1  129476 7456528 /lib/ld-2.5.so
sshd    8529 root  mem    REG    8,1 1188804  273689 /usr/lib/libnss3.so
sshd    8529 root  mem    REG    8,1   83048 7456561 /lib/libresolv-2.5.so
sshd    8529 root  mem    REG    8,1    6632  272841 /usr/lib/libfipscheck.so.1.1.0
sshd    8529 root  mem    REG    8,1    7748 7457987 /lib/libcom_err.so.2.1
sshd    8529 root  mem    REG    8,1 1702788 7456535 /lib/libc-2.5.so
sshd    8529 root  mem    REG    8,1  157304  273660 /usr/lib/libk5crypto.so.3.1
sshd    8529 root  mem    REG    8,1   18812 7456541 /lib/libdl-2.5.so
sshd    8529 root  mem    REG    8,1   13492 7456567 /lib/libutil-2.5.so
sshd    8529 root  mem    REG    8,1   33680  273659 /usr/lib/libkrb5support.so.0.1
sshd    8529 root  mem    REG    8,1 1296932 7457988 /lib/libcrypto.so.0.9.8e
sshd    8529 root  mem    REG    8,1   75028   65602 /usr/lib/libz.so.1.2.3
sshd    8529 root  mem    REG    8,1   44532 7457997 /lib/libpam.so.0.81.5
sshd    8529 root    0u   CHR    1,3            1646 /dev/null
sshd    8529 root    1u   CHR    1,3            1646 /dev/null
sshd    8529 root    2u   CHR    1,3            1646 /dev/null
sshd    8529 root    3u  IPv6 164390             TCP *:ssh (LISTEN)


[root@linux220 ~]# lsof | grep '^sshd'
sshd      8529      root  cwd       DIR        8,1     4096          2 /
sshd      8529      root  rtd       DIR        8,1     4096          2 /
sshd      8529      root  txt       REG        8,1   408576    1340939 /usr/sbin/sshd
sshd      8529      root  mem       REG        8,1   190712     273662 /usr/lib/libgssapi_krb5.so.2.2
sshd      8529      root  mem       REG        8,1   610836     273661 /usr/lib/libkrb5.so.3.3
sshd      8529      root  mem       REG        8,1     7880    7457983 /lib/libkeyutils-1.2.so
sshd      8529      root  mem       REG        8,1    98532     273688 /usr/lib/libnssutil3.so
sshd      8529      root  mem       REG        8,1    15556     273685 /usr/lib/libplc4.so
sshd      8529      root  mem       REG        8,1   228028     273683 /usr/lib/libnspr4.so
sshd      8529      root  mem       REG        8,1   135928    7456559 /lib/libpthread-2.5.so
sshd      8529      root  mem       REG        8,1    50848    7456551 /lib/libnss_files-2.5.so
sshd      8529      root  mem       REG        8,1    11460     273684 /usr/lib/libplds4.so
sshd      8529      root  mem       REG        8,1    97220    7456701 /lib/libaudit.so.0.0.0
sshd      8529      root  mem       REG        8,1   107924    7456545 /lib/libnsl-2.5.so
sshd      8529      root  mem       REG        8,1    32824    7456716 /lib/libwrap.so.0.7.6
sshd      8529      root  mem       REG        8,1   245376    7457985 /lib/libsepol.so.1
sshd      8529      root  mem       REG        8,1    43616    7456539 /lib/libcrypt-2.5.so
sshd      8529      root  mem       REG        8,1    93508    7457986 /lib/libselinux.so.1
sshd      8529      root  mem       REG        8,1   129476    7456528 /lib/ld-2.5.so
sshd      8529      root  mem       REG        8,1  1188804     273689 /usr/lib/libnss3.so
sshd      8529      root  mem       REG        8,1    83048    7456561 /lib/libresolv-2.5.so
sshd      8529      root  mem       REG        8,1     6632     272841 /usr/lib/libfipscheck.so.1.1.0
sshd      8529      root  mem       REG        8,1     7748    7457987 /lib/libcom_err.so.2.1
sshd      8529      root  mem       REG        8,1  1702788    7456535 /lib/libc-2.5.so
sshd      8529      root  mem       REG        8,1   157304     273660 /usr/lib/libk5crypto.so.3.1
sshd      8529      root  mem       REG        8,1    18812    7456541 /lib/libdl-2.5.so
sshd      8529      root  mem       REG        8,1    13492    7456567 /lib/libutil-2.5.so
sshd      8529      root  mem       REG        8,1    33680     273659 /usr/lib/libkrb5support.so.0.1
sshd      8529      root  mem       REG        8,1  1296932    7457988 /lib/libcrypto.so.0.9.8e
sshd      8529      root  mem       REG        8,1    75028      65602 /usr/lib/libz.so.1.2.3
sshd      8529      root  mem       REG        8,1    44532    7457997 /lib/libpam.so.0.81.5
sshd      8529      root    0u      CHR        1,3                1646 /dev/null
sshd      8529      root    1u      CHR        1,3                1646 /dev/null
sshd      8529      root    2u      CHR        1,3                1646 /dev/null
sshd      8529      root    3u     IPv6     164390                 TCP *:ssh (LISTEN)




pCMD(ps, pmap, pstree, pwdx, ....)
# pmap PID
# pstree PID
# pwdx PID

(3) pmap 명령어
프로세스가 사용하고 있는 메모리의 주소를 확인 할 수 있다.
응용프로그램이 실행될 때 얼마나 많은 라이브러리가 로드되는가를 확인 할 수 있다.

[명령어 형식]
# pmap PID


[root@linux220 ~]# ps -ef | grep sendmail
root      4864     1  0 16:40 ?        00:00:00 sendmail: accepting connections
smmsp     4878     1  0 16:40 ?        00:00:00 sendmail: Queue runner@01:00:00 for /var/spool/clientmqueue
root      8673  8601  0 18:01 pts/1    00:00:00 grep -i --color sendmail
[root@linux220 ~]# pmap 4864 //프로세스가 사용하고 있는 메모리의 주소를 확인
4864:   sendmail: accepting connections
00110000     36K r-x--  /lib/libcrypt-2.5.so
00119000      4K r-x--  /lib/libcrypt-2.5.so
0011a000      4K rwx--  /lib/libcrypt-2.5.so
0011b000    156K rwx--    [ anon ]
00142000     96K r-x--  /usr/lib/libsasl2.so.2.0.22
0015a000      4K rwx--  /usr/lib/libsasl2.so.2.0.22
0015b000     52K r-x--  /usr/lib/liblber-2.3.so.0.2.31
00168000      4K rwx--  /usr/lib/liblber-2.3.so.0.2.31
00169000      8K r-x--  /lib/libcom_err.so.2.1
0016b000      4K rwx--  /lib/libcom_err.so.2.1
0016c000    148K r-x--  /usr/lib/libk5crypto.so.3.1
00191000      4K rwx--  /usr/lib/libk5crypto.so.3.1
00192000      8K r-x--  /lib/libdl-2.5.so
00194000      4K r-x--  /lib/libdl-2.5.so
00195000      4K rwx--  /lib/libdl-2.5.so
00196000     80K r-x--  /lib/libpthread-2.5.so
001aa000      4K r-x--  /lib/libpthread-2.5.so
001ab000      4K rwx--  /lib/libpthread-2.5.so
001ac000      8K rwx--    [ anon ]
001ae000     88K r-x--  /lib/libselinux.so.1
001c4000      8K rwx--  /lib/libselinux.so.1
001c6000     16K r-x--  /usr/lib/sasl2/libcrammd5.so.2.0.22
001ca000      4K rwx--  /usr/lib/sasl2/libcrammd5.so.2.0.22
001cb000     16K r-x--  /usr/lib/sasl2/libanonymous.so.2.0.22
001cf000      4K rwx--  /usr/lib/sasl2/libanonymous.so.2.0.22
001d0000     16K r-x--  /usr/lib/sasl2/libplain.so.2.0.22
001d4000      4K rwx--  /usr/lib/sasl2/libplain.so.2.0.22
001dd000      4K r-x--    [ anon ]
001de000    980K r-x--  /lib/libdb-4.3.so
002d3000     12K rwx--  /lib/libdb-4.3.so
002d6000    588K r-x--  /usr/lib/libkrb5.so.3.3
00369000     12K rwx--  /usr/lib/libkrb5.so.3.3
0036c000    236K r-x--  /lib/libsepol.so.1
003a7000      4K rwx--  /lib/libsepol.so.1
003a8000     40K rwx--    [ anon ]
003b2000     44K r-x--  /usr/lib/sasl2/libdigestmd5.so.2.0.22
003bd000      4K rwx--  /usr/lib/sasl2/libdigestmd5.so.2.0.22
003f7000    104K r-x--  /lib/ld-2.5.so
00411000      4K r-x--  /lib/ld-2.5.so
00412000      4K rwx--  /lib/ld-2.5.so
00463000    180K r-x--  /usr/lib/libgssapi_krb5.so.2.2
00490000      4K rwx--  /usr/lib/libgssapi_krb5.so.2.2
0053a000    228K r-x--  /usr/lib/libldap-2.3.so.0.2.31
00573000      4K rwx--  /usr/lib/libldap-2.3.so.0.2.31
005b9000     28K r-x--  /lib/libwrap.so.0.7.6
005c0000      4K rwx--  /lib/libwrap.so.0.7.6
005c1000   1276K r-x--  /lib/libc-2.5.so
00700000      4K --x--  /lib/libc-2.5.so
00701000      8K r-x--  /lib/libc-2.5.so
00703000      4K rwx--  /lib/libc-2.5.so
00704000     12K rwx--    [ anon ]
0078c000      8K r-x--  /lib/libkeyutils-1.2.so
0078e000      4K rwx--  /lib/libkeyutils-1.2.so
007ab000    776K r-x--  /usr/sbin/sendmail.sendmail
0086d000     12K rwx--  /usr/sbin/sendmail.sendmail
00870000    472K rwx--    [ anon ]
0098d000     16K r-x--  /usr/lib/sasl2/liblogin.so.2.0.22
00991000      4K rwx--  /usr/lib/sasl2/liblogin.so.2.0.22
00a09000     12K r-x--  /usr/lib/libhesiod.so.0.0.0
00a0c000      4K rwx--  /usr/lib/libhesiod.so.0.0.0
00a0d000    876K r-x--  /usr/lib/sasl2/libsasldb.so.2.0.22
00ae8000      8K rwx--  /usr/lib/sasl2/libsasldb.so.2.0.22
00b02000     36K r-x--  /lib/libnss_files-2.5.so
00b0b000      4K r-x--  /lib/libnss_files-2.5.so
00b0c000      4K rwx--  /lib/libnss_files-2.5.so
00ca1000    272K r-x--  /lib/libssl.so.0.9.8e
00ce5000     16K rwx--  /lib/libssl.so.0.9.8e
00d92000     76K r-x--  /lib/libnsl-2.5.so
00da5000      4K r-x--  /lib/libnsl-2.5.so
00da6000      4K rwx--  /lib/libnsl-2.5.so
00da7000      8K rwx--    [ anon ]
00e10000     32K r-x--  /usr/lib/libkrb5support.so.0.1
00e18000      4K rwx--  /usr/lib/libkrb5support.so.0.1
00e21000     60K r-x--  /lib/libresolv-2.5.so
00e30000      4K r-x--  /lib/libresolv-2.5.so
00e31000      4K rwx--  /lib/libresolv-2.5.so
00e32000      8K rwx--    [ anon ]
00e90000     72K r-x--  /usr/lib/libz.so.1.2.3
00ea2000      4K rwx--  /usr/lib/libz.so.1.2.3
00ebe000   1192K r-x--  /lib/libcrypto.so.0.9.8e
00fe8000     76K rwx--  /lib/libcrypto.so.0.9.8e
00ffb000     16K rwx--    [ anon ]
08d7d000    404K rw---    [ anon ]
b7f77000     28K rw---    [ anon ]
bfa35000    208K rw---    [ stack ]
 total     9304K



(4) pstree 프로세스 상관도
실행중인 프로세스 상태를 트리 구조로 보여주는 명령어.
프로세스의 부모 자식관계를 형태로 보여주는 명령어

[명령어 형식]
# pstree (# pstree –l)
# pstree PID
# pstree user01

(선수작업) 필요하면 명령어 수행
# ps
# sleep 500 &
# sleep 600 &
# sleep 700 &
# ps

[root@linux220 ~]# ps
  PID TTY          TIME CMD
 8601 pts/1    00:00:00 bash
 8678 pts/1    00:00:00 ps
[root@linux220 ~]# sleep 500 &
[1] 8679
[root@linux220 ~]# sleep 600 &
[2] 8680
[root@linux220 ~]# sleep 700 &
[3] 8681
[root@linux220 ~]# ps
  PID TTY          TIME CMD
 8601 pts/1    00:00:00 bash
 8679 pts/1    00:00:00 sleep
 8680 pts/1    00:00:00 sleep
 8681 pts/1    00:00:00 sleep
 8682 pts/1    00:00:00 ps


[root@linux220 ~]# pstree | more

그림11


[root@linux220 ~]# ps
  PID TTY          TIME CMD
 8601 pts/1    00:00:00 bash
 8679 pts/1    00:00:00 sleep
 8680 pts/1    00:00:00 sleep
 8681 pts/1    00:00:00 sleep
 8693 pts/1    00:00:00 ps
[root@linux220 ~]# pstree 8601
bash─┬─pstree
     └─3*[sleep]


[root@linux220 ~]# bash
|---> ~/.bashrc read
|---> /etc/bashrc read
|---> /etc/profile.d/*.sh read
[root@linux220 ~]# bash
|---> ~/.bashrc read
|---> /etc/bashrc read
|---> /etc/profile.d/*.sh read
[root@linux220 ~]# ps
  PID TTY          TIME CMD
 8601 pts/1    00:00:00 bash
 8679 pts/1    00:00:00 sleep
 8680 pts/1    00:00:00 sleep
 8681 pts/1    00:00:00 sleep
 8696 pts/1    00:00:00 bash
 8708 pts/1    00:00:00 bash
 8720 pts/1    00:00:00 ps
[root@linux220 ~]# pstree 8601
bash─┬─bash───bash───pstree
     └─3*[sleep]


[root@linux220 ~]# exit
exit
[root@linux220 ~]# exit
exit
[root@linux220 ~]# jobs
[1]   Running                 sleep 500 &
[2]-  Running                 sleep 600 &
[3]+  Running                 sleep 700 &
[root@linux220 ~]# kill %1
[1]   종료됨               sleep 500
[root@linux220 ~]# kill %2
[2]-  종료됨               sleep 600
[root@linux220 ~]# kill %3
[3]+  종료됨               sleep 700


[root@linux220 ~]# pstree 8601
bash───pstree




(5) pwdx CMD
대상 프로세스의 현재 작업 디렉토리를 얻을 수 있다.

[root@linux220 ~]# ps
  PID TTY          TIME CMD
 8601 pts/1    00:00:00 bash
 8730 pts/1    00:00:00 ps
[root@linux220 ~]# pwdx 8601
8601: /root


[root@linux220 ~]# cd /etc/sysconfig
[root@linux220 /etc/sysconfig]# ps
  PID TTY          TIME CMD
 8601 pts/1    00:00:00 bash
 8734 pts/1    00:00:00 ps
[root@linux220 /etc/sysconfig]# pwdx 8601
8601: /etc/sysconfig



(6) nice / renice 명령어
프로세스를 실행하는데 있어서 프로세스에게 우선권을 부여 할 수 있다.
일반적으로 프로세스들은 설정된 우선권 순위대로 실행이 되는데
nice명령을 사용하게 되면 프로세스의 실행 우선권을 바꿀 수 있다.
우선권 순위는 -20에서 19까지의 범위를 가지며 nice 값이 적을수록 우선순위 값이 높아지게 된다.

프로세스의 우선순위: 프로세스가 운영체제의 CPU를 선점할 수 있는 권한

(프로세스의 우선순위를 조정하는 명령어)
■ nice 명령어 : 프로그램을 실행할 때 프로세스의 우선순위를 설정할 수 있는 명령어
■ renice 명령어 : 실행중인 프로그램의 우선순위를 조정할 수 있는 명령어

[root@linux220 ~]# ps -l
F S   UID   PID  PPID  C PRI  NI ADDR SZ WCHAN  TTY          TIME CMD
0 S     0  4636  4630  0  75   0 -  1461 wait   pts/1    00:00:00 bash
4 R     0  4714  4636  0  77   0 -  1379 -      pts/1    00:00:00 ps

PRI(Priority) 우선순위 숫자가 낮으면 우선순위가 높다
NI PRI에 대한 보정값 정도인거 같다?

PRI : Process가 OS의 Process 스케쥴러에서 갖는 우선 순위를 말합니다. 우선순위가 높으면 우선 순위가 낮은것 보다 우선 적으로 실행 됩니다.
NI : Process의 nice value입니다.  음수인 경우 높은 우선순위를 갖습니다.

(명령어 형식)

# CMD (EX: # backup.sh)
# nice -(-20 ~ 19) CMD (EX: # nice -10 backup.sh (NI: 10))
# nice -n (-20 ~ 19) CMD (EX: # nice --10 backup.sh (NI: -10))

# renice (-20 ~ 20) PID (EX: # renice 10 PID (NI: 10))
# renice -n (-20 ~ 20) PID (EX: # renice -10 PID (NI: -10))



[EX] nice 명령어 실습

[root@linux220 ~]# sleep 500 &
[1] 4723
[root@linux220 ~]# sleep 600 &
[2] 4724
[root@linux220 ~]# ps -l
F S   UID   PID  PPID  C PRI  NI ADDR SZ WCHAN  TTY          TIME CMD
0 S     0  4636  4630  0  76   0 -  1461 wait   pts/1    00:00:00 bash
0 S     0  4723  4636  0  77   0 -  1253 -      pts/1    00:00:00 sleep
0 S     0  4724  4636  0  77   0 -  1253 -      pts/1    00:00:00 sleep
4 R     0  4726  4636  0  78   0 -  1379 -      pts/1    00:00:00 ps
[root@linux220 ~]# nice -n 15 sleep 700 &
[3] 4728
[root@linux220 ~]# ps -l
F S   UID   PID  PPID  C PRI  NI ADDR SZ WCHAN  TTY          TIME CMD
0 S     0  4636  4630  0  75   0 -  1461 wait   pts/1    00:00:00 bash
0 S     0  4723  4636  0  77   0 -  1253 -      pts/1    00:00:00 sleep
0 S     0  4724  4636  0  77   0 -  1253 -      pts/1    00:00:00 sleep
0 S     0  4728  4636  0  95  15 -  1253 -      pts/1    00:00:00 sleep
4 R     0  4729  4636  0  77   0 -  1379 -      pts/1    00:00:00 ps
[root@linux220 ~]# nice -n -15 sleep 800 &
[4] 4731
[root@linux220 ~]# ps -l
F S   UID   PID  PPID  C PRI  NI ADDR SZ WCHAN  TTY          TIME CMD
0 S     0  4636  4630  0  75   0 -  1461 wait   pts/1    00:00:00 bash
0 S     0  4723  4636  0  77   0 -  1253 -      pts/1    00:00:00 sleep
0 S     0  4724  4636  0  77   0 -  1253 -      pts/1    00:00:00 sleep
0 S     0  4728  4636  0  95  15 -  1253 -      pts/1    00:00:00 sleep
4 S     0  4731  4636  0  62 -15 -  1253 -      pts/1    00:00:00 sleep
4 R     0  4732  4636  0  77   0 -  1379 -      pts/1    00:00:00 ps
[root@linux220 ~]# renice -5 4728
4728: old priority 15, new priority -5
[root@linux220 ~]# ps -l
F S   UID   PID  PPID  C PRI  NI ADDR SZ WCHAN  TTY          TIME CMD
0 S     0  4636  4630  0  75   0 -  1461 wait   pts/1    00:00:00 bash
0 S     0  4723  4636  0  77   0 -  1253 -      pts/1    00:00:00 sleep
0 S     0  4724  4636  0  77   0 -  1253 -      pts/1    00:00:00 sleep
0 S     0  4728  4636  0  75  -5 -  1253 -      pts/1    00:00:00 sleep
4 S     0  4731  4636  0  62 -15 -  1253 -      pts/1    00:00:00 sleep
4 R     0  4738  4636  0  77   0 -  1379 -      pts/1    00:00:00 ps


[root@linux220 ~]# ps -l
F S   UID   PID  PPID  C PRI  NI ADDR SZ WCHAN  TTY          TIME CMD
0 S     0  4636  4630  0  75   0 -  1461 wait   pts/1    00:00:00 bash
0 S     0  4723  4636  0  77   0 -  1253 -      pts/1    00:00:00 sleep
0 S     0  4724  4636  0  77   0 -  1253 -      pts/1    00:00:00 sleep
0 S     0  4728  4636  0  75  -5 -  1253 -      pts/1    00:00:00 sleep
4 S     0  4731  4636  0  62 -15 -  1253 -      pts/1    00:00:00 sleep
4 R     0  4741  4636  0  77   0 -  1379 -      pts/1    00:00:00 ps
[root@linux220 ~]# renice 5 4731
4731: old priority -15, new priority 5
[root@linux220 ~]# ps -l
F S   UID   PID  PPID  C PRI  NI ADDR SZ WCHAN  TTY          TIME CMD
0 S     0  4636  4630  0  76   0 -  1461 wait   pts/1    00:00:00 bash
0 S     0  4723  4636  0  77   0 -  1253 -      pts/1    00:00:00 sleep
0 S     0  4724  4636  0  77   0 -  1253 -      pts/1    00:00:00 sleep
0 S     0  4728  4636  0  75  -5 -  1253 -      pts/1    00:00:00 sleep
4 S     0  4731  4636  0  82   5 -  1253 -      pts/1    00:00:00 sleep
4 R     0  4744  4636  0  78   0 -  1379 -      pts/1    00:00:00 ps


(실무 예) nice, renice 사용 예

(백업스크립트/데이트 수집 스크립트)
(X) # /root/bin/backup.sh &
(0) # nice -n 10 /root/bin/backup.sh &

(부하량을 주는 프로그램)
# top
# renice 10 PID (PID : 부하량을 주는 프로그램's PID)
웹서비스용이면 웹데몬이 CPU를 많이 잡는다고 우선순위를 낮추면 안된다
DB용이면 DB데몬이 CPU를 많이 잡는다고 우선순위를 낮추면 안된다
주의하도록






원격접속과 파일전송
Remote Connection & File Transfer

파일전송
 scp CMD
 sftp CMD
원격접속
 ssh CMD

secure 암호화해서


sCMD 명령어 //s로 시작해서 sCMD, 아래 설명에서 뒤쪽은 평문으로 전송하는 방식
■ ssh Secure Shell(원격 접속) : telnet, rlogin
■ scp Secure Copy (파일 전송) : rcp
■ sftp Secure FTP (파일 전송) : ftp

[참고] (TUI)tcpdump, (GUI)ethereal, wireshark

(명령어 형식)
# scp file1 172.16.9.254:/tmp/file2
# scp file1 172.16.9.254:/test
# scp 172.16.9.254:/test/file1 /test
# scp -r dir1 172.16.9.254:/tmp  //디렉토리를 카피하기 때문에 -r(recursive)

[참고] scp 명령어는 cp 명령어 형식과 비슷하다.
# cp file1 file2
# cp file1 dir1
# cp -r dir1 dir2




[EX] scp 명령어 실습

(실습 전 준비)
# service sshd restart
# pgrep -lf sshd

(on linux220)

[root@linux220 /test]# cp /etc/passwd linux220.txt
[root@linux220 /test]# cd ~/.ssh
[root@linux220 ~/.ssh]# ls
known_hosts
[root@linux220 ~/.ssh]# > known_hosts
[root@linux220 ~/.ssh]# scp /test/linux220.txt root@172.16.9.252:/tmp
The authenticity of host '172.16.9.252 (172.16.9.252)' can't be established.
RSA key fingerprint is e2:f0:f8:a2:47:3b:b4:7c:ae:65:38:0e:31:bf:1f:84.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '172.16.9.252' (RSA) to the list of known hosts.
root@172.16.9.252's password:
linux220.txt                                                                 100% 1904     1.9KB/s   00:00   


암호/복호화

     +---------------+              +---------------+
A -> |암호화 알고리즘| -> 암호문 -> |복호화 알고리즘| -> A
     |     +3 /2     |              |     *2 -3     |
     +---------------+              +---------------+
           +key B                         +key C

key B = key C : 대칭키. 암호화키와 복호화키가 동일


[root@linux220 ~/.ssh]# cp /etc/services /test/CentOS220
[root@linux220 ~/.ssh]# scp -P 22 /test/CentOS220 root@172.16.9.252:/tmp //-P : Port Number
root@172.16.9.252's password:
CentOS220                                                                    100%  354KB 353.6KB/s   00:00   

[root@linux220 ~/.ssh]# ssh 172.16.9.252 ls /tmp/*220*
root@172.16.9.252's password:
/tmp/CentOS220
/tmp/linux220.txt


(on linux252)
# su - fedora
$ cp /etc/passwd testfile1


(on linu220)
[root@linux220 ~/.ssh]# ssh fedora@172.16.9.252 ls
fedora@172.16.9.252's password:
file1
file2
file3
linux200
linux201
linux202
linux204
linux205
linux206
linux211
linux212
linux220
linux223
linux228.txt
linuxfile200
linuxfile201
linuxfile202
linuxfile204
linuxfile205
linuxfile206
linuxfile211
linuxfile212
linuxfile220
linuxfile223
testfile1
[root@linux220 ~/.ssh]# scp fedora@172.16.9.252:/home/fedora/testfile1 /test
fedora@172.16.9.252's password:
testfile1                                                                    100% 2461     2.4KB/s   00:00   
[root@linux220 ~/.ssh]# ls /test
CentOS220  file1  file2  file3  linux220.txt  testfile1


(on linu220)
[root@linux220 ~/.ssh]# scp -r 172.16.9.252:/test /tmp
root@172.16.9.252's password:
kbd_mode                                                                     100% 7836     7.7KB/s   00:00   
loadkeys.static                                                              100%  598KB 598.2KB/s   00:00   
kill                                                                         100%   11KB  11.0KB/s   00:00   
uname                                                                        100%   20KB  19.6KB/s   00:00   
chmod                                                                        100%   38KB  37.9KB/s   00:00   
su                                                                           100%   24KB  23.7KB/s   00:00   
nisdomainname                                                                100%   12KB  11.9KB/s   00:00   
file4                                                                        100%  354KB 353.6KB/s   00:01   
mkdir                                                                        100%   29KB  29.3KB/s   00:00   
grep                                                                         100%   83KB  83.1KB/s   00:00   
alsacard                                                                     100% 6376     6.2KB/s   00:00   
file3                                                                        100%  354KB 353.6KB/s   00:00   
pwd                                                                          100%   23KB  23.1KB/s   00:00   
alsaunmute                                                                   100%   18KB  18.3KB/s   00:00   
csh                                                                          100%  339KB 338.6KB/s   00:00   
stty                                                                         100%   46KB  45.9KB/s   00:00   
rm                                                                           100%   45KB  45.4KB/s   00:00   
file1                                                                        100%  354KB 353.6KB/s   00:00   
gzip                                                                         100%   62KB  61.8KB/s   00:00   
domainname                                                                   100%   12KB  11.9KB/s   00:00   
unicode_stop                                                                 100%   79     0.1KB/s   00:00   
more                                                                         100%   31KB  31.4KB/s   00:00   
unicode_start                                                                100% 1271     1.2KB/s   00:00   
netstat                                                                      100%  118KB 118.5KB/s   00:00   
touch                                                                        100%   41KB  41.3KB/s   00:00   
dumpkeys                                                                     100%   57KB  57.4KB/s   00:00   
logger                                                                       100%   10KB  10.3KB/s   00:00   
ls                                                                           100%   93KB  92.9KB/s   00:00   
awk                                                                          100%  313KB 313.3KB/s   00:01   
dbus-cleanup-sockets                                                         100% 9624     9.4KB/s   00:00   
rvi                                                                          100%  581KB 580.8KB/s   00:00   
rmdir                                                                        100%   19KB  18.5KB/s   00:00   
date                                                                         100%   53KB  53.4KB/s   00:00   
mktemp                                                                       100% 9228     9.0KB/s   00:00   
tcsh                                                                         100%  339KB 338.6KB/s   00:00   
login                                                                        100%   25KB  25.2KB/s   00:00   
raw                                                                          100% 8108     7.9KB/s   00:00   
false                                                                        100%   17KB  16.7KB/s   00:00   
loadkeys                                                                     100%   78KB  77.6KB/s   00:00   
testfile1                                                                    100% 2461     2.4KB/s   00:00   
setserial                                                                    100%   20KB  20.2KB/s   00:00   
gawk                                                                         100%  313KB 313.3KB/s   00:00   
echo                                                                         100%   19KB  19.4KB/s   00:00   
dbus-monitor                                                                 100%   13KB  12.8KB/s   00:00   
traceroute6                                                                  100%   36KB  36.4KB/s   00:00   
gunzip                                                                       100%   62KB  61.8KB/s   00:00   
rview                                                                        100%  581KB 580.8KB/s   00:00   
ping                                                                         100%   35KB  35.0KB/s   00:00   
tracert                                                                      100%   36KB  36.4KB/s   00:00   
cp                                                                           100%   70KB  69.9KB/s   00:00   
file5                                                                        100%  354KB 353.6KB/s   00:00   
cpio                                                                         100%  105KB 105.4KB/s   00:00   
env                                                                          100%   18KB  18.0KB/s   00:00   
dbus-daemon                                                                  100%  318KB 318.4KB/s   00:00   
sleep                                                                        100%   19KB  19.2KB/s   00:00   
dnsdomainname                                                                100%   12KB  11.9KB/s   00:00   
mountpoint                                                                   100% 7196     7.0KB/s   00:00   
arch                                                                         100% 5088     5.0KB/s   00:00   
mailx                                                                        100%   81KB  81.1KB/s   00:00   
cat                                                                          100%   23KB  22.7KB/s   00:00   
tracepath                                                                    100% 9988     9.8KB/s   00:00   
dmesg                                                                        100% 6772     6.6KB/s   00:00   
dd                                                                           100%   47KB  46.5KB/s   00:00   
gtar                                                                         100%  224KB 224.3KB/s   00:00   
sort                                                                         100%   56KB  56.0KB/s   00:00   
ex                                                                           100%  581KB 580.8KB/s   00:00   
ksh                                                                          100% 1253KB   1.2MB/s   00:00   
sed                                                                          100%   51KB  50.6KB/s   00:00   
echo.start                                                                   100%    5     0.0KB/s   00:00   
view                                                                         100%  581KB 580.8KB/s   00:00   
usleep                                                                       100%   26KB  26.2KB/s   00:00   
ipcalc                                                                       100%   32KB  32.3KB/s   00:00   
tracepath6                                                                   100% 9996     9.8KB/s   00:00   
link                                                                         100%   18KB  17.9KB/s   00:00   
df                                                                           100%   44KB  43.7KB/s   00:00   
taskset                                                                      100%   10KB  10.1KB/s   00:00   
igawk                                                                        100% 3089     3.0KB/s   00:00   
doexec                                                                       100% 4796     4.7KB/s   00:00   
chown                                                                        100%   43KB  43.3KB/s   00:00   
tcptraceroute                                                                100%   36KB  36.4KB/s   00:00   
mount                                                                        100%   58KB  58.1KB/s   00:00   
zcat                                                                         100%   62KB  61.8KB/s   00:00   
ed                                                                           100%   43KB  42.7KB/s   00:00   
ping6                                                                        100%   31KB  30.5KB/s   00:00   
cut                                                                          100%   34KB  33.7KB/s   00:00   
hostname                                                                     100%   12KB  11.9KB/s   00:00   
ln                                                                           100%   29KB  29.4KB/s   00:00   
mail                                                                         100%   81KB  81.1KB/s   00:00   
chgrp                                                                        100%   41KB  41.1KB/s   00:00   
ps                                                                           100%   77KB  77.3KB/s   00:00   
ksh93                                                                        100% 1253KB   1.2MB/s   00:00   
sync                                                                         100%   17KB  17.2KB/s   00:01   
.mem2.c.swp                                                                  100%   12KB  12.0KB/s   00:00   
rpm                                                                          100%   88KB  87.6KB/s   00:00   
dbus-uuidgen                                                                 100% 7184     7.0KB/s   00:00   
egrep                                                                        100%   83KB  83.1KB/s   00:00   
unlink                                                                       100%   18KB  17.7KB/s   00:00   
sh                                                                           100%  719KB 719.1KB/s   00:00   
umount                                                                       100%   40KB  39.7KB/s   00:00   
setfont                                                                      100%   35KB  35.4KB/s   00:00   
pgawk                                                                        100%  314KB 314.1KB/s   00:00   
mv                                                                           100%   80KB  80.3KB/s   00:00   
red                                                                          100%   43KB  42.7KB/s   00:00   
dbus-send                                                                    100%   16KB  16.4KB/s   00:00   
ypdomainname                                                                 100%   12KB  11.9KB/s   00:00   
tar                                                                          100%  224KB 224.3KB/s   00:00   
gettext                                                                      100%   26KB  26.3KB/s   00:00   
file2                                                                        100%  354KB 353.6KB/s   00:00   
traceroute                                                                   100%   36KB  36.4KB/s   00:00   
vi                                                                           100%  581KB 580.8KB/s   00:00   
true                                                                         100%   17KB  16.7KB/s   00:00   
nice                                                                         100%   20KB  20.5KB/s   00:00   
keyctl                                                                       100%   23KB  23.3KB/s   00:00   
bash                                                                         100%  719KB 719.1KB/s   00:00   
fgrep                                                                        100%   83KB  83.1KB/s   00:00   
basename                                                                     100%   18KB  18.2KB/s   00:00   
redhat_lsb_init                                                              100%  576     0.6KB/s   00:00   
mknod                                                                        100%   25KB  24.5KB/s   00:00   



[EX1] sftp 명령어 실습

(on linux252)
$ pwd

$ cp /etc/services file1
$ cp file1 file2
$ cp file1 file3


(on linux220)
# cd /test
# rm -rf /test/*

# sftp fedora@172.16.9.252:/home/fedora/*

# pwd

# ls

# rm -rf /test/*
# cp /etc/passwd linux2XX
# cp /etc/services linuxfile2XX

# sftp fedora@172.16.9.252

# ls /root
-> linux* 파일 존재





원격접속 명령어(ssh 명령어)

(ssh 명령어 형식)

# ssh 172.16.9.252
# ssh root@172.16.9.252
# ssh fedora@172.16.9.252

# ssh 172.16.9.252 CMD
# ssh 172.16.9.252 hostname
# ssh 172.16.9.252 ls /tmp
# ssh 172.16.9.252 ls /test



[EX1] telnet/ssh 명령어 실습

[root@linux220 ~]# telnet 172.16.9.252
Trying 172.16.9.252...
Connected to 172.16.9.252 (172.16.9.252).
Escape character is '^]'.

    linux252.example.com (Linux release 2.6.18-409.el5.centos.plusPAE #1 SMP Tue Mar 15 18:56:56 EDT 2016) (12)

login: root
Password:
Last login: Wed Apr 20 20:54:31 from 172.16.6.204
You have mail.
[linux252@~]#  hostname
linux252.example.com
[linux252@~]#  id
uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel)
[linux252@~]#  exit
logout
Connection closed by foreign host.
[root@linux220 ~]# cd ~/.ssh
[root@linux220 ~/.ssh]# ls
known_hosts
[root@linux220 ~/.ssh]# cat known_hosts
172.16.9.252 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA1Wu5Y1I5yS4xHNxvHOyzwyh0qKc1AOdeloAUCbyDu0Xia+gGpdncN1US+s/95jCCSF+oW5psmTohI6N0gG978UJLen0YXi22Uibz8fr7Glx3B3I+gB7VaKd+T5PFs/K8eAgxHBIPF7wnWMi0BxNvG1wCySAbXErJNKSNgjGFzNcHDsEEZ03FuB7vP3PaIwY33k1uMtl6d5eBaxtLOvMFIPJt5awRb/jOOBjqC7f5MQhFL+reLV1tT6yoxK3NmwgkIScqctyQXVng0EIEP9LNYA08QXt+BJCgEbzrvTQ219gKIai4pTRJ9Gq2JoW6TIca0Q2SlmocyR1VdzBlCvCVVw==
[root@linux220 ~/.ssh]# > known_hosts //키를 지운다
[root@linux220 ~/.ssh]# ssh 172.16.9.252
The authenticity of host '172.16.9.252 (172.16.9.252)' can't be established.
RSA key fingerprint is e2:f0:f8:a2:47:3b:b4:7c:ae:65:38:0e:31:bf:1f:84.
Are you sure you want to continue connecting (yes/no)? yes //키를 새로 받는다
Warning: Permanently added '172.16.9.252' (RSA) to the list of known hosts.
root@172.16.9.252's password:
Last login: Wed Apr 20 20:55:41 2016 from linux252.example.com
[linux252@~]#  hostname
linux252.example.com
[linux252@~]#  id
uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel)
[linux252@~]#  exit
logout
Connection to 172.16.9.252 closed.




[EX2] ssh/scp 명령어를 통한 파일 전송

[root@linux220 ~]# a
[root@linux220 /test]# cp /bin/* /test
[root@linux220 /test]# ls
alsacard              dbus-daemon    false     link             netstat          sed            traceroute
alsaunmute            dbus-monitor   fgrep     ln               nice             setfont        traceroute6
arch                  dbus-send      gawk      loadkeys         nisdomainname    setserial      tracert
awk                   dbus-uuidgen   gettext   loadkeys.static  pgawk            sh             true
basename              dd             grep      logger           ping             sleep          umount
bash                  df             gtar      login            ping6            sort           uname
cat                   dmesg          gunzip    ls               ps               stty           unicode_start
chgrp                 dnsdomainname  gzip      mail             pwd              su             unicode_stop
chmod                 doexec         hostname  mailx            raw              sync           unlink
chown                 domainname     igawk     mkdir            red              tar            usleep
cp                    dumpkeys       ipcalc    mknod            redhat_lsb_init  taskset        vi
cpio                  echo           kbd_mode  mktemp           rm               tcptraceroute  view
csh                   ed             keyctl    more             rmdir            tcsh           ypdomainname
cut                   egrep          kill      mount            rpm              touch          zcat
date                  env            ksh       mountpoint       rvi              tracepath
dbus-cleanup-sockets  ex             ksh93     mv               rview            tracepath6
[root@linux220 /test]# mkdir -p /backup
[root@linux220 /test]# tar cvzf /backup/linux220.tar.gz /test
tar: Removing leading `/' from member names
/test/
/test/umount
/test/unicode_start
/test/echo
/test/tracert
/test/chmod
/test/stty
/test/ps
/test/doexec
/test/mkdir
/test/sed
/test/kill
/test/mountpoint
/test/mount
/test/gettext
/test/mktemp
/test/vi
/test/alsacard
/test/raw
/test/hostname
/test/dmesg
/test/ls
/test/pgawk
/test/gunzip
/test/ping
/test/ed
/test/mv
/test/uname
/test/gtar
/test/ipcalc
/test/gzip
/test/awk
/test/netstat
/test/bash
/test/rview
/test/chown
/test/domainname
/test/nisdomainname
/test/tracepath
/test/keyctl
/test/false
/test/login
/test/dbus-uuidgen
/test/setfont
/test/gawk
/test/tcsh
/test/kbd_mode
/test/date
/test/dbus-send
/test/dnsdomainname
/test/usleep
/test/pwd
/test/ksh
/test/grep
/test/touch
/test/dumpkeys
/test/ypdomainname
/test/nice
/test/basename
/test/sh
/test/mail
/test/redhat_lsb_init
/test/loadkeys
/test/cat
/test/mailx
/test/sync
/test/cpio
/test/unicode_stop
/test/view
/test/ping6
/test/rvi
/test/env
/test/ex
/test/ksh93
/test/sleep
/test/df
/test/loadkeys.static
/test/link
/test/dbus-monitor
/test/alsaunmute
/test/rm
/test/csh
/test/red
/test/setserial
/test/sort
/test/egrep
/test/tar
/test/more
/test/unlink
/test/dbus-cleanup-sockets
/test/tracepath6
/test/chgrp
/test/taskset
/test/arch
/test/rpm
/test/rmdir
/test/ln
/test/su
/test/dbus-daemon
/test/traceroute6
/test/dd
/test/cp
/test/true
/test/igawk
/test/tcptraceroute
/test/cut
/test/logger
/test/zcat
/test/fgrep
/test/mknod
/test/traceroute
[root@linux220 /test]# scp /backup/linux220.tar.gz 172.16.9.252:/backup
root@172.16.9.252's password:
linux220.tar.gz                                                              100% 6129KB   6.0MB/s   00:00   
[root@linux220 /test]# ssh 172.16.9.252 ls /backup
root@172.16.9.252's password:
linux200.tar.gz
linux208.tar.gz
linux212.tar.gz
linux213.tar.gz
linux216.tar.gz
linux217.tar.gz
linux220.tar.gz
linux221.tar.gz
linux226.tar.gz
linux2XX.tar.gz


[EX3] 로컬 && 원격 파일/디렉토리 비교

[root@linux220 /test]# cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1       localhost.localdomain   localhost
::1             localhost6.localdomain6 localhost6
172.16.6.220    linux220.example.com    linux220
[root@linux220 /test]# ssh 172.16.9.252 cat /etc/hosts
root@172.16.9.252's password:
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1       localhost.localdomain   localhost
::1             localhost6.localdomain6 localhost6
172.16.9.252    linux252.example.com    linux252

#
# Test OS
#
#172.16.9.50    linux50.example.com     linux50

#
# (1) Server Hosting List
#
#172.16.9.200   linux200.example.com    linux200
#172.16.9.201   linux201.example.com    linux201
#172.16.9.202   linux202.example.com    linux202
#172.16.9.203   linux203.example.com    linux203
#172.16.9.204   linux204.example.com    linux204
#172.16.9.205   linux205.example.com    linux205
#172.16.9.206   linux206.example.com    linux206
#172.16.9.207   linux207.example.com    linux207
#172.16.9.208   linux208.example.com    linux208
#172.16.9.209   linux209.example.com    linux209
#172.16.9.210   linux210.example.com    linux210
#172.16.9.211   linux211.example.com    linux211
#172.16.9.212   linux212.example.com    linux212
#172.16.9.213   linux213.example.com    linux213
#172.16.9.214   linux214.example.com    linux214
#172.16.9.215   linux215.example.com    linux215
#172.16.9.216   linux216.example.com    linux216
#172.16.9.217   linux217.example.com    linux217
#172.16.9.218   linux218.example.com    linux218
#172.16.9.219   linux219.example.com    linux219
#172.16.9.220   linux220.example.com    linux220
#172.16.9.221   linux221.example.com    linux221
#172.16.9.222   linux222.example.com    linux222
#172.16.9.223   linux223.example.com    linux223
#172.16.9.224   linux224.example.com    linux224
#172.16.9.225   linux225.example.com    linux225
#172.16.9.226   linux226.example.com    linux226
#172.16.9.227   linux227.example.com    linux227
#172.16.9.228   linux228.example.com    linux228
#172.16.9.229   linux229.example.com    linux229
#172.16.9.230   linux230.example.com    linux230
#172.16.1.200   linux200.example.com    linux200

#
# (2) Working Host
#
172.16.9.249    linux249.example.com    linux249

#
# (3) NFS Test
#
#172.16.9.239   ibmaix239       ibmaix239.example.com
#172.16.9.249   solaris249      solaris249.example.com


[root@linux220 /test]# ls /test
file1  file2  file3
[root@linux220 /test]# ssh 172.16.9.252 ls /test
root@172.16.9.252's password:
alsacard
alsaunmute
arch
awk
basename
bash
cat
chgrp
chmod
chown
cp
cpio
csh
cut
date
dbus-cleanup-sockets
dbus-daemon
dbus-monitor
dbus-send
dbus-uuidgen
dd
df
dmesg
dnsdomainname
doexec
domainname
dumpkeys
echo
ed
egrep
env
ex
false
fgrep
gawk
gettext
grep
gtar
gunzip
gzip
hostname
igawk
ipcalc
kbd_mode
keyctl
kill
ksh
ksh93
link
linux208.tar.gz
ln
loadkeys
loadkeys.static
logger
login
ls
mail
mailx
mkdir
mknod
mktemp
more
mount
mountpoint
mv
netstat
nice
nisdomainname
pgawk
ping
ping6
ps
pwd
raw
red
redhat_lsb_init
rm
rmdir
rpm
rvi
rview
sed
setfont
setserial
sh
sleep
sort
stty
su
sync
tar
taskset
tcptraceroute
tcsh
touch
tracepath
tracepath6
traceroute
traceroute6
tracert
true
umount
uname
unicode_start
unicode_stop
unlink
usleep
vi
view
ypdomainname
zcat




(실무 예) 암호입력없이 ssh/scp CMD 명령어 수행하기

=====서버A=====                               =====서버B=====
# ssh-keygen CMD
id_rsa
id_rsa.pub               ---------->          ~/.ssh/authorized_keys


(on linux220)
[root@linux220 ~]# cd ~/.ssh
[root@linux220 ~/.ssh]# ls
known_hosts
[root@linux220 ~/.ssh]# ssh-keygen -t rsa (# ssh-keygen -t dsa)
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
8e:c5:ec:a0:c1:31:96:af:c0:be:c7:a7:3b:9a:15:66 root@linux220.example.com
[root@linux220 ~/.ssh]# ls
id_rsa  id_rsa.pub  known_hosts
[root@linux220 ~/.ssh]# scp id_rsa.pub 172.16.9.252:/root/.ssh/authorized_keys.linux220
root@172.16.9.252's password:
id_rsa.pub                                                                   100%  407     0.4KB/s   00:00   


(on linux252)
# cd ~/.ssh
# cat authorized_keys.* > authorized_keys
# cat authorized_keys

(on linux220)
[root@linux220 ~/.ssh]# ssh 172.16.9.252 cat /root/.ssh/authorized_keys
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAsshx8jUPsyrDVHm4pYsi/SNzaEf0/I40IPIOInsgagk4nCJZpXKrtDN3dj1/3u16jKGMbmhK4v4V0axnVKXRtKDeySioJjMFwfP+M9dNdzOQpfhFkF5iC7FELq3SPWFak8/caEFB98Xb8J4WTrbUzuKvZH4ndYdcBiKTtyCpof5lK/+QwT/Wujb42LO2QjkhTKEyf1I6qxaSJNQhdMAKf33YvpE3P6UGRjjQVW1vQvsRlMqc6X8IdRtWlksW8IwejPdbkoCcIA/JDyGus/7eS4qTKENVfhU5lqb7Veqet7Yt4Ip9yykWFY4g3qnUTl0RADVrN65N9J9d5uhPnMYg4Q== root@linux200.example.com
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAmTf9xcvvwxJ0jAN/RyBcs2FbtWFfwaUv2D+fmkjDY6fFzdzurXi6AKHq7X+5mZ0ZI6+U3jVdzZ/VEPYGoTrdDptf4qAdSYkOWIjpFadEZX9JU9izuTj8lIIEWG/K/gce1mNKTftrPekgUyZrPnzBszG4fleWp8fADyZnwjZY2klulVaVmzzBYNxYBROZKnscYPRhKj8hvdov9TKktrk6oSUQzXfKZdiUB2tUTzmKAQjpwP1ik+bESqF4sJWyABQQWpx3vZnTBMew64xq6amUrUAh/hlKfwAVg3aFyreSqBsWm+E4jIMQ605E5+bPjmBOmzdOBj1nWtSPYymP5VIP+Q== root@linux200.example.com
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA2qcaUAEtoDg7Rql3yS+WWsvMkxIcMuqO7gRyCklbPTldIYHUNwyt6vVpMMpR1zOj8mdJOnTCKOklMyLigdPR50u77j8NCZYxFNLb5KTkG+BZuHyIq3MTFenjFqDd4TxrTw67zklDgAfqdrbf0OHC14aJv0r8I+YiCTC5xTQ6ZYAw3OtMsIfzsSNCP5HCjN8TrMlp3d83bOOilkYncGxhrRBptGIkf4OQyw6tOXCQIMjkqetYZ+47c0aTii6haIhyZYpv0toQVUGM9Qlw699/CRE3vRRNkwI1VuZuRynHkQerdvlKsKOlANLL+t4hfGg5ROt9zxA56/Wf6aPi7btA+Q== root@linux203.example.com
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA2fMfcq/BS5DmLJi6WD+Q3lJtzeBVyBEJ84EC7yJ475tg0UveSpXLP+uRdSzV9skH08XtJZaqLOw8PBGF1WdeuI1n1hQYvQActMUG3X8774S0SxOznQAVzfVGivIZboNmSFV6HWGQ46YpJyNLMMpv0nDYjQm7URyQwhfZQvvX6ujFUol1pywgPZxUGVWLhZJ+6Mper4VFDNQqi3qVidLBgPZidGHXPlN6djUVL6bY9deHn2yjdQKreFBlSYrqOnu0JylXNolQxXtAUYNNCdYq0Bg528UdRkNDue0iZvErvAmdldozSHVY3BcXKxBzmFjXDEPdWSYc5ZXffEYMmpUQCw== root@linux204.example.com
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAzCDcE5EixFwf00i3MvLzs6haTJN/b47IRqR58lpiFOxwejEOBl7GPXmdQfFDeLDgORannoXwOotbyc3YDOAhIgYQqcmgf5VifroyjmMnoavYOO7Cdomi+O3iJzfVn6oCz+rCNwpUUlTxbBPPz7gCNARlpy7Fn4DCEwoespPNcS32pPOnFHC6Bym2jbxuqcxqgNBQE7AEUcg0ZTKgEIPBw4WE2dtEy1YNoH0KrN2fnlD6YHrKQC9LZ8m55GVRbok4Ypt+8mKmKCkCFiA5kQZqzfFhdMBrBrPLhEQLedq8m9OfUF+iv1buwnIjmjeIlNwiGC91TYdDHXxjgq1n2NPlKQ== root@linux208.example.com
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAyMk7JRJZ9kovvRZJW38O4PIB4iiNaM6cnUVqFTmhTEMcRYgHFrhje8cZMSVT0JWbRLHX2QOfX+rqzWFRrXsJhVfM9Hvwdqf8PimvKcorYOLiej9OHCHEPgd+Ni3I4XVxKQPIfgU3or3M4DwAKPEexANwrng4xvuwhZdi7qDF/h8vAbQ8fQQ2IVt3KAqvka33YG0gq4yE3LfgAkf7SuZQTV2ss0lqsQ52KOBVBCk0r8qbH3hz4Y1fpG5Wr2vgSfxxI3fekeIJW6QU2VMZammMuGdiMtNxNHdK3wbZZoRlqQStwx70swFhnN1oEqemZIUxSl8Og+d+bZDAtf6hHYk/nQ== root@linux209.example.com
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAugbVrCpvozt+PXVDNi6DPFbW9AcIDGSpfaj22oWawmuJOmIduINiODZzNC4dcWpFH9cH078VIVawtsxFDLW/640mVrMdNBBaENxpdx8vjY29Yc6rgXWXl6CleCWGKhfXT1k9mOQtsUBITD8hFblEhrsBc+TK3Odof42huxJz37n/cslbX8AXQL4dVZW2hg1mH20hQ6AF7yZBDavTJp+Ngf3eijhKS0Qewgxv8avZ/ahN04LBmoXaWNDeIbHb5337mZfuW5BZAGXezGBy+ffsX0XzdblG11XY5roMNYpMVIXkhSEIJ/AB/OYciwBpk7Cn6SFF7i5IJXf7kEyRADFTfQ== root@linux210.example.com
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAoLge+fBBQyteutiDVvd3ptF3A1DCGaBmYoIcZjiJbPwHCY9AUp1p0M/Vwsr19EsrsNQB0aEG9mwRjedeRrR0XwwPl8n9w50OVVkDCLvadwJ9UwFXJaE/DpDE4Ss+nBuByTVdCzuygCzA+pZjPumy1n5luvhhaC0el+mrhYs+Ep/ZqTIKHcjuxsA3rQIApUoMkVucipO3aUjH72KDzpLVR3F9bJZcHf39Vel8auYOfNxBsAgpj5bHCLFF3O4qcVfZlskiKw8LRavK/hO9iJ/dmvpfiFH/EfuZV8xiRRgxXwWcEk8mZWzcBKaETrTXrLs73sbzhmgVRUIHsAMzCBEZpw== root@linux211.example.com
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAqyaTXCY3F+D40Nl/unvYElTt+s3Dt9fAWCqztD9VqFbkeyY80zIBTh1PfgvUxTUtdY8sfWDul8XNrGXE7lSFoRHPE0J600sfNi3NhzXm+uL6ssuaFR+6TsIQBELnIu3+kB5aPL9Wzxe79e4cdd1/pFfwu8920YF+Eb8MTqlllaTGpImOjEQH4uXl2y1TAinEkDosSkFAh1WuIHSwRoCOsNPdYsEGIPE6O4leVyLzjXBAJGzmadRhDlTXO37LzkYVtPnA84pdVuI37u40V3o/xy3YNSAuJmsAfT/R2gWLAD+qI3mLVoMyvESvwrCNXjnRjYinB8jjhDBP+9a/NGFfgQ== root@linux212.example.com
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA1vY482Q5Q6UmfGc/Xcl+P9z/xVFXonW58k1dKdcgr9xCYmoAHTp+fQze7ElZNkXbbexCMO6agiYMFekY1NNNmOPPUvw5FS886X6mrYgoiGlaflUVRNYvQZKWxz330acUkHV1qeu/nswohfttBou2nFREkkXg2UQjb+gxpCrn/jiwcHMl/rjS/HToxELjWpKDF9VkUfHeC202CF9OI1YbmwU3S5rxsJCERguBaCOoDeUDuQDA/sOi/vDX6hqXEWNG8pxb8w0GMvEZ9zGDQlDL2mY6Pvm5Fox6DW9bcvu7XkjRhLUTOR5uWCLm+JQ3xzG18CQ0GGlzp39LdOEZ2Asi3Q== root@linux213.example.com
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEApm0KxAiZWI18hEfPxcygUXrlhQPrcVKCLEslD2l4tlxDRdMIvHQgsKx8Z4CK5YPA+bD3Twp5bPTaz1AOk2/9yjVchT/c0A5vPl2i4gcC4W1Fq7ENlOKqFTgh1I3PxieOLWF/GFsnte58EnI3vj1JaV5RuMd3QgzV8VYsa5LClBp3ibAjC0X5r8a2h7Vmo2Mep+F/OZvWm7uVtqFQ4bYFmic6IazqTrAkhtuqmlOSxuDQzcMd899lbTelE1M84Wif1UvdOp1jxp/fAbtA5xdwOBxiP7bQlbLmGE80vS5UyjuMUhshjTU1ues45I9vV1ETUAOyzCGWVmN+47EuZUSaeQ== root@linux215.example.com
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAulcHALXahBFwyWW0AU+/3JiACpw3Evc3bzeq86sOH7ldUYEP60IOC3uWJcy1Q+JB9cAqKnKSXTRW379z1rtMdXC8womAo63xZEM73JVl7zwiyCaK3lR5EtbFOUagvag+lARLYzXLgTBp8QZ0IWYvtvBWTKWXGh/tZlpzXM9pol1gYhJ4N/i7QlJqA3LNeM8nC4fCenU21H5ZAwuhM//5l4D6FLLyFvsuhks8z34/s8V3IvYjGxSl5cZnlL9pbMFDlFFb8dQ5Y6ZIDVvvztzUss+1IxXT+kkQZP7nEKU+dkTukWu4hgdtp1N1qdf++JA6FYYXtU4nURlGuXa4HEA+aw== root@linux216.example.com
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAqEmsezj/jz/qF6Y6X60Y6VsPNAnaPv1AUrrYhyADLYjR4RufgS/O/t6EiEBf8asae7qwtWE1NMn+cAQFGIVzUyA2xkgQz+LMS9TQGjJLIVPQzY4C1UF6rd49TFCyt1lhO+uMpqLQ7MjpY0WZOtUO9aQOIEnOtKdSnoQP2ggMDs4UjI8CQmVVHfKD/qB3UphecO9D7RwHnvBpcQKs4LqquzeSRDlcBszsPDOh2AFbUTzNPyW5/UPCI7mErhxu9xnhXyBBeG6ZG4vVcnIyZ6EiILiTCwtfE0otyZT+Y8ynBT2idE5SNG18et1RQ/xjXpaXnKcH6nDIuZPT5Td+yHzzAw== root@linux217.example.com
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAln/JssvWvvN4YPWUf62H5WTevTl1GdpfYnFYig3UTKXPk+4LHI7OIPFL1cqZuAzoIQFr76rqJO2WXx9aA4crcS0FWodvK6DuMK9Id4MqIUKZKrHXTRVxVE+717qTLow7RkbOmCXYIQruEqJQH1zsKfS+iXqI3/rEoV17s7uZId3L/0L6k+axuRFi/2nb+O0+6oQAK7seQVXZ4M9oZYDzzFC+HhGf1Hk/IOnRNTjkrO3Oy6bXg+spDNzHvm0J6k4UJUuQsYEYYkzztJLxk1lTXU+3hGCGPOTC2kolptDv2vU7OVPpWgV0iGCrVOD8eG5R6msRXOsrPqk5hZ3HnyrlIw== root@linux218.example.com
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAxmkv76UB2EK2qDx02rtL9e8Y2sQp/vdr8A76OZCyUj5FWvI+qAyAwHoFUi8xJVflv0UVGLzaBRHeGVaPgdK5dlbUkftS/rWUSRCiBWY5vE56O+r1myJnwrR4MkA2e4W88P0thBArdACO4xyMu2hBy2nOQkxBjrpUn02/o+Yr2Za7KTYgLswQNY6Ov2tUQScZyAzizkTvjhx27mWKVdSaVd2k0CwLUWLbYCz215R/YBMbjbHYN82Drl8pDj33m21N6WS8H6t+87XwF/EE2cm0hGyzXRhF2iS3D6gwtYWtMRi+WQaSFWNYKxeOM1fGcF0wQ4UkXQkirW2ARbwwCjKwMw== root@linux219.example.com
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAr+XkmiZQv3r/z6hYgwcIWZNUWm27uRmBa+rLDQJFiFvhujXLw3TJG1XgRspB8yLKY53VVzikanlL+kvJGoYU1rDAomp8kk+dSzcOGAn3uSwJiCNjuGfPa3rlsQ4tH2JIn014qkxXeQWJ3ScMHUVGkLCsoH0EhFW1WsLJxCI4I52SAo13NUMUn7dd6z8v5Cw4TbHf0P89V16xSPO5TbvdagE8fxEHdiwWiCpVbsMGzMlh1E0fxcjAW6sX+hNhRdKhqm214UDFsFMbN6wHn9IUaONYPqyCEash1WTCemHp5QLAYei3i5YBBaLVahDTaIoC2ApBu3b3UoNJh940A1yZ6Q== root@linux220.example.com
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA26A+DPUo2A2h28/iuWD7Ia892d5jqnPNOdXxyde0UnVqQzWstH2aUonDZkbMDycCIMu3ZhfAzU6Fr1jLGcpnYSljGdVxyHAGi9cYqSf722uvTFkrT2lqYGnl3hqgUIYzNsnv09984Pptd63P4ffTTwacm38brB+IWueUbuJzMRVGDLKR6PA9AAfadN9/bRJ4rl4FeLj/eu9GKYqUxcBhrWpsA3gFIF6eti6WQzdyBYSHFCvcKOO64ZnoXFGG9yRpwH26VkVuukMxDdPuZB8mXDrtjhwvWQbw0mqqrApEqYz6E9s+GO9W4oAuHALiWNrhaHjDXpZ8gzm9UXlZhlhOHw== root@linux222.example.com
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAplJluWti16B68pwgxFeeks3vJD9nz+FFxBeqNSxKynZUpf+htGF42yN0HF3RoR3DofHUHGo41aTspPJh19+Xirdb1XqfudJg2hq2W4nH9QkU9/4SaRqG/QGEugjwWw3DpgVjeLzEoPs9vt5ajddazOYbcJ4TCIYWlOVeuYNlLrynSMh9llLcJLd3UXxzyEzUH6QuUYrqTlzOojrQ5z5W9KixZmgWOVAFZgBBy0xmc64KCDVepD+J80ibQx8dPIgdTfg5N4JoVSDCoKpg9Ig7FVc555j+PPDzo2Ig4dZVf6Fat8QK7Xauhh2TnBU5cKYAOfzmUBKgvvh69u9x1H3smw== root@linux224.example.com
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA0OvNGYTphqxqxoMoSKkVtVJSpt5V1xWnMVR0enOneLR58bQjmnamueSdoqFhQ+470Uh0yu9n44FaqXNH97jrJrXqaRqk+OvS/9eia4sChPwM+B9RaCzwO77MKjl7BJwglQslqd5EeWsf7AUGR2zastDybMJVIQokUuzDJYmVv/ZID3l/8P3A9YnDmVABwkoMIKL8B7snsF6qjokb3Hjc3nx9ngpS8qXMD4QLh9nFr5X8YWfSAfRKz3rY40V2xZqry593BsNY77Mx4OXmJMELyQ6DrohZe8EQdZCuiXAN2GUPPrIYhtJlpYORhrPJvjPOkgD1lBryeZe391jgZdWb6w== root@linux225.example.com
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAyir2TBIVp+AF6b9Mpm5Vob72Dkqsf6VAf7/yd+pGtYvTAFN2KSsKJ82LAYh/SMdsL+kKirQcHJ4EBz/LjA2VtASXcM1X5aCDblcbZpIvSWx1oaaX4o1xWInHBZ4O5R6zUIqJ/hing+sYKyhYIXdW80csG8ZNl6CZR1Rli7879hmFOdisU8ufikuVek+GNrq2dKfqlOb2+Nma9dgIaT3m0JFxaBK207kT3AAz77L9mNUNEUQY4XW1adpqj5M5OR4iPuxRn3zh71rpIXkvKdG+D/+1iEkBqpGB0kE9q/LOdjH0+kEx7C0Jam76r4xNhB8GHKdLaUljs2AfMQODyVQQjQ== root@linux227.example.com
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA0GdykYm8/tMy2rVTc7ELbXDEznbasK15j7RO9dupFfoY9xfmrDWfivLOgfeIJu5nMFVGjgWBuEtWih6SeWwfK9Tshw3VdQpCwkGkgpVRl/NHSci7I14mpd33WtxX0qbGpdwedi0JqyKmcGLJ+qcThZ+y1W01g/1mGDS3BSVXe4wklwzdJd4X/UKVu9SmCiijEJLwUaSdVSkAqG4/3Od0FUihke/Wn5jPIBN5GZsKESsZMMgbZUq/X1jdNzeXjNOAQpfMTjBQBm7OynW1xRMWh2RMrKw4bBdfsMly2WMm+RD5nVad6dN4BtmtpJWXk83qsAAgjIm8+X9md+lZYE14Gw== root@linux228.example.com
[root@linux220 ~/.ssh]# ssh 172.16.9.252 hostname
linux252.example.com
[root@linux220 ~/.ssh]# ssh 172.16.9.252 cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1       localhost.localdomain   localhost
::1             localhost6.localdomain6 localhost6
172.16.9.252    linux252.example.com    linux252

#
# Test OS
#
#172.16.9.50    linux50.example.com     linux50

#
# (1) Server Hosting List
#
#172.16.9.200   linux200.example.com    linux200
#172.16.9.201   linux201.example.com    linux201
#172.16.9.202   linux202.example.com    linux202
#172.16.9.203   linux203.example.com    linux203
#172.16.9.204   linux204.example.com    linux204
#172.16.9.205   linux205.example.com    linux205
#172.16.9.206   linux206.example.com    linux206
#172.16.9.207   linux207.example.com    linux207
#172.16.9.208   linux208.example.com    linux208
#172.16.9.209   linux209.example.com    linux209
#172.16.9.210   linux210.example.com    linux210
#172.16.9.211   linux211.example.com    linux211
#172.16.9.212   linux212.example.com    linux212
#172.16.9.213   linux213.example.com    linux213
#172.16.9.214   linux214.example.com    linux214
#172.16.9.215   linux215.example.com    linux215
#172.16.9.216   linux216.example.com    linux216
#172.16.9.217   linux217.example.com    linux217
#172.16.9.218   linux218.example.com    linux218
#172.16.9.219   linux219.example.com    linux219
#172.16.9.220   linux220.example.com    linux220
#172.16.9.221   linux221.example.com    linux221
#172.16.9.222   linux222.example.com    linux222
#172.16.9.223   linux223.example.com    linux223
#172.16.9.224   linux224.example.com    linux224
#172.16.9.225   linux225.example.com    linux225
#172.16.9.226   linux226.example.com    linux226
#172.16.9.227   linux227.example.com    linux227
#172.16.9.228   linux228.example.com    linux228
#172.16.9.229   linux229.example.com    linux229
#172.16.9.230   linux230.example.com    linux230
#172.16.1.200   linux200.example.com    linux200

#
# (2) Working Host
#
172.16.9.249    linux249.example.com    linux249

#
# (3) NFS Test
#
#172.16.9.239   ibmaix239       ibmaix239.example.com
#172.16.9.249   solaris249      solaris249.example.com


[root@linux220 ~/.ssh]# ls
id_rsa  id_rsa.pub  known_hosts
[root@linux220 ~/.ssh]# mv id_rsa.pub authorized_keys
[root@linux220 ~/.ssh]# ssh 172.16.6.220 hostname
The authenticity of host '172.16.6.220 (172.16.6.220)' can't be established.
RSA key fingerprint is 54:29:83:45:01:48:8a:3f:a9:49:5c:59:a8:4c:b1:93.
Are you sure you want to continue connecting (yes/no)?
[root@linux220 ~/.ssh]# ssh 172.16.6.220 ifconfig
The authenticity of host '172.16.6.220 (172.16.6.220)' can't be established.
RSA key fingerprint is 54:29:83:45:01:48:8a:3f:a9:49:5c:59:a8:4c:b1:93.
Are you sure you want to continue connecting (yes/no)?

왜 또 키를 받으라고 하는걸까??

known_hosts 값을 비우고 나니 252에 접속할때 또 키를 받으라고 함

뭐가 문젤까?

---->> 내가 이해를 잘못한 문제

키는 새로 받지만 암호입력없이 들어갈수 있게 하는것이었다!!

[root@linux220 ~/.ssh]# ssh 172.16.9.252 hostname
The authenticity of host '172.16.9.252 (172.16.9.252)' can't be established.
RSA key fingerprint is e2:f0:f8:a2:47:3b:b4:7c:ae:65:38:0e:31:bf:1f:84.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '172.16.9.252' (RSA) to the list of known hosts.
linux252.example.com

[root@linux220 ~/.ssh]# ssh 172.16.6.220 hostname
The authenticity of host '172.16.6.220 (172.16.6.220)' can't be established.
RSA key fingerprint is 54:29:83:45:01:48:8a:3f:a9:49:5c:59:a8:4c:b1:93.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '172.16.6.220' (RSA) to the list of known hosts.
|---> ~/.bashrc read
|---> /etc/bashrc read
linux220.example.com
[root@linux220 ~/.ssh]# ssh 172.16.6.220 ifconfig
|---> ~/.bashrc read
|---> /etc/bashrc read
eth0      Link encap:Ethernet  HWaddr 00:0C:29:1F:D6:BF 
          inet addr:172.16.6.220  Bcast:172.16.255.255  Mask:255.255.0.0
          inet6 addr: fec0:1234::20c:29ff:fe1f:d6bf/64 Scope:Site
          inet6 addr: fe80::20c:29ff:fe1f:d6bf/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:254383 errors:0 dropped:0 overruns:0 frame:0
          TX packets:19338 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:58422053 (55.7 MiB)  TX bytes:8444881 (8.0 MiB)
          Interrupt:67 Base address:0x2024

lo        Link encap:Local Loopback 
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:1487 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1487 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:2317725 (2.2 MiB)  TX bytes:2317725 (2.2 MiB)



기초 끝.












'모의해킹 침해대응 전문가 과정' 카테고리의 다른 글

20160421 리눅스 관리자  (0) 2016.04.22
20160420 리눅스 관리자  (0) 2016.04.21
20160419 리눅스 기초  (0) 2016.04.20
20160418 리눅스 기초  (0) 2016.04.19
20160415 리눅스 기초  (0) 2016.04.15
Posted by 22Hz
, |

최근에 달린 댓글

최근에 받은 트랙백

글 보관함