블로그 이미지
오정oI

카테고리

분류 전체보기 (119)
회사 - pj # 나라원 (1)
회사 - pj # 나라원 (2)
이직준비 (10)
국비-클라우드 (1)
학점은행제 (0)
취미 (0)
주식 (0)
외국어 (0)
자격증 (14)
BigData_On (1)
BigData_Off1 (74)
딥 러닝 (0)
머신러닝을 이용한 빅데이터 분석 (0)
Index (0)
Spring Framework (0)
JSP (0)
리눅스2(재) (0)
네트워크기초(재)-CCNA (0)
리눅스2 (15)
리눅스1 (16)
윈도우2 (20)
윈도우1 (15)
CCNP-Switch (1)
네트워크기초-CCNA (7)
파이썬 (0)
클라우드 (0)
언어_Framework (1)
언어-Server (2)
언어_Client (0)
업무 (1)
IT참고서적 (1)
IT 최신 트랜드 (0)
제테크 (1)
Study Plan (2)
동영상 및 자료 (5)
여행 (1)
git (0)
Total
Today
Yesterday
반응형
SMALL

*  프로세스(Process)

프로세스(Process)
- 컴퓨터에서 연속적으로 실행되고 있는 컴퓨터 프로그램을 말함

사용형식
ps [option]

option
-e : 모든 프로세스를 출력
-f : 풀 포맷형식으로

 

프로세스 종료 명령어

사용형식

kill PID

 

 

프로세스 항목
UID : User ID(사용자 고유 식별자)
PID : Process ID(자식, 프로세스 고유 식별자)
PPID : Parents ID(부모, 프로세스 고유 식별자)
C : CPU(점유율)
STIME : Start Time(접속한 시간)
TTY : TeleTYpe Writer(가상 터미널)
TIME : 실행시간
CMD : CoMmanD(명령어)

[root@localhost itbank]# ps -ef

[root@localhost itbank]# kill 2484
[root@localhost itbank]#

 

////////////////////////////////////////////////

 

* CentOS 6이하 운영레벨

 

 

 


/etc/inittab -> 리눅스가 부팅할 때 운영레벨을 선택하는 설정파일

#   1 - Single user mode
 단일 사용자(root로 바로 로그인, 비번없이)
 Windows에서 안전모드와 같다
 파일시스템을 점검, 관리자 비밀번호 변경, 악성코드,  바이러스 등
 관리자가 관리하기 위해서 (복구모드)
 CLI환경
#   2 - Multiuser, without NFS (The same as 3, if you do   not have networking)
 다중 사용자(어떠한 사용자로 로그인, 비번입력),   NFS(서비스)를 지원하지 않음
 CLI환경
#   3 - Full multiuser mode
 다중 사용자(어떠한 사용자로 로그인, 비번입력),   NFS(서비스)를 지원함
 CLI환경
#   4 - unused
 /etc/inittab을 사용하지 않음(2번과 동일)
 CLI환경
#   5 - X11
 X-Window를 사용하여 그래픽을 지원함, 3번 기능까지   지원함
 (현재 우리가 사용하고 있는 운영레벨임)
#   0 - halt (Do NOT set initdefault to this)
 종료
#   6 - reboot (Do NOT set initdefault to this)
 재부팅 

 

* 현재

CentOS 6이전   | CentOS 7
/etc/inittab   | /lib/systemd/system/
--------------------------------------
runlevel 0  -> poweroff.target
runlevel 1  -> rescue.target
runlevel 2  -> multi-user.target
runlevel 3  -> multi-user.target
runlevel 4 -> multi-user.target
runlevel 5  -> graphical.target
runlevel 6  -> reboot.target

운영레벨 변경하기(CentOS 7 기준)
ln -sf /lib/systemd/system/TARGET.target /etc/systemd/system/default.target
systemctl set-default TARGET.target

운영레벨 확인(CentOS 7기준)
systemctl get-default

////////////////////////////////////////////////

 


* 관리자 비밀번호 분실 시 해결방법

 

 

1> 비밀번호 분실 시 해결방법

부팅시 커널에서 알파벳 'e' -> 15줄에서 방향키 왼쪽 버튼을 눌러서 rhgb quiet까지를 삭제후

ro를 rw로 변경 후 한 칸 띄고 init=/bin/bash를 입력 후 ctrl+x를 누름

비밀번호를 바꾸어야 하므로 passwd 명령어를 사용하여 비번을 바꾸자

exec /sbin/init 치면 재부팅

비밀번호 분실 시 해결방법

 

 


2> grub 암호화 걸기

root로 그래픽으로 로그인 하시고 아래와 같이 작업을 하세요
준비물
mkdir /backup
cp /boot/grub2/grub.cfg /backup
cp /etc/grub.d/00_header /backup

1) /etc/grub.d/00_header를 확인!
2) 문서 편집기를 이용하여 00_header를 작업!
3) 맨 마지막 줄 아래에 작성하기

cat << EOF
set superusers="root"
password root linuxone
EOF

4) 저장 후 종료
5) grub2-mkconfig -o /boot/grub2/grub.cfg 타이핑하고 엔터!
6) reboot


EOF
화면에 긴 문장을 한번에 출력할 경우
띄어쓰기 줄바꾸기도 그대로 유지
EOF 바로 앞까지 출력

 


[실습]

// 비번 변경

재부팅

> 3줄 있을 때, 마우스 안에 넣고 e 또는 ctrl+alt+insert

> 위에서 15째줄 까지 오고 왼쪽 무우스 누르기 이 줄 다 지우고

> 커서를 ro쪽 오고 ro를→ rw init=bin/bash 로 변경

> Ctrl-X

> bash-4.2# passwd Enter

> 1, 1

># exec /sbin/init        // 재부팅

 

// 암호화 처리 ; 알파벳 e 못치게(보안 처리)

# ls -l /backup

# cp /etc/grub.d/00_header /backup        // group에 관련된 파일

# ls -l /backup

 

# vi /etc/grub.d/00_header            

맨 밑에

빈 줄 생성

360 cat << EOF

361 set superusers="centos7"

362 password centos7 linux1    // lunux1 : 비번

363 EOF

:wq

 

# grub2-mkconfig -o /boot/grub2/grub.cfg

done

이 뜨면 된거

# reboot

세 줄 떴을 때 알파벳  e 누르고 비번 눌러서 체크해보기

centos7

linux1

 

////////////////////////////////////////////////

 

 

 

 

 

 

* Partitioning 방법

 

1. HDD 추가 (IDE)

 

poweroff> VMware> Edit virtual machine> settings> add> 예>

Hard Disk  클릭> IDE 체크> Create a new virtual disk  클릭>

Maximum disk size : 1.0 GB> Disk file(기본값)> Finish> 확인 후 OK

 

2. HDD 삭제

 

poweroff> Edit virtual machine> settings> 삭제할 HDD를 선택>

Remove> OK

 

3. HDD  확인

 

사용형식

fdisk [option]

fdisk [option] 장치명

 

option

-l :  하드디스크와 파티션 목록

 

 

4. 파티션 생성

 

사용형식

 

fisk 장치

 

fdisk에서 사용할 명령어들

d는 파티션 삭제

l은 파티션 타입 리스트

m은 도움말 출력

n은 파티션 생성

p는 파티션 테이블 출력

q는 저장하지 않고 종료

t는 파티션의 시스템 ID 변경

w는 저장하고 종료

 

1) Primary(주) Partition 생성

n → p 또는  enter → 파티션 번호는 생성하는 순서대로 잡아주는 것이 좋음(1 또는 enter)

→ 첫 번째 섹터는 기본값대로  → 마지막 섹터는 용량으로 하는게 편함(용량은 +용량단위) +500M

 

2) Extened(확장)

Partition 생성

n → e → 파티션 번호 순서대로(2 또는 enter) → 첫번째 섹터는 기본값으로(enter)

→ 마지막 섹터는 용량으로(+용량단위) +300M

 

3) Logical(논리)

Partition 생성

n →  l → 파티션 번호는 무조건 5번(이상) → 첫번째 섹터는 기본값으로(enter)

→ 마지막 섹터는 용량으로(+ 용량단위) 또는 용량으로 enter(남은 용량 다 잡아라)

→ enter

 

 

 

삭제시 d

Partition num : 2

확장(extended) 지우면 logical 도 같이 지워짐

 

 

p

sdb1 : HDD명+partition num,

End : sector

Blocks :  용량

ID : 리눅스 시스템 고유 번호, 83

 

확장은 System의 Extended

논리는 Device Boot의 /dev/sdb5 => 5번부터인것 확인~!

 

 

5. 포맷(Make File System)

 

사용형식

mkfs [option]  인자값 장치

(파티션)

또는

mkfs. 인자값 장치(파티션)

 

option

-t : type.

 

인자값

 xfs    // centos7 에서 쓰는 파일 시스템 (windows에서 NTFS; FAT32(기본값) : 4GB 이상은 못 받음)

 

cf. 포맷 대상

p(주), l(논리)

p는 포맷이 되는데

e는 포맷이 안됨(사용할 수 있는 공간이 아님)

 

(참고!

CentOS 5.x  포맷 방법

mkfs -t ext3 장치(파티션)

또는

 mkfs.ext3 장치(파티션)

 

CentOS 6.x 포맷 방법

mkfs -t ext4 장치(파티션)

또는

mkfs.ext4  장치(파티션)  )

 

 

6. 마운트(mount)

- 파일 시스템을 디렉터리 일부에 넣어서 이용가능하게 하는 작업

마치, 디릭터리처럼 사용하는 것을 마운트라 할 수 있음

- 서버의 자원을 사용하는 것이므로 관리자만 사용가능

- 장치파일을 디렉터리화 함

 

사용형식(mount 장착)

mount

→ 마운트 된 목록을 출력

 

mount 장치(파티션) 임의의 디렉터리(mount point)

 

사용형식(mount 장착해제)

umount 장치(파티션)

또는

umount 임의의 디렉터리(mount point)

 

별도로 mount 상태 확인할 때   df -h를 사용함

 

df(명령어)는 디스크 공간 확인

-h은 사람이 보기 편하게 출력

 

!  mount 주의사항

 

1)  mount를 할 때 하나의 장치나 파티션은 반드시 하나의 임의의 디렉터리(mount point)를

사용해야 함

(예를 들어, 1개의 장치를 사용할 때 여러 개의 mount point를 사용할 필요가 없으며, 여러

개의 장치를 하나의 mount point로  mount 해서는 안 됨)

 

2) umount를 할 때 반드시 mount point에 있어선 안 됨

(예를 들어,  mount point나 그 하위에 있으면 umount가 안됨. 그래서 mount point가 아닌

곳으로 변경해야 함)

 

3) mount를 할 때 Primary Partition과 Logical Partition만 해당 됨    // 포맷이 되니까

(Extended Partition은 mount  할 수 없음)        // 포맷이 안되니까

 

4) mount를 할 때 반드시 기존에 사용중인 디렉터리로 mount 해서는 안 됨

(예를 들어, 사용자 홈 디렉터리 X 기존에 사용중인 /home/itbank 로 하지마!!!

mkdir로 새로 만들것! )

 

 

ex>

 장치파일    

 디렉터리

 /dev/sdb1

 /a 

   귀신  →  어떤 사람

             mount

           ↑ 빙의

Driver

S/W ↔ H/W

 

☆ CD-ROM 사용 방법

먼저 iso image file을 삽입!

: VM> Settings> CD/DVD => C:0_CentOS7>ISO

사용형식
mount /dev/sr0(원본파일) 임의의 디렉터리(mount point)
또는
mount /dev/cdrom(바로가기) 임의의 디렉터리(mount point)

 

(참고로

The partition table has been altered!        // w 눌렀을 때??

 

Calling ioctl() to re-read partition table.

Syncing disks.

 

위 문구 사이에... The new table will be used at the next reboot ... 문구가 나오면

재부팅을 반드시 하세요)

 

cf) 로그인 하기 전에 CD-ROM을 삽입 한 경우

수동으로 mount  해줘야..,

 

centOS 5.x : /dev/hdc

centOS 6.x : /dev/sr0

    /dev/cdrom

 

cf) vmware하단에 CD 아이콘 불 안 깜박 거리면

오.버> connect 클릭!

 

 

 

[root@localhost ~]# cd ~itbank
[root@localhost itbank]#

// 하드디스크와 파티션  보기

[root@localhost itbank]# fdisk -l

Disk /dev/sda: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000a586b

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     2099199     1048576   83  Linux
/dev/sda2         2099200     6293503     2097152   82  Linux swap / Solaris
/dev/sda3         6293504    41943039    17824768   83  Linux

Disk /dev/sdb: 1073 MB, 1073741824 bytes, 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

[root@localhost itbank]#

// 내가 추가한 장치 보기

[root@localhost itbank]# fdisk -l /dev/sdb

Disk /dev/sdb: 1073 MB, 1073741824 bytes, 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

 

// 파티션 생성

[root@localhost itbank]# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0xd8f28c00.

Command (m for help): m
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   g   create a new empty GPT partition table
   G   create an IRIX (SGI) partition table
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)

Command (m for help): p

Disk /dev/sdb: 1073 MB, 1073741824 bytes, 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xd8f28c00

   Device Boot      Start         End      Blocks   Id  System

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-2097151, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-2097151, default 2097151): +500M
Partition 1 of type Linux and of size 500 MiB is set

Command (m for help): p

Disk /dev/sdb: 1073 MB, 1073741824 bytes, 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xd8f28c00

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048     1026047      512000   83  Linux

Command (m for help): n
Partition type:
   p   primary (1 primary, 0 extended, 3 free)
   e   extended
Select (default p): e
Partition number (2-4, default 2): 2
First sector (1026048-2097151, default 1026048):
Using default value 1026048
Last sector, +sectors or +size{K,M,G} (1026048-2097151, default 2097151): +300M
Partition 2 of type Extended and of size 300 MiB is set

Command (m for help): n
Partition type:
   p   primary (1 primary, 1 extended, 2 free)
   l   logical (numbered from 5)
Select (default p): l
Adding logical partition 5
First sector (1028096-1640447, default 1028096):
Using default value 1028096
Last sector, +sectors or +size{K,M,G} (1028096-1640447, default 1640447):
Using default value 1640447
Partition 5 of type Linux and of size 299 MiB is set

Command (m for help): p

Disk /dev/sdb: 1073 MB, 1073741824 bytes, 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xd8f28c00

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048     1026047      512000   83  Linux
/dev/sdb2         1026048     1640447      307200    5  Extended
/dev/sdb5         1028096     1640447      306176   83  Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

// 포맷

[root@localhost itbank]#
[root@localhost itbank]# mkfs -t xfs /dev/sdb1
meta-data=/dev/sdb1              isize=512    agcount=4, agsize=32000 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0, sparse=0
data     =                       bsize=4096   blocks=128000, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1

log      =internal log           bsize=4096   blocks=855, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
[root@localhost itbank]#
[root@localhost itbank]#
[root@localhost itbank]# mkfs -t xfs /dev/sdb2
mkfs.xfs: /dev/sdb2 appears to contain a partition table (dos).
mkfs.xfs: Use the -f option to force overwrite.
[root@localhost itbank]#
[root@localhost itbank]# mkfs.xfs /dev/sdb5
meta-data=/dev/sdb5              isize=512    agcount=4, agsize=19136 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0, sparse=0
data     =                       bsize=4096   blocks=76544, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal log           bsize=4096   blocks=855, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
[root@localhost itbank]#
[root@localhost itbank]#

 

// 마운트(장치 쓰기)

// 아직 장치를 쓸 수 없음..,

[root@localhost itbank]# mkdir /dev/sdb1/hello
mkdir: `/dev/sdb1/hello' 디렉토리를 만들 수 없습니다: 디렉터리가 아닙니다
[root@localhost itbank]#
[root@localhost itbank]# touch /dev/sdb1/hello
touch: cannot touch `/dev/sdb1/hello': 디렉터리가 아닙니다
[root@localhost itbank]#
[root@localhost itbank]# ls -l /dev/sdb1
brw-rw----. 1 root disk 8, 17  1월 10 13:31 /dev/sdb1        // b : block system file
[root@localhost itbank]#
[root@localhost itbank]#

[root@localhost itbank]# mkdir /mountpoint
[root@localhost itbank]#
[root@localhost itbank]# ls -l /mountpoint/
합계 0
[root@localhost itbank]#
[root@localhost itbank]# touch /mountpoint/testfile2
[root@localhost itbank]#
[root@localhost itbank]# ls -l /mountpoint
합계 0
-rw-r--r--. 1 root root 0  1월 10 14:05 testfile2
[root@localhost itbank]#
[root@localhost itbank]# ls -l /dev/sdb1
brw-rw----. 1 root disk 8, 17  1월 10 13:31 /dev/sdb1
[root@localhost itbank]#
[root@localhost itbank]# mount /dev/sdb1 /mountpoint     // /dev/sdb1 == /mountpoint
[root@localhost itbank]#
[root@localhost itbank]# ls -l /mountpoint/    
합계 0                                            // dev/sdb1으로 mount를 해서 testfile2가 사라짐
[root@localhost itbank]#

[root@localhost itbank]# touch /mountpoint/testfile1
[root@localhost itbank]#
[root@localhost itbank]# ls -l /mountpoint
합계 0
-rw-r--r--. 1 root root 0  1월 10 14:08 testfile1

 

// 현재 마운트된 목록 확인

// 1> 마운트된 detail한 목록

[root@localhost itbank]# mount | tail -1
/dev/sdb1 on /mountpoint type xfs (rw,relatime,seclabel,attr2,inode64,noquota)

or

// 2> mount  유무

[root@localhost itbank]# df -h | tail -1
/dev/sdb1       497M   26M  472M   6% /mountpoint

 

// 마운트 해지

[root@localhost itbank]# umount /dev/sdb1
or

[root@localhost itbank]# umount /mountpoint

// 확인해 보면 해지 된 것을 알 수 있다

[root@localhost itbank]# mount | tail -1        
tmpfs on /run/user/0 type tmpfs (rw,nosuid,nodev,relatime,seclabel,size=99972k,mode=700)
[root@localhost itbank]#
[root@localhost itbank]# df -h | tail -1
tmpfs            98M     0   98M   0% /run/user/0
[root@localhost itbank]#
[root@localhost itbank]# ls -l /mountpoint/
합계 0
-rw-r--r--. 1 root root 0  1월 10 14:05 testfile2
[root@localhost itbank]#
[root@localhost itbank]# ls -l /dev/sdb1
brw-rw----. 1 root disk 8, 17  1월 10 13:31 /dev/sdb1
[root@localhost itbank]#
[root@localhost itbank]#
[root@localhost itbank]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda3        17G  4.8G   13G  28% /
devtmpfs        474M     0  474M   0% /dev
tmpfs           489M     0  489M   0% /dev/shm
tmpfs           489M  7.0M  482M   2% /run
tmpfs           489M     0  489M   0% /sys/fs/cgroup
/dev/sda1      1014M  194M  821M  20% /boot
tmpfs            98M   12K   98M   1% /run/user/42
tmpfs            98M     0   98M   0% /run/user/0
[root@localhost itbank]#

 


 

// CD-ROM mount

[root@localhost ~]# mount | tail -1
/dev/sr0 on /run/media/root/CentOS 7 x86_64 type iso9660 (ro,nosuid,nodev,relatime,uid=0,gid=0,iocharset=utf8,mode=0400,dmode=0500,uhelper=udisks2)
[root@localhost ~]#
f[root@localhost ~]# df -h | tail -1
/dev/sr0        8.1G  8.1G     0 100% /run/media/root/CentOS 7 x86_64
[root@localhost ~]#
[root@localhost ~]# umount /dev/sr0
[root@localhost ~]#
[root@localhost ~]# mount | tail -1
fusectl on /sys/fs/fuse/connections type fusectl (rw,relatime)
[root@localhost ~]#
[root@localhost ~]# ls -l /dev/sr0
brw-rw----+ 1 root cdrom 11, 0  1월 10 14:30 /dev/sr0
[root@localhost ~]#
[root@localhost ~]# ls -l /dev/cdrom
lrwxrwxrwx. 1 root root 3  1월 10 14:30 /dev/cdrom -> sr0
[root@localhost ~]#
[root@localhost ~]# mount /dev/cdrom /mountpoint
mount: /dev/sr0 is write-protected, mounting read-only
[root@localhost ~]#
[root@localhost ~]# mount | tail -1
/dev/sr0 on /mountpoint type iso9660 (ro,relatime)
[root@localhost ~]#
[root@localhost ~]# df -h | tail -1
/dev/sr0        8.1G  8.1G     0 100% /mountpoint
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# cd /mountpoint/
[root@localhost mountpoint]#
[root@localhost mountpoint]# ls
CentOS_BuildTag  GPL       RPM-GPG-KEY-CentOS-7          images
EFI              LiveOS    RPM-GPG-KEY-CentOS-Testing-7  isolinux
EULA             Packages  TRANS.TBL                     repodata

// unmount

[root@localhost mountpoint]# pwd
/mountpoint

[root@localhost mountpoint]# umount /dev/cdrom
umount: /mountpoint: target is busy.
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1))
[root@localhost mountpoint]#
[root@localhost mountpoint]# cd ~itbank
[root@localhost itbank]#
[root@localhost itbank]# umount /dev/cdrom

반응형
LIST
Posted by 오정oI
, |
반응형
SMALL

* File System & Disk Management

* 목차

 

 

1> HDD(Hard Disk Drive)

- 자성체로 코팅된 알루미늄 기판에 자료를 저장할 수 있또록 만든 보조기억 장치의 한 종류

 

① 플래터(Platter)

- 하드 디스크를 구성하는 얇은 판

- 코팅 된 산화금속 막을 논리적으로 나누고(Partitioning)

   위치를 지정(formatting) 하면 정보를 저장할 수 있음

 

② 스핀들(Spindle)

- 플래터가 회전할 수 있도록 모터와 직접 연결된 축

- 플래터를 일정한 속도로 회전시키는 장치인 모터가 있고,

  HDD용 모터는 스핀들에 직접 연결되어있기 때문에 '스핀들 모터' 라고도

  부름

 

③ 해드(Head)

- 플래터 표면에 코팅된 자성체를 자화/소거하여 정보를 저장/삭제하거나

  저장된 정보를 읽는 장치

 

④ 해드구동 장치(Actuator)

- 엑츄에이터는 해드를 움직이는 장치

- 해드가 부착된 ARM(팔) 을 지정한 위치까지 이동함

 

⑤ 실린더(Cylinder)

- 다수개의 플래터의 트랙을 수직적으로 관통하는 3차원적인 스택을 말함

- 기록 밀도가 높은 곳은 그 만큼 데이터 안정에 문제가 있을 수 있음

  위 이유로 모든 섹터가 같은 길이를 갖도록 데이터를 기록하는 방식이 일반 적임

- 디스크에 중심축으로 같은 위치에 있는 트랙의 집합

 

⑥ 트랙, 섹터(Track, Sector)

- 하드디스크 기록 단위의 하나로써 자기 매체에 늘어선 동심원으로 구획된

  하나하나를 트랙이라 부르고 그 트랙들을 다시 섹터로 나눔

- 트랙은 정보가 저장되는 동심원

- 섹터는 최소 단위가 512byte (피자조각) 이고 공간낭비가 없으나 읽는 속도가 느림

=> 위 문제 해결 :

     클러스터 (섹터의 최소단위 문제점 해결)

     클러스터 : 섹터의 집합 (4kb = 4096 byte = 섹터 8개)

읽는 속도는 빠르나, 공간낭비가 있음

- 하나의 데이터만 저장 가능

 

⑦ 클러스터(Cluster)

- 섹터의 최소 단위의 문제점을 해결하기 위함

- 기본적으로 4KB

- 읽는 속도는 빨라졌으나 공간낭비가 있음 

 

2> HDD의 형식

MBR(Master Boot Record) 와 GPT(GIUD Partition Table)

- 사용할 수 있는 디스크 종류는 크게 2가지가 있음

 

1) 전통적인 BIOS(Basic Input Output System) 방식의 시스템에서 사용되고

   있는 디스크 형식인 MBR 디스크

 

2) 새롭게 개발된 EFI(Extensible Fimware Interface)방식의 시스템에서 사용되고

   있는 디스크 형식인 GPT 디스크

   (BIOS가  아니라 EFI라는 좀 더 개선된 핌웨어에서 사용함 (BIOS에서 GPT  디스크 사용불가)

    다시 말하면 디스크에 관한 정보를 담는데는  MBR이냐 GPT냐로 나뉘게 됨)

 ex> N클라우드, 서버계열, 대형 회사

=> 우리가 일반적으로 쓰고 있는건 1)

 

섹터 512byte 중,

부팅에 관한 정보를 담고 있는 440byte의 Master Boot Code 영역

파티션에 대해 정보를 담고 있는 64byte의 Partition Table 영역

 

- MBR 의 단점? (Partition 영역 4개뿐이 못 만듦..,)

Primary(주) Partition Table에 기록이 되는  파티션 엔트리(공간)는 개당 16byte로 이루어져

있음

최대  MBR Primary Partition을 4개까지만 생성할 수 있음.

GPT  디스크는 Primary Partition을 무려 128개까지 생성가능(거의 무제한)

 

MBR의 최대 파티션 생성 개수가 4개까지라는 제한으로 인해 이를 해결하기 위해서

Extended(확장) Partition과 Logical(논리) Partition을 생성해야만 4개이상 생성할 수 있음

 

C:\

 

C:\             E:\        

프로그램     부가, 중요

3 : 7

C:\ E:\ F:\

=> 관리의 효율성 위함

 

- 볼륨? 파티션과는 다른 개념임 (파티션 묶음)

 

 

3> Partitioning

- 그림

- 특징

주는 독립적임 삭제되는 데 영향 미치지 않음

 

Extended 삭제시, Logical 에 영향 있음

 

Logical을 삭제 하는 경우에는 다른 부분에 영향을 주지 않음

Logical은 Extended 사이즈를 넘을 수 없음

 

4> HDD Type

IDE(Integrated Drive Electronics : 병렬)는 CPU에서 직접관리하기 때문에 부팅 중에

(전원이 켜져 있을 때) 장착할 수 없음

hd + 문자 → hda, hdb, hdc는 CD-ROM(우리가 사용불가), hdd, ... 등등

 

SCSI(Small Computer System Interface : 직렬)는 CPU에서 직접관리하지 않고 내부에서

scsichip에서 직접관리함. 부팅 중에도 추가할 수 있으나 인식이 되지 않으므로 재부팅후에

인식가능

sd+문자 → sda, sdb, sdc, sdd, ...  등등

 

참고로

CentOS 5.x에서는 IDE HDD를 추가하면  hd+문자, SCSI HDD를 추가하면 sd+문자 사용됨

CentOS 6.x이후부터는 IDE HDD나 SCSI HDD 를 추가하면  sd+문자로만 사용 됨

 

5> Partition Type

IDE HDD(hd+문자)+숫자  →   hda1, hdb2, hdd3, hde4, ...  등등

SCSI HDD(sd+문자)+숫자 →   sda1, sdb2,  sdc3,  sdd4, ...  등등

 

 

////////////////////////////// 2018.01.10 내용 추가 //////////////////////////////

 

 

 

* Partitioning 방법

 

1. HDD 추가 (IDE)

 

poweroff> VMware> Edit virtual machine> settings> add> 예>

Hard Disk  클릭> IDE 체크> Create a new virtual disk  클릭>

Maximum disk size : 1.0 GB> Disk file(기본값)> Finish> 확인 후 OK

 

2. HDD 삭제

 

poweroff> Edit virtual machine> settings> 삭제할 HDD를 선택>

Remove> OK

 

3. HDD  확인

 

사용형식

fdisk [option]

fdisk [option] 장치명

 

option

-l :  하드디스크와 파티션 목록

 

 

4. 파티션 생성

 

사용형식

fdisk 장치

 

fdisk에서 사용할 명령어들

d는 파티션 삭제

l은 파티션 타입 리스트

m은 도움말 출력

n은 파티션 생성

p는 파티션 테이블 출력

q는 저장하지 않고 종료

t는 파티션의 시스템 ID 변경

w는 저장하고 종료

 

1) Primary(주) Partition 생성

n → p 또는  enter → 파티션 번호는 생성하는 순서대로 잡아주는 것이 좋음(1 또는 enter)

→ 첫 번째 섹터는 기본값대로  → 마지막 섹터는 용량으로 하는게 편함(용량은 +용량단위) +500M

 

2) Extened(확장)

Partition 생성

n → e → 파티션 번호 순서대로(2 또는 enter) → 첫번째 섹터는 기본값으로(enter)

→ 마지막 섹터는 용량으로(+용량단위) +300M

 

3) Logical(논리)

Partition 생성

n →  l → 파티션 번호는 무조건 5번(이상) → 첫번째 섹터는 기본값으로(enter)

→ 마지막 섹터는 용량으로(+ 용량단위) 또는 용량으로 enter(남은 용량 다 잡아라)

→ enter

 

 

삭제시 d

Partition num : 2

확장(extended) 지우면 logical 도 같이 지워짐

 

p

sdb1 : HDD명+partition num,

End : sector

Blocks :  용량

ID : 리눅스 시스템 고유 번호, 83

 

확장은 System의 Extended

논리는 Device Boot의 /dev/sdb5 => 5번부터인것 확인~!

 

 

5. 포맷(Make File System)

 

사용형식

mkfs [option]  인자값 장치(파티션)

또는

mkfs. 인자값 장치(파티션)

 

option

-t : type.

 

인자값

 xfs    // centos7 에서 쓰는 파일 시스템 (windows에서 NTFS; FAT32(기본값) : 4GB 이상은 못 받음)

 

cf. 포맷 대상

p(주), l(논리)

p는 포맷이 되는데

e는 포맷이 안됨(사용할 수 있는 공간이 아님)

 

(참고!

CentOS 5.x  포맷 방법

mkfs -t ext3 장치(파티션)

또는

 mkfs.ext3 장치(파티션)

 

CentOS 6.x 포맷 방법

mkfs -t ext4 장치(파티션)

또는

mkfs.ext4  장치(파티션)  )

 

 

6. 마운트(mount)

- 파일 시스템을 디렉터리 일부에 넣어서 이용가능하게 하는 작업

마치, 디렉터리처럼 사용하는 것을 마운트라 할 수 있음

- 서버의 자원을 사용하는 것이므로 관리자만 사용가능

- 장치파일을 디렉터리화 함

 

ㆍ사용형식(mount 장착)

mount 장치(파티션) 임의의 디렉터리(mount point)

mount

→ 마운트 된 목록을 출력

 

 

ㆍ사용형식(mount 장착해제)

umount 장치(파티션)

또는

umount 임의의 디렉터리(mount point)

 

ㆍ별도로 mount 상태 확인할 때   df -h를 사용함

df(명령어)는 디스크 공간 확인

-h은 사람이 보기 편하게 출력

 

!  mount 주의사항

 

1)  mount를 할 때 하나의 장치나 파티션은 반드시 하나의 임의의 디렉터리(mount point)를

사용해야 함

(예를 들어, 1개의 장치를 사용할 때 여러 개의 mount point를 사용할 필요가 없으며, 여러

개의 장치를 하나의 mount point로  mount 해서는 안 됨)

 

2) umount를 할 때 반드시 mount point에 있어선 안 됨

(예를 들어,  mount point나 그 하위에 있으면 umount가 안됨. 그래서 mount point가 아닌

곳으로 변경해야 함)

 

3) mount를 할 때 Primary Partition과 Logical Partition만 해당 됨    // 포맷이 되니까

(Extended Partition은 mount  할 수 없음)        // 포맷이 안되니까

 

4) mount를 할 때 반드시 기존에 사용중인 디렉터리로 mount 해서는 안 됨

(예를 들어, 사용자 홈 디렉터리 X 기존에 사용중인 /home/itbank 로 하지마!!!

mkdir로 새로 만들것! )

 

ex>

 장치파일    

 디렉터리

 /dev/sdb1

 /a 

 

   귀신  →  어떤 사람

             mount

           ↑ 빙의

Driver

S/W ↔ H/W

 

☆ CD-ROM 사용 방법

먼저 iso image file을 삽입!

: VM> Settings> CD/DVD => C:0_CentOS7>ISO

사용형식
mount /dev/sr0(원본파일) 임의의 디렉터리(mount point)
또는
mount /dev/cdrom(바로가기) 임의의 디렉터리(mount point)

 

(참고로

The partition table has been altered!        // w 눌렀을 때??

 

Calling ioctl() to re-read partition table.

Syncing disks.

 

위 문구 사이에... The new table will be used at the next reboot ... 문구가 나오면

재부팅을 반드시 하세요)

 

cf) 로그인 하기 전에 CD-ROM을 삽입 한 경우

수동으로 mount  해줘야..,

 

centOS 5.x : /dev/hdc

centOS 6.x : /dev/sr0

    /dev/cdrom

 

cf) vmware하단에 CD 아이콘 불 안 깜박 거리면

오.버> connect 클릭!

 

 

 

// hdd 추가

Virtual Machine Settings> Add...> Hard Disk>

SCSI> default> 1 입력> Finish> OK

[root@localhost ~]# cd ~itbank
[root@localhost itbank]#

// 하드디스크와 파티션  보기 (all)

[root@localhost itbank]# fdisk -l

Disk /dev/sda: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000a586b

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     2099199     1048576   83  Linux
/dev/sda2         2099200     6293503     2097152   82  Linux swap / Solaris
/dev/sda3         6293504    41943039    17824768   83  Linux

Disk /dev/sdb: 1073 MB, 1073741824 bytes, 2097152 sectors    
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

[root@localhost itbank]#

// 내가 추가한 장치 보기

[root@localhost itbank]# fdisk -l /dev/sdb

Disk /dev/sdb: 1073 MB, 1073741824 bytes, 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

 

// 파티션 생성

[root@localhost itbank]# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0xd8f28c00.

Command (m for help): m
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   g   create a new empty GPT partition table
   G   create an IRIX (SGI) partition table
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)

Command (m for help): p

Disk /dev/sdb: 1073 MB, 1073741824 bytes, 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xd8f28c00

   Device Boot      Start         End      Blocks   Id  System

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-2097151, default 2048):     Enter
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-2097151, default 2097151): +500M
Partition 1 of type Linux and of size 500 MiB is set

Command (m for help): p

Disk /dev/sdb: 1073 MB, 1073741824 bytes, 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xd8f28c00

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048     1026047      512000   83  Linux

/////

sdb1 : HDD명+partition num,

End : sector

Blocks :  용량

ID : 리눅스 시스템 고유 번호, 83

/////

Command (m for help): n
Partition type:
   p   primary (1 primary, 0 extended, 3 free)
   e   extended
Select (default p): e
Partition number (2-4, default 2): 2
First sector (1026048-2097151, default 1026048):   Enter
Using default value 1026048
Last sector, +sectors or +size{K,M,G} (1026048-2097151, default 2097151): +300M
Partition 2 of type Extended and of size 300 MiB is set

Command (m for help): p

Disk /dev/sdb: 1073 MB, 1073741824 bytes, 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xdd30b289

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048     1026047      512000   83  Linux
/dev/sdb2         1026048     1640447      307200    5  Extended

Command (m for help): n
Partition type:
   p   primary (1 primary, 1 extended, 2 free)
   l   logical (numbered from 5)
Select (default p): l
Adding logical partition 5
First sector (1028096-1640447, default 1028096):   Enter
Using default value 1028096
Last sector, +sectors or +size{K,M,G} (1028096-1640447, default 1640447):   Enter
Using default value 1640447
Partition 5 of type Linux and of size 299 MiB is set

Command (m for help): p

Disk /dev/sdb: 1073 MB, 1073741824 bytes, 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xd8f28c00

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048     1026047      512000   83  Linux
/dev/sdb2        1026048     1640447     307200     5  Extended
/dev/sdb5        1028096     1640447     306176   83  Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

// 하드디스크와 파티션 목록 확인

[root@localhost ~]# fdisk -l /dev/sdb

Disk /dev/sdb: 1073 MB, 1073741824 bytes, 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xdd30b289

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048     1026047      512000   83  Linux
/dev/sdb2         1026048     1640447      307200    5  Extended
/dev/sdb5         1028096     1640447      306176   83  Linux

 

// 포맷

 

cf. 포맷 대상

p(주), l(논리)

p는 포맷이 되는데

e는 포맷이 안됨(사용할 수 있는 공간이 아님)

[root@localhost itbank]#
[root@localhost itbank]# mkfs -t xfs /dev/sdb1
meta-data=/dev/sdb1              isize=512    agcount=4, agsize=32000 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0, sparse=0
data     =                       bsize=4096   blocks=128000, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1

log      =internal log           bsize=4096   blocks=855, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
[root@localhost itbank]#
[root@localhost itbank]#
[root@localhost itbank]# mkfs -t xfs /dev/sdb2    //Extended는 포맷 대상이 아님!
mkfs.xfs: /dev/sdb2 appears to contain a partition table (dos).
mkfs.xfs: Use the -f option to force overwrite.
[root@localhost itbank]#
[root@localhost itbank]# mkfs.xfs /dev/sdb5
meta-data=/dev/sdb5              isize=512    agcount=4, agsize=19136 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0, sparse=0
data     =                       bsize=4096   blocks=76544, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal log           bsize=4096   blocks=855, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
[root@localhost itbank]#
[root@localhost itbank]#

 

// 마운트(장치 쓰기)

=> 아직 장치를 쓸 수 없음..,

=> 장치파일을 디렉터리화 함

[root@localhost itbank]# mkdir /dev/sdb1/hello
mkdir: `/dev/sdb1/hello' 디렉토리를 만들 수 없습니다: 디렉터리가 아닙니다    // 아직 장치를 쓸 수 없음!
[root@localhost itbank]#
[root@localhost itbank]# touch /dev/sdb1/hello
touch: cannot touch `/dev/sdb1/hello': 디렉터리가 아닙니다
[root@localhost itbank]#
[root@localhost itbank]# ls -l /dev/sdb1
b
rw-rw----. 1 root disk 8, 17  1월 10 13:31 /dev/sdb1        // b : block system file
[root@localhost itbank]#
[root@localhost itbank]#

// 장치 마운트할 dir. 생성

[root@localhost itbank]# mkdir /mountpoint
[root@localhost itbank]#
[root@localhost itbank]# ls -ld /mountpoint
drwxr-xr-x 2 root root 6  1월 24 22:32 /mountpoint

[root@localhost itbank]#
[root@localhost itbank]# touch /mountpoint/testfile2
[root@localhost itbank]#
[root@localhost itbank]# ls -l /mountpoint
합계 0
-rw-r--r--. 1 root root 0  1월 10 14:05 testfile2        // 현재 /mountpoint dir. 에 testfile2 file 존재
[root@localhost itbank]#
[root@localhost itbank]# ls -l /dev/sdb1
brw-rw----. 1 root disk 8, 17  1월 10 13:31 /dev/sdb1
[root@localhost itbank]#
[root@localhost itbank]# mount /dev/sdb1 /mountpoint     // /dev/sdb1 == /mountpoint
[root@localhost itbank]#
[root@localhost itbank]# ls -l /mountpoint/    
합계 0                                            // dev/sdb1으로 mount를 해서 testfile2가 사라짐
[root@localhost itbank]#

[root@localhost itbank]# touch /mountpoint/testfile1
[root@localhost itbank]#
[root@localhost itbank]# ls -l /mountpoint
합계 0
-rw-r--r--. 1 root root 0  1월 10 14:08 testfile1

 

// 현재 마운트된 목록 확인

// 1> 마운트된 detail한 목록

[root@localhost itbank]# mount | tail -1
/dev/sdb1 on /mountpoint type xfs (rw,relatime,seclabel,attr2,inode64,noquota)

or

// 2> mount  유무

[root@localhost itbank]# df -h | tail -1
/dev/sdb1       497M   26M  472M   6% /mountpoint

 

// 마운트 해지

[root@localhost itbank]# umount /dev/sdb1

or

[root@localhost itbank]# umount /mountpoint

 

// 확인해 보면 해지 된 것을 알 수 있다

[root@localhost itbank]# mount | tail -1        
tmpfs on /run/user/0 type tmpfs (rw,nosuid,nodev,relatime,seclabel,size=99972k,mode=700)
[root@localhost itbank]#
[root@localhost itbank]# df -h | tail -1
tmpfs            98M     0   98M   0% /run/user/0
[root@localhost itbank]#
[root@localhost itbank]# ls -l /mountpoint/
합계 0
-rw-r--r--. 1 root root 0  1월 10 14:05 testfile2    // mount하기전 만든 파일 존재 => mount할 dir은 비어있는 거로 하기!
[root@localhost itbank]#
[root@localhost itbank]# ls -l /dev/sdb1
brw-rw----. 1 root disk 8, 17  1월 10 13:31 /dev/sdb1    
[root@localhost itbank]#
[root@localhost itbank]#
[root@localhost itbank]# df -h
Filesystem      Size  Used Avail Use% Mounted on    // mount 장치 빠진 것 확인?
/dev/sda3        17G  4.8G   13G  28% /
devtmpfs        474M     0  474M   0% /dev
tmpfs           489M     0  489M   0% /dev/shm
tmpfs           489M  7.0M  482M   2% /run
tmpfs           489M     0  489M   0% /sys/fs/cgroup
/dev/sda1      1014M  194M  821M  20% /boot
tmpfs            98M   12K   98M   1% /run/user/42
tmpfs            98M     0   98M   0% /run/user/0
[root@localhost itbank]#

[root@localhost itbank]# mount /dev/sdb1 /mountpoint
[root@localhost itbank]#
[root@localhost itbank]# df -h | tail -1
/dev/sdb1       497M   26M  472M   6% /mountpoint
[root@localhost itbank]#
[root@localhost itbank]# umount /mountpoint/
[root@localhost itbank]#
[root@localhost itbank]# df -h | tail -1
tmpfs            98M   28K   98M   1% /run/user/0

 

// CD-ROM mount ( 위에 ☆ CD-ROM 사용 방법 참고)

// mount된 목록 출력

[root@localhost ~]# mount | tail -1
/dev/sr0 on /run/media/root/CentOS 7 x86_64 type iso9660 (ro,nosuid,nodev,relatime,uid=0,gid=0,iocharset=utf8,mode=0400,dmode=0500,uhelper=udisks2)
[root@localhost ~]#

// mount 상태 확인

[root@localhost ~]# df -h | tail -1
/dev/sr0        8.1G  8.1G     0 100% /run/media/root/CentOS 7 x86_64
[root@localhost ~]#

// unmount

[root@localhost ~]# umount /dev/sr0
[root@localhost ~]#
[root@localhost ~]# mount | tail -1
fusectl on /sys/fs/fuse/connections type fusectl (rw,relatime)
[root@localhost ~]#

// mount 장치 2가지 (둘 중에 아무거나 써도 됨)

[root@localhost ~]# ls -l /dev/sr0    // 원본
brw-rw----+ 1 root cdrom 11, 0  1월 10 14:30 /dev/sr0
[root@localhost ~]# ls -l /dev/cdrom // 바로가기
lrwxrwxrwx. 1 root root 3  1월 10 14:30 /dev/cdrom -> sr0    // 바로가기 → 원본
// ex> ln -s 원본 바로가기

// cdrom mount

[root@localhost itbank]# mkdir /mountpoint
[root@localhost itbank]#
[root@localhost itbank]# ls -ld /mountpoint
drwxr-xr-x 2 root root 6  1월 24 22:32 /mountpoint

[root@localhost ~]# mount /dev/cdrom /mountpoint
mount: /dev/sr0 is write-protected, mounting read-only
[root@localhost ~]#

// mount 상태 확인

[root@localhost ~]# mount | tail -1
/dev/sr0 on /mountpoint type iso9660 (ro,relatime)
[root@localhost ~]#
[root@localhost ~]# df -h | tail -1
/dev/sr0        8.1G  8.1G     0 100% /mountpoint
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# cd /mountpoint/
[root@localhost mountpoint]#
[root@localhost mountpoint]# ls
CentOS_BuildTag  GPL       RPM-GPG-KEY-CentOS-7          images
EFI              LiveOS    RPM-GPG-KEY-CentOS-Testing-7  isolinux
EULA             Packages  TRANS.TBL                     repodata

// unmount

[root@localhost mountpoint]# pwd
/mountpoint

[root@localhost mountpoint]# umount /dev/cdrom
umount: /mountpoint: target is busy.        // mountpt. 가 아닌 곳으로 나가야..,
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1))
[root@localhost mountpoint]#
[root@localhost mountpoint]# cd ~itbank
[root@localhost itbank]#
[root@localhost itbank]# umount /dev/cdrom

반응형
LIST
Posted by 오정oI
, |
반응형
SMALL

* rpm vs. yum

    (자동)         (수동)

패키지는 rpm 이 관리

rpm의존성은 yum이 해결 

yum은 인터넷이 되야..,

yum이 안되는 부분이 있으면, rpm을 이용해 내가 직접 설치해야..,

yum은 패키지명을 정확히 알아야 써먹을 수 있음

 

 

* YUM(Yello dog Updater Modified)

 

cf) 공유폴더 :  \\192.168.46.46 

 

1> YUM 이란

RPM 기반의 시스템을 위한 패키지 설치/제거 및 자동 업데이트 도구(툴)

(참고로  Windows OS 에서 Windows Update 와 비슷함)

 

/etc/yum.conf

- YUM의 환경설정 파일

 

/etc/yum.repos.d

- YUM과 관련된 파일들을 저장하고 있는 디렉터리

 

/var/log/yum.log

- YUM의 기록이 저장되는 파일

 

/usr/bin/yum

- YUM의 실행파일

 

[사용형식]

yum list

→ 업데이트 가능한 패키지 목록을 확인

 

yum update

→ 패키지를 업데이트 함

 

사용형식(패키지 설치)

yum [option] install 패키지명

 

option

-y : 물어보지 않음

 

사용형식(패키지 삭제)

yum [option] remove 패키지명

 

option

-y : 물어보지 않음

 

 

 

 

 

 

* RPM(Redhat Package Manager)

 

1> rpm 이란

- Redhat 계열 리눅스는 패키지의 설치와 관리에 있어서 rpm이라는 명령어를 사용함

- rpm은 어떤 패키지를 설치하고, 어떤 프로그램들이 있는지 확인하고, 어떤 구조로 되어있는가를 알 수 있게 함

 

리눅스는 오픈 소스로써 원래 소스를 직접 컴파일해서 사용.

그런데 그 과정이 복잡하고 사용하기 어려움이 있으므로 편리하게 사용하기 위해

미리 소스를 컴파일하여 만들어 놓은 패키지를 제공함.

 

마치, Windows에서 setup.exe와 비슷함. 패키지를 설치하면 바로 실행할 수 있음

리눅스 운영체제에 서비스를 깜

 

Package 설명

[준비물]

# rpm -qa | grep vim

[root@localhost itbank]# rpm -qa | grep vim
vim-common-7.4.160-2.el7.x86_64.rpm                // 이미 깔린거라 .rpm이 안나옴
vim-enhanced-7.4.160-2.el7.x86_64
vim-minimal-7.4.160-2.el7.x86_64
vim-filesystem-7.4.160-2.el7.x86_64

=> 해당 패키지에 버전은 다 동일하게 맞춰줘야..,

 

vim-common, vim-enhanced, vim-minimal, vim-filesystem 은 패키지명 (문자 마지막)

vim은 대표패키지명

 

7.4.160-2.el7는 버전(version)

 

7은 주(major) 버전

- 프로그램 자체가 완전히 변경되었을 경우 변경 됨

ex) windows  운영체제, VMware 프로그램

 

4는 보조(하위, minor) 버전

- 기능에 추가가 있을 경우 변경

ex) windows  운영체제에서 home edition, brood war(starcraft)

 

160은 패치(patch)

- 기존 기능에서 버그가 수정되는 경우(부분 오류 수정)

 

2.el7은 release(배포)

- 수정을 하지 않은 한도내에서 배포측에서 얼마만큼 배포를 했는지 알려줌

 

x86_64는 시스템 아키텍처(CPU, 메모리 크기(인식, 처리량)

 

x86_64는 64bit

i686은 32bit

noarch는 시스템 아키텍처를 따지지 않겠음  (bit 안따짐)

 

rpm은 rpm이라는 확장자로써 rpm파일이라는 것을 의미

 

// 준비물

# rm -rf /home/*

# ls -l

itbank~

 

 

2> rpm 명령어 사용해서 패키지 설치

 

사용형식

rpm [option] 패키지명-버전.시스템아키텍처.rpm

 

option

-i :  install. centos 7 에 없는 패키지를 설치할 때  ★ 필수

-v : verbose. tar에서 v(visual)와 같은 의미.

-h : hash. 설치할 때 '#'으로 표현함

 

3> rpm  명령어 사용해서 패키지 삭제

 

 사용형식

rpm [option] 패키지명

 

option

-e : erase. centos7에 설치되어 있는 패키지를 삭제할 때

 

4> rpm  명령어로 패키지 설치/삭제 확인

패키지 삭제시 경로는 상관 없는데

패키지 설치시 패키지가 있는 경로에서 다운받아야 됨!

 

사용형식

rpm [option]

 

option

-qa : centos 7에 설치되어 있는 모든 패키지를 조회 (all)

-ql : 패키지의 파일 리스트를 조회 (list)

-qf : 파일이 어느 패키지에 속해 있는지 조회 (file)

-qi : 패키지의 정보를 조회 (information)

 

-q는 query(질의)

--nodeps : 의존성을 검사 하지 않음(무시)

--force : 강제

-U : Upgrade. 기존에 패키지가 설치되어 있는 경우에 버전을

업그레이드하거나 다운그레이드 할 때

--oldpackage : 다운그레이드할 때

 

- 아래에 방법을 자주 사용함

rpm -qa | grep 대표 패키지명

- grep  명령어는 문자열을 검색

 

// vim 패키지 확인

[root@localhost ~]# rpm -qa | grep vim
vim-common-7.4.160-2.el7.x86_64
vim-enhanced-7.4.160-2.el7.x86_64
vim-minimal-7.4.160-2.el7.x86_64
vim-filesystem-7.4.160-2.el7.x86_64

 

// vim 패키지 삭제

// 삭제 시 순서대로 할 것~!!!

// Failed dependencies : installed 기준 오른쪽 패키지 먼저 삭제~!

 

# rpm -e vim-common

Failed dependencies ~ installed vim-enhanced

# rpm -e vim-enhanced

# rpm -e vim-common

[root@localhost ~]# rpm -qa | grep vim
vim-minimal-7.4.160-2.el7.x86_64
vim-filesystem-7.4.160-2.el7.x86_64
[root@localhost ~]#
[root@localhost ~]# rpm -e vim-minimal
오류: Failed dependencies:
        vim-minimal is needed by (installed) sudo-1.8.19p2-11.el7_4.x86_64
[root@localhost ~]#
[root@localhost ~]# rpm -e sudo
[root@localhost ~]#
[root@localhost ~]# rpm -e vim-minimal
[root@localhost ~]#
[root@localhost ~]# rpm -qa | grep vim
vim-filesystem-7.4.160-2.el7.x86_64
[root@localhost ~]#
[root@localhost ~]# rpm -e vim-filesystem
[root@localhost ~]#
[root@localhost ~]# rpm -qa | grep vim

[root@localhost ~]# vi            
bash: vi: 명령을 찾을 수 없습니다...  // vi 관련  패키지임

//  vim 패키지 재 설치

// Centos mirror site에서 패키지 다운로드

http://mirror.navercorp.com/centos/7.4.1708/os/x86_64/Packages/

ctrl + f : vim-*    // vim으로 시작되는 애들 다 다운

// 패키지 삭제시 경로는 상관 없는데

// 패키지 설치시 패키지가 있는 경로에서 다운받아야 됨!

[root@localhost ~]# cd
[root@localhost ~]#
[root@localhost ~]# pwd
/root
[root@localhost ~]#
[root@localhost ~]# ls
anaconda-ks.cfg       공개      문서      비디오  서식
initial-setup-ks.cfg  다운로드  바탕화면  사진    음악
[root@localhost ~]#
[root@localhost ~]# cd 다운로드/
드[root@localhost 다운로드]#
드[root@localhost 다운로드]# ls
vim-X11-7.4.160-2.el7.x86_64.rpm       vim-filesystem-7.4.160-2.el7.x86_64.rpm
vim-common-7.4.160-2.el7.x86_64.rpm    vim-minimal-7.4.160-2.el7.x86_64.rpm
vim-enhanced-7.4.160-2.el7.x86_64.rpm

드[root@localhost 다운로드]#
드[root@localhost 다운로드]# rpm -i vim-X11-7.4.160-2.el7.x86_64.rpm
오류: Failed dependencies:
        vim-common = 2:7.4.160-2.el7 is needed by vim-X11-2:7.4.160-2.el7.x86_64
드[root@localhost 다운로드]#
드[root@localhost 다운로드]# rpm -i vim-common-7.4.160-2.el7.x86_64.rpm
오류: Failed dependencies:
        vim-filesystem is needed by vim-common-2:7.4.160-2.el7.x86_64
드[root@localhost 다운로드]#
드[root@localhost 다운로드]# rpm -i vim-filesystem-7.4.160-2.el7.x86_64.rpm
드[root@localhost 다운로드]#
드[root@localhost 다운로드]# rpm -iv vim-common-7.4.160-2.el7.x86_64.rpm
Preparing packages...
vim-common-2:7.4.160-2.el7.x86_64
드[root@localhost 다운로드]#
드[root@localhost 다운로드]# rpm -ivh vim-X11-7.4.160-2.el7.x86_64.rpm
준비 중...                         ################################# [100%]
Updating / installing...
   1:vim-X11-2:7.4.160-2.el7          ################################# [100%]
드[root@localhost 다운로드]#
드[root@localhost 다운로드]# rpm -ivh vim-enhanced-7.4.160-2.el7.x86_64.rpm
준비 중...                         ################################# [100%]
Updating / installing...
   1:vim-enhanced-2:7.4.160-2.el7     ################################# [100%]
드[root@localhost 다운로드]#
드[root@localhost 다운로드]# rpm -ivh vim-minimal-7.4.160-2.el7.x86_64.rpm
준비 중...                         ################################# [100%]
Updating / installing...
   1:vim-minimal-2:7.4.160-2.el7      ################################# [100%]
드[root@localhost 다운로드]#
드[root@localhost 다운로드]# rpm -qa | grep vim
vim-enhanced-7.4.160-2.el7.x86_64
vim-filesystem-7.4.160-2.el7.x86_64
vim-minimal-7.4.160-2.el7.x86_64
vim-common-7.4.160-2.el7.x86_64
vim-X11-7.4.160-2.el7.x86_64
드[root@localhost 다운로드]#
드[root@localhost 다운로드]# vi
드[root@localhost 다운로드]#
드[root@localhost 다운로드]# rm -rf *
드[root@localhost 다운로드]#
드[root@localhost 다운로드]# ls
드[root@localhost 다운로드]#
드[root@localhost 다운로드]# cd /home/itbank/

 

5> rpm 작업 시 요령

1) 패키지 작업시 반드시 동일한 버전이어야 함

2) 의존성 오류(Failed Dependencies)를 절대로 무시하면 안 됨

3) 의존성 오류를 제기한 패키지를 먼저 작업함

4) 'lib' 으로 시작하고 중간에 'so'가 있으면 일단 보류!        // 패키지가 아님?

'lib'으로 시작하고 중간에 'so'가 없는 패키지를 먼저 작업함

계속해서 'lib'으로 시작하고 중간에 'so'가 나타나면 그때 작업

5) 디렉터리로(/usr/bin) 시작하는 경우에는 패키지가 아니므로 무시함

6) 모든 작업은 반드시 대표패키지부터 작업을 함

7) 작업하면서 나머지 패키지는 보이는 순서대로 작업을 함

 

 

* 기타 설정

프로그램> 시스템 도구> 설정> 전원> 빈 화면 - 안함 설정

 

* 실습 1

// mariadb 삭제 관련 package 받아서 재 설치

 

[쌤 풀이]

- 관련 사이트 : http://mirror.navercorp.com/centos/7.4.1708/os/x86_64/Packages/

 

// 1> 삭제

# cd /root/다운로드/

# pwd

/root/다운로드
드[root@localhost 다운로드]# rpm -e mariadb-libs

 의존성 뜸

(installed) 오른쪽 패키지 삭제 => postfix

드[root@localhost 다운로드]#  rpm -e postfix

드[root@localhost 다운로드]# rpm -e mariadb-libs

드[root@localhost 다운로드]# rpm -qa | grep mariadb

 

// 2> mariadb  패키지 설치

// ctrl + f : mariadb

// x86_64 아키텍처로 8개 다운받을 것!

[   ] mariadb-5.5.56-2.el7.x86_64.rpm                                                    11-Aug-2017 03:13  8.7M 
[   ] mariadb-bench-5.5.56-2.el7.x86_64.rpm                                              11-Aug-2017 03:13  388K 
[   ] mariadb-devel-5.5.56-2.el7.x86_64.rpm                                              11-Aug-2017 03:14  752K 
[   ] mariadb-embedded-5.5.56-2.el7.x86_64.rpm                                           11-Aug-2017 03:14  3.6M 
[   ] mariadb-embedded-devel-5.5.56-2.el7.x86_64.rpm                                     11-Aug-2017 03:14  7.4M 
[   ] mariadb-libs-5.5.56-2.el7.x86_64.rpm                                               11-Aug-2017 03:14  757K 
[   ] mariadb-server-5.5.56-2.el7.x86_64.rpm                                             11-Aug-2017 03:14   11M 
[   ] mariadb-test-5.5.56-2.el7.x86_64.rpm                                               11-Aug-2017 03:15  8.1M 

드[root@localhost 다운로드]# ls

// 왼쪽 기준 설치

 

드[root@localhost 다운로드]# rpm -ivh mariadb-5.5.56-2.el7.x86_64.rpm

의존성

설치 시 왼쪽 => mariadb-libs // 대표 패키지

드[root@localhost 다운로드]# rpm -ivh mariadb-libs-5.5.56-2.el7.x86_64.rpm    // (○)

드[root@localhost 다운로드]# rpm -ivh mariadb-5.5.56-2.el7.x86_64.rpm         // (○)

드[root@localhost 다운로드]# rpm -ivh mariadb-bench-5.5.56-2.el7.x86_64.rpm

의존성 => perl(GD)

[   ] perl-GD-2.49-3.el7.x86_64.rpm                                                      04-Jul-2014 13:18  173K 

드[root@localhost 다운로드]# rpm -ivh perl-GD-2.49-3.el7.x86_64.rpm         //(ㅁ)

드[root@localhost 다운로드]# rpm -ivh mariadb-bench-5.5.56-2.el7.x86_64.rpm //(O)

 

드[root@localhost 다운로드]# rpm -ivh  mariadb-devel-5.5.56-2.el7.x86_64.rpm //(O)                                            

/////////////////// ↓↓↓↓ 의존성 리스트

의존성 =>  openssl-devel

 openssl-devel-1.0.2k-8.el7.x86_64.rpm                                              11-Aug-2017 03:37  1.5M

드[root@localhost 다운로드]# rpm -ivh openssl-devel-1.0.2k-8.el7.x86_64.rpm  //(ㅁ)    

의존성 =>   krb5-devel ★    // (ㅁ)

    => zlib-devel    ☆    // (ㅁ)     

 

// [   ] krb5-devel-1.15.1-8.el7.x86_64.rpm                                                 11-Aug-2017 01:54  266K 

// [   ] zlib-devel-1.2.7-17.el7.x86_64.rpm                                                 21-Nov-2016 06:05   50K                         

드[root@localhost 다운로드]# rpm -ivh [   ] krb5-devel-1.15.1-8.el7.x86_64.rpm  

의존성 => 5개 뜸..,

1) keyutils-libs-devel        //(ㅁ)

2) libcom_err-devel         //(ㅁ)

3) libkadm5                  //(ㅁ)

4) libselinux-devel    => 의존성  //(ㅁ)

     1) libsepol-devel        //(ㅁ) ?? 계속 의존성 뜸

     2) pkgconfig(libpcre)  // 이미 설치.., rpm -qa | grep pkgconfig

ctrl + f : pcre // 얘 또한 이미 설치되어 있음..,

[   ] pcre-8.32-17.el7.x86_64.rpm                                                        11-Aug-2017 04:00  422K

     3) pkgconfig(libsepol)  // 이미 설치되어 있음

[   ] libsepol-2.5-6.el7.x86_64.rpm                                                      21-Nov-2016 04:10  288K 

# rpm -qa | grep libsepol

=> libsepol-devel 설치

# rpm -qa | grep pcre

5) libverto-devel

///////////////////

 

 

# rpm -ivh mariadb-server-5.5.56-2.el7.x86_64.rpm // (○)

의존성 => perl-DBD-MySQL

# rpm -ivh mariadb-test-5.5.56-2.el7.x86_64.rpm  // (○)

의존성 => perl(Env)

          => perl-Test-More => perl-Test-Simple

 

드[root@localhost 다운로드]# rpm -qa | grep mariadb | nl
     1  mariadb-5.5.56-2.el7.x86_64
     2  mariadb-devel-5.5.56-2.el7.x86_64
     3  mariadb-libs-5.5.56-2.el7.x86_64
     4  mariadb-bench-5.5.56-2.el7.x86_64
     5  mariadb-embedded-devel-5.5.56-2.el7.x86_64
     6  mariadb-test-5.5.56-2.el7.x86_64
     7  mariadb-embedded-5.5.56-2.el7.x86_64
     8  mariadb-server-5.5.56-2.el7.x86_64

 

[내가 한거]

[root@localhost itbank]# rpm -qa | grep mariadb
mariadb-libs-5.5.56-2.el7.x86_64
[root@localhost itbank]#

// 삭제

[root@localhost itbank]# rpm -qa | grep mariadb
mariadb-libs-5.5.56-2.el7.x86_64
[root@localhost itbank]#
[root@localhost itbank]# rpm -e mariadb-libs-5.5.56-2.el7.x86_64
오류: Failed dependencies:
        libmysqlclient.so.18()(64bit) is needed by (installed) postfix-2:2.10.1-6.el7.x86_64
        libmysqlclient.so.18(libmysqlclient_18)(64bit) is needed by (installed) postfix-2:2.10.1-6.el7.x86_64
[root@localhost itbank]#
[root@localhost itbank]# rpm -e postfix-2:2.10.1-6.el7.x86_64
[root@localhost itbank]#
[root@localhost itbank]# rpm -e mariadb-libs-5.5.56-2.el7.x86_64
[root@localhost itbank]#
[root@localhost itbank]# rpm -qa | grep mariadb
[root@localhost itbank]#
[root@localhost itbank]#

// mariadb-* 관련 패키지 다운

http://mirror.navercorp.com/centos/7.4.1708/os/x86_64/Packages/

[   ] mariadb-5.5.56-2.el7.x86_64.rpm                                                    11-Aug-2017 03:13  8.7M 
[   ] mariadb-bench-5.5.56-2.el7.x86_64.rpm                                              11-Aug-2017 03:13  388K 
[   ] mariadb-devel-5.5.56-2.el7.i686.rpm                                                11-Aug-2017 03:14  752K 
[   ] mariadb-devel-5.5.56-2.el7.x86_64.rpm                                              11-Aug-2017 03:14  752K 
[   ] mariadb-embedded-5.5.56-2.el7.i686.rpm                                             11-Aug-2017 03:14  3.6M 
[   ] mariadb-embedded-5.5.56-2.el7.x86_64.rpm                                           11-Aug-2017 03:14  3.6M 
[   ] mariadb-embedded-devel-5.5.56-2.el7.i686.rpm                                       11-Aug-2017 03:14  7.4M 
[   ] mariadb-embedded-devel-5.5.56-2.el7.x86_64.rpm                                     11-Aug-2017 03:14  7.4M 
[   ] mariadb-libs-5.5.56-2.el7.i686.rpm                                                 11-Aug-2017 03:14  756K 
[   ] mariadb-libs-5.5.56-2.el7.x86_64.rpm                                               11-Aug-2017 03:14  757K 
[   ] mariadb-server-5.5.56-2.el7.x86_64.rpm                                             11-Aug-2017 03:14   11M 
[   ] mariadb-test-5.5.56-2.el7.x86_64.rpm                                               11-Aug-2017 03:15  8.1M 

 

[root@localhost /]# cd
[root@localhost ~]#
[root@localhost ~]# ls
anaconda-ks.cfg       공개      문서      비디오  서식
initial-setup-ks.cfg  다운로드  바탕화면  사진    음악
[root@localhost ~]#
[root@localhost ~]# cd 다운로드/
드[root@localhost 다운로드]#
드[root@localhost 다운로드]# ls
mariadb-5.5.56-2.el7.x86_64.rpm
mariadb-bench-5.5.56-2.el7.x86_64.rpm
mariadb-devel-5.5.56-2.el7.i686.rpm
mariadb-devel-5.5.56-2.el7.x86_64.rpm
mariadb-embedded-5.5.56-2.el7.i686.rpm
mariadb-embedded-5.5.56-2.el7.x86_64.rpm
mariadb-embedded-devel-5.5.56-2.el7.i686.rpm
mariadb-embedded-devel-5.5.56-2.el7.x86_64.rpm
mariadb-libs-5.5.56-2.el7.i686.rpm
mariadb-libs-5.5.56-2.el7.x86_64.rpm
mariadb-server-5.5.56-2.el7.x86_64.rpm
mariadb-test-5.5.56-2.el7.x86_64.rpm

드[root@localhost 다운로드]# rm -rf *.i686.rpm        // .i686은 32bit 체계이므로 삭제함
드[root@localhost 다운로드]#
드[root@localhost 다운로드]# ls
mariadb-5.5.56-2.el7.x86_64.rpm
mariadb-bench-5.5.56-2.el7.x86_64.rpm
mariadb-devel-5.5.56-2.el7.x86_64.rpm
mariadb-embedded-5.5.56-2.el7.x86_64.rpm
mariadb-embedded-devel-5.5.56-2.el7.x86_64.rpm
mariadb-libs-5.5.56-2.el7.x86_64.rpm
mariadb-server-5.5.56-2.el7.x86_64.rpm
mariadb-test-5.5.56-2.el7.x86_64.rpm

드[root@localhost 다운로드]# rpm -ivh mariadb-5.5.56-2.el7.x86_64.rpm
오류: Failed dependencies:
        mariadb-libs(x86-64) = 1:5.5.56-2.el7 is needed by mariadb-1:5.5.56-2.el7.x86_64
드[root@localhost 다운로드]#
드[root@localhost 다운로드]# rpm -ivh mariadb-libs-5.5.56-2.el7.x86_64.rpm
준비 중...                         ################################# [100%]
Updating / installing...
   1:mariadb-libs-1:5.5.56-2.el7      ################################# [100%]
드[root@localhost 다운로드]#
드[root@localhost 다운로드]# rpm -ivh mariadb-5.5.56-2.el7.x86_64.rpm
준비 중...                         ################################# [100%]
Updating / installing...
   1:mariadb-1:5.5.56-2.el7           ################################# [100%]
드[root@localhost 다운로드]#
드[root@localhost 다운로드]# rpm -qa | grep mariadb
mariadb-5.5.56-2.el7.x86_64
mariadb-libs-5.5.56-2.el7.x86_64
드[root@localhost 다운로드]#
드[root@localhost 다운로드]# rpm -ivh mariadb-bench-5.5.56-2.el7.x86_64.rpm
오류: Failed dependencies:
        perl(GD) is needed by mariadb-bench-1:5.5.56-2.el7.x86_64
드[root@localhost 다운로드]#

// ctrl + F : perl(GD)

[   ] perl-GD-2.49-3.el7.x86_64.rpm                                                      04-Jul-2014 13:18  173K 

드[root@localhost 다운로드]# rpm -ivh perl-GD-2.49-3.el7.x86_64.rpm
준비 중...                         ################################# [100%]
Updating / installing...
   1:perl-GD-2.49-3.el7               ################################# [100%]
드[root@localhost 다운로드]#
드[root@localhost 다운로드]# rpm -ivh mariadb-bench-5.5.56-2.el7.x86_64.rpm
준비 중...                         ################################# [100%]
Updating / installing...
   1:mariadb-bench-1:5.5.56-2.el7     ################################# [100%]


드[root@localhost 다운로드]# rpm -ivh mariadb-devel-5.5.56-2.el7.x86_64.rpm
오류: Failed dependencies:
        openssl-devel(x86-64) is needed by mariadb-devel-1:5.5.56-2.el7.x86_64
// openssl-devel-1.0.2k-8.el7.x86_64.rpm                                              11-Aug-2017 03:37  1.5M

드[root@localhost 다운로드]# rpm -ivh openssl-devel-1.0.2k-8.el7.x86_64.rpm
오류: Failed dependencies:
        zlib-devel(x86-64) is needed by openssl-devel-1:1.0.2k-8.el7.x86_64

// zlib-devel-1.2.7-17.el7.x86_64.rpm                                                 21-Nov-2016 06:05   50K 

드[root@localhost 다운로드]#
드[root@localhost 다운로드]# rpm -ivh zlib-devel-1.2.7-17.el7.x86_64.rpm
준비 중...                         ################################# [100%]
Updating / installing...
   1:zlib-devel-1.2.7-17.el7          ################################# [100%]
드[root@localhost 다운로드]#
드[root@localhost 다운로드]# rpm -ivh openssl-devel-1.0.2k-8.el7.x86_64.rpm
준비 중...                         ################################# [100%]
Updating / installing...
   1:openssl-devel-1:1.0.2k-8.el7     ################################# [100%]

드[root@localhost 다운로드]#
드[root@localhost 다운로드]# rpm -ivh mariadb-devel-5.5.56-2.el7.x86_64.rpm
준비 중...                         ################################# [100%]
Updating / installing...
   1:mariadb-devel-1:5.5.56-2.el7     ################################# [100%]

드[root@localhost 다운로드]# rpm -ivh mariadb-embedded-devel-5.5.56-2.el7.x86_64pm
준비 중...                         ################################# [100%]
Updating / installing...
   1:mariadb-embedded-devel-1:5.5.56-2################################# [100%]

드[root@localhost 다운로드]#
드[root@localhost 다운로드]# rpm -ivh mariadb-embedded-5.5.56-2.el7.x86_64.rpm
준비 중...                         ################################# [100%]
Updating / installing...
   1:mariadb-embedded-1:5.5.56-2.el7  ################################# [100%]
드[root@localhost 다운로드]#
드[root@localhost 다운로드]# ls
mariadb-5.5.56-2.el7.x86_64.rpm
mariadb-bench-5.5.56-2.el7.x86_64.rpm
mariadb-devel-5.5.56-2.el7.x86_64.rpm
mariadb-embedded-5.5.56-2.el7.x86_64.rpm
mariadb-embedded-devel-5.5.56-2.el7.x86_64.rpm
mariadb-libs-5.5.56-2.el7.x86_64.rpm
mariadb-server-5.5.56-2.el7.x86_64.rpm
mariadb-test-5.5.56-2.el7.x86_64.rpm

드[root@localhost 다운로드]#

드[root@localhost 다운로드]# rpm -ivh mariadb-server-5.5.56-2.el7.x86_64.rpm
오류: Failed dependencies:
        perl-DBD-MySQL is needed by mariadb-server-1:5.5.56-2.el7.x86_64

// perl-DBD-MySQL-4.023-5.el7.x86_64.rpm                                              04-Jul-2014 13:16  140K

드[root@localhost 다운로드]# rpm -ivh perl-DBD-MySQL-4.023-5.el7.x86_64.rpm
준비 중...                         ################################# [100%]
Updating / installing...
   1:perl-DBD-MySQL-4.023-5.el7       ################################# [100%]

드[root@localhost 다운로드]# rpm -ivh mariadb-server-5.5.56-2.el7.x86_64.rpm
준비 중...                         ################################# [100%]
Updating / installing...
   1:mariadb-server-1:5.5.56-2.el7    ################################# [100%]

드[root@localhost 다운로드]# rpm -ivh mariadb-test-5.5.56-2.el7.x86_64.rpm
오류: Failed dependencies:
        perl(Env) is needed by mariadb-test-1:5.5.56-2.el7.x86_64
        perl(Test::More) is needed by mariadb-test-1:5.5.56-2.el7.x86_64
//  perl-Env-1.04-2.el7.noarch.rpm                                                     04-Jul-2014 13:17   16K 

 

드[root@localhost 다운로드]# rpm -ivh perl-Env-1.04-2.el7.noarch.rpm
준비 중...                         ################################# [100%]
Updating / installing...
   1:perl-Env-1.04-2.el7              ################################# [100%]

 

// perl-Test-Simple-0.98-243.el7.noarch.rpm                                           04-Jul-2014 13:24  170K 

드[root@localhost 다운로드]# rpm -ivh perl-Test-Simple-0.98-243.el7.noarch.rpm
준비 중...                         ################################# [100%]
Updating / installing...
   1:perl-Test-Simple-0.98-243.el7    ################################# [100%]

드[root@localhost 다운로드]# rpm -ivh mariadb-test-5.5.56-2.el7.x86_64.rpm
준비 중...                         ################################# [100%]
Updating / installing...
   1:mariadb-test-1:5.5.56-2.el7      ################################# [100%]

드[root@localhost 다운로드]# rpm -qa | grep mariadb
mariadb-5.5.56-2.el7.x86_64
mariadb-devel-5.5.56-2.el7.x86_64
mariadb-libs-5.5.56-2.el7.x86_64
mariadb-bench-5.5.56-2.el7.x86_64
mariadb-embedded-devel-5.5.56-2.el7.x86_64
mariadb-test-5.5.56-2.el7.x86_64
mariadb-embedded-5.5.56-2.el7.x86_64
mariadb-server-5.5.56-2.el7.x86_64

 

* 리눅스 환경설정 셋팅> 시스템 도구> 설정> 전원> 빈 화면 : 안함 체크

 

 

반응형
LIST
Posted by 오정oI
, |
반응형
SMALL

*  압축 (Compress)

3) 보관

tar(tape archive)

          보관하다

압축이 아님

 

1> archive file 생성

[사용형식]

# tar [option] archive file 보관할 file

 

[option]

c : create, archive file을 생성

v : visual.  과정, 자세히

f : file. archiving을 지정

t : list. archiving file에 보관되어 있는 파일을 출력

 

[특징]

- 확장자처럼  archive file명을 정해주어야 함

- 원본이 남아있음. 따라서 백업으로 쓰임

-  archive file(tar file)은 보관하고 있는 파일의 용량보다 큼

 

2> archive file 해제 및 추가

[사용형식]

# tar [option] archive file(tar file)

 

[option]

x  : extract. archive file(tar file) 풀기

--delete : archive file(tar file)에 보관되어 있는 파일을 삭제

r : archive file(tar file)에 파일을 추가

C : archive file(tar file)을 풀 디렉터리를 지정

 

참고로 절대경로를 이용해서 tar 하면 절대경로까지 보관을 하고

ex) tar cvf basket.tar /home/itbank/*

상대경로를 이용해서  tar하면 현재 디렉터리 하위를 보관함

ex) tar cvf basket.tar ./*

 

// 3) 보관

[root@localhost itbank]#
[root@localhost itbank]# ls -l
합계 24
-rw-r--r--. 1 root root 5078  1월  5 18:18 grub.cfg
-rw-r--r--. 1 root root  511  1월  5 18:18 inittab
-rw-r--r--. 1 root root 2028  1월  5 18:18 login.defs
-rw-r--r--. 1 root root 2205  1월  5 18:18 testfile1
-rw-r--r--. 1 root root 2205  1월  5 18:22 testfile2
[root@localhost itbank]#

// c : archilve file 생성
[root@localhost itbank]# tar cvf testarchive grub.cfg
grub.cfg
[root@localhost itbank]#
[root@localhost itbank]# ls -l
합계 36
-rw-r--r--. 1 root root  5078  1월  5 18:18 grub.cfg
-rw-r--r--. 1 root root   511  1월  5 18:18 inittab
-rw-r--r--. 1 root root  2028  1월  5 18:18 login.defs
-rw-r--r--. 1 root root 10240  1월  5 23:51 testarchive            // 확장자가 없으면 파악 힘듬..,
-rw-r--r--. 1 root root  2205  1월  5 18:18 testfile1
-rw-r--r--. 1 root root  2205  1월  5 18:22 testfile2

[root@localhost itbank]#

// t : list. archiving file에 보관되어 있는 파일을 출력

[root@localhost itbank]# tar tvf testarchive
-rw-r--r-- root/root      5078 2018-01-04 14:44 grub.cfg

// 확장자가 안보여서 구분 힘듬

// 확장자 지정해서 다시 생성

[root@localhost itbank]# tar cf test.tar grub.cfg
[root@localhost itbank]#
root@localhost itbank]# ls -l
합계 48
-rw-r--r--. 1 root root  5078  1월  5 18:18 grub.cfg
-rw-r--r--. 1 root root   511  1월  5 18:18 inittab
-rw-r--r--. 1 root root  2028  1월  5 18:18 login.defs
-rw-r--r--. 1 root root 10240  1월  5 23:54 test.tar
-rw-r--r--. 1 root root 10240  1월  5 23:51 testarchive
-rw-r--r--. 1 root root  2205  1월  5 18:18 testfile1
-rw-r--r--. 1 root root  2205  1월  5 18:22 testfile2
[root@localhost itbank]#

 

// 원본이 살아있으므로 백업용으로 쓰기 용이

[root@localhost itbank]# tar tvf test.tar
-rw-r--r-- root/root      5078 2018-01-04 14:44 grub.cfg

 

// tar(archive, 백업용) 파일은 원본(보관용) 파일보다 용량이 큼

[root@localhost itbank]# rm -rf testarchive
[root@localhost itbank]#
[root@localhost itbank]# tar cf test.tar grub.cfg
[root@localhost itbank]#
[root@localhost itbank]# ls -l
합계 40
-rw-r--r--. 1 root root  5078  1월  4 14:44 grub.cfg
-rw-r--r--. 1 root root   511  1월  4 14:44 inittab
-rw-r--r--. 1 root root  2028  1월  4 14:44 login.defs
-rw-r--r--. 1 root root  2116  1월  4 14:44 passwd
-rw-r--r--. 1 root root 10240  1월  5 12:55 test.tar
-rw-r--r--. 1 root root  1786  1월  5 12:43 testfile1
-rw-r--r--. 1 root root  1852  1월  5 12:49 testfile2

// archive 파일 해제

[root@localhost itbank]# ls -l
합계 40
-rw-r--r--. 1 root root  5078  1월  4 14:44 grub.cfg
-rw-r--r--. 1 root root   511  1월  4 14:44 inittab
-rw-r--r--. 1 root root  2028  1월  4 14:44 login.defs
-rw-r--r--. 1 root root  2116  1월  4 14:44 passwd
-rw-r--r--. 1 root root 10240  1월  5 12:59 test.tar
-rw-r--r--. 1 root root  1786  1월  5 12:43 testfile1
-rw-r--r--. 1 root root  1852  1월  5 12:49 testfile2
[root@localhost itbank]#
[root@localhost itbank]# rm -rf testfile1
[root@localhost itbank]#
[root@localhost itbank]# rm -rf grub.cfg
[root@localhost itbank]#
[root@localhost itbank]# ls -l
합계 24
-rw-r--r--. 1 root root   511  1월  5 18:18 inittab
-rw-r--r--. 1 root root  2028  1월  5 18:18 login.defs
-rw-r--r--. 1 root root 10240  1월  5 23:54 test.tar
-rw-r--r--. 1 root root  2205  1월  5 18:22 testfile2
[root@localhost itbank]#
[root@localhost itbank]# tar xvf test.tar
testfile1
[root@localhost itbank]#
[root@localhost itbank]# ls -l
합계 32
-rw-r--r--. 1 root root  5078  1월  5 18:18 grub.cfg
-rw-r--r--. 1 root root   511  1월  5 18:18 inittab
-rw-r--r--. 1 root root  2028  1월  5 18:18 login.defs
-rw-r--r--. 1 root root 10240  1월  5 23:54 test.tar
-rw-r--r--. 1 root root  2205  1월  5 18:22 testfile2

 

// 보관 파일 중 일부 해제     <실습 1> 후

[root@localhost itbank]# tar tvf basket.tar
-rw-r--r-- root/root      5078 2018-01-06 00:50 grub.cfg
-rw-r--r-- root/root       511 2018-01-06 00:50 inittab
-rw-r--r-- root/root      2028 2018-01-06 00:50 login.defs
-rw-r--r-- root/root     10240 2018-01-06 01:18 tarfile.tar
[root@localhost itbank]#
[root@localhost itbank]# tar f basket.tar --delete tarfile.tar
[root@localhost itbank]#
[root@localhost itbank]# tar tvf basket.tar
-rw-r--r-- root/root      5078 2018-01-06 00:50 grub.cfg
-rw-r--r-- root/root       511 2018-01-06 00:50 inittab
-rw-r--r-- root/root      2028 2018-01-06 00:50 login.defs
[root@localhost itbank]#
[root@localhost itbank]# ls -l
합계 40
-rw-r--r--. 1 root root 10240  1월  6 02:07 basket.tar
-rw-r--r--. 1 root root  5078  1월  6 00:50 grub.cfg
-rw-r--r--. 1 root root   511  1월  6 00:50 inittab
-rw-r--r--. 1 root root  2028  1월  6 00:50 login.defs
-rw-r--r--. 1 root root 10240  1월  6 01:18 tarfile.tar

// 보관 파일 중(archive) 일부 파일 추가

[root@localhost itbank]# tar rf basket.tar tarfile.tar
[root@localhost itbank]#
[root@localhost itbank]# tar tvf basket.tar
-rw-r--r-- root/root      5078 2018-01-06 00:50 grub.cfg
-rw-r--r-- root/root       511 2018-01-06 00:50 inittab
-rw-r--r-- root/root      2028 2018-01-06 00:50 login.defs
-rw-r--r-- root/root     10240 2018-01-06 01:18 tarfile.tar
[root@localhost itbank]#
[root@localhost itbank]# tar f basket.tar --delete tarfile.tar
[root@localhost itbank]#
[root@localhost itbank]# tar tvf basket.tar
-rw-r--r-- root/root      5078 2018-01-06 00:50 grub.cfg
-rw-r--r-- root/root       511 2018-01-06 00:50 inittab
-rw-r--r-- root/root      2028 2018-01-06 00:50 login.defs
[root@localhost itbank]#
[root@localhost itbank]# tar f basket.tar -r tarfile.tar  // basket.tar를 지정하고 tarfile.tar  파일을 추가
[root@localhost itbank]#
[root@localhost itbank]# tar tvf basket.tar
-rw-r--r-- root/root      5078 2018-01-06 00:50 grub.cfg
-rw-r--r-- root/root       511 2018-01-06 00:50 inittab
-rw-r--r-- root/root      2028 2018-01-06 00:50 login.defs
-rw-r--r-- root/root     10240 2018-01-06 01:18 tarfile.tar

 

<실습 1>

/home/itbank  홈 디렉터리 하위에 존재하는 모든 것들을 basket.tar로 보관해 주세요.

 

1) 절대경로 : 절대경로로 적어준것 까지 보관

2) 상대경로 : * : 파일만

    ./* : . 도 보관되는데 풀어보면 파일만 있음


[root@localhost itbank]# tar cvf basket.tar *
grub.cfg
inittab
login.defs
testfile2
[root@localhost itbank]#
[root@localhost itbank]# tar cvf basket2.tar ./*
./basket.tar
./grub.cfg
./inittab
./login.defs
./testfile2
[root@localhost itbank]#
[root@localhost itbank]# tar cvf basket3.tar /home/itbank/*
tar: Removing leading `/' from member names
/home/itbank/basket.tar
/home/itbank/basket2.tar
/home/itbank/grub.cfg
/home/itbank/inittab
/home/itbank/login.defs
/home/itbank/testfile2
[root@localhost itbank]#
[root@localhost itbank]# ls -l
합계 240
-rw-r--r--. 1 root root  61440  1월  6 00:41 basket.tar
-rw-r--r--. 1 root root  40960  1월  6 00:41 basket2.tar
-rw-r--r--. 1 root root 122880  1월  6 00:42 basket3.tar

-rw-r--r--. 1 root root   5078  1월  5 18:18 grub.cfg
-rw-r--r--. 1 root root    511  1월  5 18:18 inittab
-rw-r--r--. 1 root root   2028  1월  5 18:18 login.defs
-rw-r--r--. 1 root root   2205  1월  5 18:22 testfile2

<실습 2>

/home/itbank 홈 디렉터리 하위에 모든 것들을 archive file로 보관하여

/backup 디렉터리 하위에 보관을 해제해주세요.

 

 // 준비물

[root@localhost itbank]# ls
basket.tar   basket3.tar  inittab     passwd     testfile2
basket2.tar  grub.cfg     login.defs  testfile1
[root@localhost itbank]# rm -rf *
[root@localhost itbank]#
[root@localhost itbank]# ls
[root@localhost itbank]#
[root@localhost itbank]# cp /backup/* ./
[root@localhost itbank]#
[root@localhost itbank]# ls -l
합계 24
-rw-r--r--. 1 root root 5078  1월  5 13:26 grub.cfg
-rw-r--r--. 1 root root  511  1월  5 13:26 inittab
-rw-r--r--. 1 root root 2028  1월  5 13:26 login.defs
-rw-r--r--. 1 root root 2116  1월  5 13:26 passwd
-rw-r--r--. 1 root root   21  1월  5 13:26 testfile2
[root@localhost itbank]#
[root@localhost itbank]# rm -rf /backup/*
[root@localhost itbank]#
[root@localhost itbank]# ls -l /backup/
합계 0

// 실습 시작~!

// sol 1>

[root@localhost itbank]# ls -l
합계 24
-rw-r--r--. 1 root root 5078  1월  5 13:26 grub.cfg
-rw-r--r--. 1 root root  511  1월  5 13:26 inittab
-rw-r--r--. 1 root root 2028  1월  5 13:26 login.defs
-rw-r--r--. 1 root root 2116  1월  5 13:26 passwd
-rw-r--r--. 1 root root   21  1월  5 13:26 testfile2
[root@localhost itbank]#
[root@localhost itbank]# ls -l /backup/
합계 0
[root@localhost itbank]#
[root@localhost itbank]# tar cvf back.tar *    // 현재 경로의 모든 파일을 보관 하는 back.tar 생성
grub.cfg
inittab
login.defs
[root@localhost itbank]# ls -l
합계 28
-rw-r--r--. 1 root root  5078  1월  6 00:50 grub.cfg
-rw-r--r--. 1 root root 10240  1월  6 01:01 back.tar
-rw-r--r--. 1 root root   511  1월  6 00:50 inittab
-rw-r--r--. 1 root root  2028  1월  6 00:50 login.defs
[root@localhost itbank]#
[root@localhost itbank]# cp back.tar /backup/

[root@localhost itbank]#
[root@localhost itbank]# ls -l /backup/
합계 20
-rw-r--r--. 1 root root 20480  1월  5 13:47 back.tar
[root@localhost itbank]#
[root@localhost itbank]# cd /backup/
[root@localhost backup]#
[root@localhost backup]# tar xvf /backup/back.tar
grub.cfg
inittab
login.defs
[root@localhost backup]#
[root@localhost backup]#
[root@localhost backup]# rm -rf /backup/back.tar
[root@localhost backup]#

 

[root@localhost itbank]# tar xvf tarfile.tar     // 안됨


// sol 2>

[root@localhost itbank]# tar cvf tarfile.tar *
grub.cfg
inittab
login.defs
[root@localhost itbank]#
[root@localhost itbank]# cd /backup

[root@localhost itbank]# pwd
[root@localhost itbank]#
[root@localhost itbank]# tar xvf /home/itbank/tarfile.tar

 

// sol 3>

[root@localhost itbank]# tar xvf tarfile.tar  -C /backup/
grub.cfg
inittab
login.defs
[root@localhost itbank]#
[root@localhost itbank]# ls -l /backup/
합계 16
-rw-r--r--. 1 root root 5078  1월  6 00:50 grub.cfg
-rw-r--r--. 1 root root  511  1월  6 00:50 inittab
-rw-r--r--. 1 root root 2028  1월  6 00:50 login.defs

 

<실습 3> grub.cfg  파일만 /backup에 풀기

 

① -x 파일명

② -- get 파일명

③ -- extract 파일명

옵션 찾아보기~!!!

# man tar

 -x, --extract, --get
          저장된 것에서 풀어낸다.

[root@localhost itbank]# ls -l
합계 28
-rw-r--r--. 1 root root  5078  1월  6 00:50 grub.cfg
-rw-r--r--. 1 root root   511  1월  6 00:50 inittab
-rw-r--r--. 1 root root  2028  1월  6 00:50 login.defs
-rw-r--r--. 1 root root 10240  1월  6 01:18 tarfile.tar
[root@localhost itbank]#
[root@localhost itbank]# tar xvf tarfile.tar -C /backup/ -x grub.cfg
grub.cfg
[root@localhost itbank]#
[root@localhost itbank]# ls -l /backup/
합계 8
-rw-r--r--. 1 root root 5078  1월  6 00:50 grub.cfg
[root@localhost itbank]#
[root@localhost itbank]# tar xvf tarfile.tar -C /backup/ --get inittab
inittab
[root@localhost itbank]#
[root@localhost itbank]# ls -l /backup/
합계 12
-rw-r--r--. 1 root root 5078  1월  6 00:50 grub.cfg
-rw-r--r--. 1 root root  511  1월  6 00:50 inittab
[root@localhost itbank]#
[root@localhost itbank]# tar xvf tarfile.tar -C /backup/ --extract login.defs
login.defs
[root@localhost itbank]#
[root@localhost itbank]# ls -l /backup/
합계 16
-rw-r--r--. 1 root root 5078  1월  6 00:50 grub.cfg
-rw-r--r--. 1 root root  511  1월  6 00:50 inittab
-rw-r--r--. 1 root root 2028  1월  6 00:50 login.defs

 

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////

 

4) 다중압축

1> tar +gzip을 동시에 이용하여 작업(생성)        

사용형식

tar [option] archive file(tar file)  보관할 file

 

option

c, v, f

z :  tar + gzip을 동시에            

 

참고로  archive file(tar file) 이름을 입력할 때 *.tar.gz 해야 함

 

2> tar +gzip을 동시에 이용하여 작업(해제)        

사용형식

tar [option] archive file(tar file)  보관할 file

 

option

x, v, f

z :  tar + gzip을 동시에            

 

3> tar +bzip2을 동시에 이용하여 작업(생성)        

사용형식

tar [option] archive file(tar file)  보관할 file

 

option

c, v, f

j :  tar + bzip2을 동시에            

 

참고로  archive file(tar file) 이름을 입력할 때 *.tar.bz2 해야 함

 

4> tar +bzip2을 동시에 이용하여 작업(해제)       

사용형식

tar [option] archive file(tar file)  보관할 file

 

option

x, v, f

j :  tar + bzip2을 동시에          

 

// 4) 다중압축

<실습 4>

/usr/bin  디렉터리 하위에 모든 파일을 /home 디렉터리 하위에

archive file(tar file)로 생성해서 서로 비교해보기

 

조건: 표준방법(tar 따로 압축(gzip, bzip2)따로) 과

응용방법(tar + 압축(gzip, bzip2)을 동시에 ) 을 사용해서 작업

(archive file(tar file)을 풀지말기!)

 

gzip

(표준) : archive file(tar file) 명 binlistg

(응용) : archive file(tar file) 명 binlistg2

-------------------------

bzip2

(표준) : archive file(tar file) 명 binlistb

(응용) : archive file(tar file) 명 binlistb2

 

// 준비물

[root@localhost itbank]# ls -l /backup/
합계 16
-rw-r--r--. 1 root root 5078  1월  5 13:26 grub.cfg
-rw-r--r--. 1 root root  511  1월  5 13:26 inittab
-rw-r--r--. 1 root root 2116  1월  5 13:26 passwd
[root@localhost itbank]#
[root@localhost itbank]#
[root@localhost itbank]# pwd
/home/itbank
[root@localhost itbank]#
[root@localhost itbank]# rm -rf *
[root@localhost itbank]#
[root@localhost itbank]# ls

 

1) 

 [gzip 표준]

① tar  보관

② gzip 압축

 

# tar cf /home/binlistg.tar /usr/bin/*    // v 치면 많이 나와 생략

# ls -l /home

# gzip /home/binlistg.tar

# ls -l /home

 

 

# tar cvf testarchive grub.cfg

# tar cvf binlistg.tar /usr/bin/*

[root@localhost itbank]# ls -l
합계 307000
-rw-r--r--. 1 root root 314368000  1월  5 14:29 binlistg.tar
[root@localhost itbank]#
[root@localhost itbank]# gzip binlistg.tar
[root@localhost itbank]#
[root@localhost itbank]# ls -l
합계 124028
-rw-r--r--. 1 root root 127000601  1월  5 14:29 binlistg.tar.gz

 

[gzip 응용]

① tar + gzip

 

# tar cfz /home/binlistg2.tar.gz /usr/bin/*

# ls -l /home

 

2)

# tar cf /home/binlistb.tar /usr/bin/*

# ls -l /home

# bzip2 /home/binlistb.tar

# ls -l /home

# tar cfj /home/binlistb2.tar.bz2 /usr/bin/*

# ls -l /home

 

=> 압축률이 bzip2가 더 좋음~!!!


 

 

 

======================= Review ======================

 

*  압축 (Compress)

- 용량을 줄이기 위해서

- 여러 개의 파일을 하나의 파일로 작업할 때

 

1> 종류

Windows 운영체제에서 사용되는 압축 프로그램

ex) 알집, 반디집, 7-zip, 빵집, WinRAR 등등

 

Linux 운영체제에서 사용되는 압축 프로그램

 

1) compress

- 초창기때 사용되었던 압축 프로그램

 

2) gzip

- 유닉스에서 사용되었던 compress보다 더 양호한 압축 기능을 가진 프로그램

 

장점으로는 압축속도가 빠르며 단점으로는 압축률이 좋지 않음

용량이 적은 파일에서 사용

압축레벨이 존재함(가장 안전하게, 가장 빠르게)

 

3) bzip2

- 버로우즈-휠러 변환 기법의 압축 알고리즘 및 압축 소프트웨어

bzip은 블럭 정렬을 이용해서 산술 부호화를 사용했지만 특허 문제로 인해서 bzip2에서는

사용하지 않음

 

장점으로는 압축률이 좋으며 단점으로는 압축속도가 느림

용량이 많은 파일에서 사용

압축레벨이 존재함(가장 안전하게, 가장 빠르게)

 

4) xz

- bzip2보다 압축률이 좋고 속도도 빠름

 

5) zip

-호환성이 좋음

(Windows에서 Linux로 압축된 파일을 해제하거나 압축해서 사용가능)

 

2> 사용법

 

1) 압축

[준비물]

# cp /backup/* /home/itbank

# touch testfile1

testfile1에다가 적당히 내용 입력

cp testfile1 testfile2

 

[사용형식]

# gzip 파일명            // 용량 작으면 더 우세

# bzip2 파일명          // 용량 크면 bzip2 더 우세

 

[특징]

- 확장자 생김(gzip은 *.gz, bzip2 *.bz2)

- 용량이 줄었음

- 생성날짜와 시간이 변경되지 않음

- 원본이 사라짐

- 압축한 파일을 다시 압축 하는 행위는 좋지 않음

 

2) 압축 해제

[사용형식]

# gunzip 파일명

# bunzip2 파일명

[특징]

- 압축을 해제할 경우 반드시 압축한 프로그램으로 사용

- bunzip2 관련 파일은 확장자 생략 불가

 

[option]

-d : decompress(압축해제)

 

// 1) 압축

[root@localhost ~]# cd /home/itbank/
[root@localhost itbank]#
[root@localhost itbank]# ls
[root@localhost itbank]#
[root@localhost itbank]# cp /backup/* /home/itbank/
[root@localhost itbank]#
[root@localhost itbank]# ls
grub.cfg  inittab  login.defs
[root@localhost itbank]#
[root@localhost itbank]# touch testfile1
[root@localhost itbank]#
[root@localhost itbank]# vi testfile1
hihihihihihihihihihi    

// yy 누르고

// p 누르기~!!!

[root@localhost itbank]# cp testfile1 testfile2
[root@localhost itbank]#
[root@localhost itbank]# ls -l
합계 24
-rw-r--r--. 1 root root 5078  1월  5 18:18 grub.cfg
-rw-r--r--. 1 root root  511  1월  5 18:18 inittab
-rw-r--r--. 1 root root 2028  1월  5 18:18 login.defs
-rw-r--r--. 1 root root 2205  1월  5 18:18 testfile1
-rw-r--r--. 1 root root 2205  1월  5 18:22 testfile2

// gzip으로 압축

[root@localhost itbank]# gzip testfile1
[root@localhost itbank]#
[root@localhost itbank]# ls -l
합계 24
-rw-r--r--. 1 root root 5078  1월  5 18:18 grub.cfg
-rw-r--r--. 1 root root  511  1월  5 18:18 inittab
-rw-r--r--. 1 root root 2028  1월  5 18:18 login.defs
-rw-r--r--. 1 root root   57  1월  5 18:18 testfile1.gz
-rw-r--r--. 1 root root 2205  1월  5 18:22 testfile2
[root@localhost itbank]#
[root@localhost itbank]#

// bzip2으로 압축


[root@localhost itbank]# bzip2 testfile2
[root@localhost itbank]#
[root@localhost itbank]# ls -l
합계 24
-rw-r--r--. 1 root root 5078  1월  5 18:18 grub.cfg
-rw-r--r--. 1 root root  511  1월  5 18:18 inittab
-rw-r--r--. 1 root root 2028  1월  5 18:18 login.defs
-rw-r--r--. 1 root root   57  1월  5 18:18 testfile1.gz
-rw-r--r--. 1 root root   46  1월  5 18:22 testfile2.bz2


 

// 2) 압축 해제

// 압축한 파일을 다시 압축 하는 행위는 좋지 않음

[root@localhost itbank]# bzip2 testfile2.bz2
bzip2: Input file testfile2.bz2 already has .bz2 suffix.
// 다른 프로그램으로 압축하는 것 역시 안 좋음

[root@localhost itbank]# gzip testfile2.bz2
[root@localhost itbank]#
[root@localhost itbank]# bzip2 testfile1.gz
[root@localhost itbank]#
[root@localhost itbank]# ls -l
합계 24
-rw-r--r--. 1 root root 5078  1월  5 18:18 grub.cfg
-rw-r--r--. 1 root root  511  1월  5 18:18 inittab
-rw-r--r--. 1 root root 2028  1월  5 18:18 login.defs
-rw-r--r--. 1 root root  122  1월  5 18:18 testfile1.gz.bz2
-rw-r--r--. 1 root root   81  1월  5 18:22 testfile2.bz2.gz

[root@localhost itbank]#
[root@localhost itbank]# gunzip testfile1.gz.bz2
gzip: testfile1.gz.bz2: unknown suffix -- ignored
[root@localhost itbank]#
[root@localhost itbank]# bunzip2 testfile2.bz2.gz
bunzip2: Can't guess original name for testfile2.bz2.gz -- using testfile2.bz2.gz.out
bunzip2: testfile2.bz2.gz is not a bzip2 file.
[root@localhost itbank]#

// 압축 해제

[root@localhost itbank]# gunzip testfile2.bz2.gz
[root@localhost itbank]#
[root@localhost itbank]# ls -l
합계 24
-rw-r--r--. 1 root root 5078  1월  5 18:18 grub.cfg
-rw-r--r--. 1 root root  511  1월  5 18:18 inittab
-rw-r--r--. 1 root root 2028  1월  5 18:18 login.defs
-rw-r--r--. 1 root root  122  1월  5 18:18 testfile1.gz.bz2
-rw-r--r--. 1 root root   46  1월  5 18:22 testfile2.bz2

[root@localhost itbank]#
[root@localhost itbank]# gunzip testfile2.bz2
gzip: testfile2.bz2: unknown suffix -- ignored
[root@localhost itbank]# gunzip testfile2.bz2
gzip: testfile2.bz2: unknown suffix -- ignored
[root@localhost itbank]#
[root@localhost itbank]# bunzip2 testfile1.gz.bz2
[root@localhost itbank]#
[root@localhost itbank]# ls -l
합계 24
-rw-r--r--. 1 root root 5078  1월  5 18:18 grub.cfg
-rw-r--r--. 1 root root  511  1월  5 18:18 inittab
-rw-r--r--. 1 root root 2028  1월  5 18:18 login.defs
-rw-r--r--. 1 root root   57  1월  5 18:18 testfile1.gz
-rw-r--r--. 1 root root   46  1월  5 18:22 testfile2.bz2


[root@localhost itbank]#

// -d 옵션 사용

[root@localhost itbank]# gzip -d testfile2.bz2
gzip: testfile2.bz2: unknown suffix -- ignored
[root@localhost itbank]#
[root@localhost itbank]# bzip2 -d testfile1.gz
bzip2: Can't guess original name for testfile1.gz -- using testfile1.gz.out
bzip2: testfile1.gz is not a bzip2 file.
[root@localhost itbank]#
[root@localhost itbank]# gzip -d testfile1        // 확장자 안써도 됨
[root@localhost itbank]#
[root@localhost itbank]# bzip2 -d testfile2
bzip2: Can't open input file testfile2: No such file or directory.
[root@localhost itbank]#
[root@localhost itbank]# bzip2 -d testfile2.bz2 // 확장자 꼭 써야~!!!
[root@localhost itbank]#
[root@localhost itbank]# ls -l
합계 24
-rw-r--r--. 1 root root 5078  1월  5 18:18 grub.cfg
-rw-r--r--. 1 root root  511  1월  5 18:18 inittab
-rw-r--r--. 1 root root 2028  1월  5 18:18 login.defs
-rw-r--r--. 1 root root 2205  1월  5 18:18 testfile1
-rw-r--r--. 1 root root 2205  1월  5 18:22 testfile2


* 다중압축?

=> 불가!!!

반응형
LIST
Posted by 오정oI
, |
반응형
SMALL

* umask

[사용형식]

# umask

→ umask 기본 값 출력

umask [값]

 

umask [option]

option

-S : umask값을 문자로 출력

 

[특징]

- 파일이나 디렉터리 생성시 기본 퍼미션(허가권)을 지정해주는 지시자 역할

- umask 설정하면 별도로 허가권 설정 필요 없음!

- file은 'x'가 없으므로 홀수가 안나옴

 

1> directory (rwxrwxrwx)

 rwxrwxrwx

 허가권

 umask           

 관리자 (root)

 rwxr-xr-x  (755)

                    rwxrwxrwx

----w--w- (022)   - rwxr-xr-x     

 일반사용자 (itbank)

 rwxrwxr-x  (775)

                    rwxrwxrwx

-------w- (002)   - rwxrwxr-x

// root dir.

[root@localhost ~]# cd /home/itbank/
[root@localhost itbank]#
[root@localhost itbank]# mkdir ad_dir
[root@localhost itbank]#
[root@localhost itbank]# ls -ld ad_dir/
drwxr-xr-x. 2 root root 6  1월  4 21:18 ad_dir/            // 755
[root@localhost itbank]#

[root@localhost itbank]# umask                              // root umask
0022                                                    

// user dir.

[itbank@localhost ~]$ cd /home/itbank/
[itbank@localhost ~]$
[itbank@localhost ~]$ mkdir usr_dir
[itbank@localhost ~]$
[itbank@localhost ~]$ ls -ld usr_dir/
drwxrwxr-x. 2 itbank itbank 6  1월  4 21:29 usr_dir/    // 775

[itbank@localhost ~]$ umask                                // user umask
0002


2> file 

 rw-rw-rw-

 허가권

 umask           

 관리자 (root)

 rw-r--r--  (644)

                    rw-rw-rw-

----w--w- (022)   - rw-r--r--     

 일반사용자 (itbank)

 rw-rw-r--  (664)

                    rw-rw-rw-

-------w- (002)   - rw-rw-r--

    

 

// root file

[root@localhost itbank]# touch adm_file
[root@localhost itbank]#
[root@localhost itbank]# ls -l
합계 0
drwxr-xr-x. 2 root   root   6  1월  4 21:18 ad_dir
-rw-r--r--. 1 root   root   0  1월  4 21:36 adm_file
drwxrwxr-x. 2 itbank itbank 6  1월  4 21:29 usr_dir
[root@localhost itbank]#
[root@localhost itbank]# ls -l adm_file
-rw-r--r--. 1 root root 0  1월  4 21:36 adm_file
[root@localhost itbank]#

// user file

[itbank@localhost ~]$ touch usr_file
[itbank@localhost ~]$
[itbank@localhost ~]$ ls -l usr_file
-rw-rw-r--. 1 itbank itbank 0  1월  4 21:38 usr_file

ex>

1> dir.

최대값        :  777  rwxrwxrwx

dir. a 허가권 :  321  -wx-w---x

      456  r--r-xrw-

 

2> file

최대값        : rw-rw-rw-  666

file b 허가권 : r--r-xrw-  456

: -w--w---- 210??? => 220

 

 

// root 1

[root@localhost itbank]# cd ~itbank/
[root@localhost itbank]#
[root@localhost itbank]# pwd
/home/itbank
[root@localhost itbank]# ls
ad_dir  adm_file  usr_dir  usr_file
[root@localhost itbank]# ls -l
합계 0
drwxr-xr-x. 2 root   root   6  1월  4 21:18 ad_dir
-rw-r--r--. 1 root   root   0  1월  4 21:36 adm_file
drwxrwxr-x. 2 itbank itbank 6  1월  4 21:29 usr_dir
-rw-rw-r--. 1 itbank itbank 0  1월  4 21:38 usr_file
[root@localhost itbank]#
[root@localhost itbank]# rm -rf *
[root@localhost itbank]#
[root@localhost itbank]# ls
[root@localhost itbank]#
[root@localhost itbank]# mkdir testdir1
[root@localhost itbank]#
[root@localhost itbank]# touch testfile1
[root@localhost itbank]#
[root@localhost itbank]# ls -l
합계 0
drwxr-xr-x. 2 root root 6  1월  4 22:15 testdir1            // 755
-rw-r--r--. 1 root root 0  1월  4 22:15 testfile1           // 644 
[root@localhost itbank]#
[root@localhost itbank]# umask 123
[root@localhost itbank]#
[root@localhost itbank]# umask
0123
[root@localhost itbank]#
[root@localhost itbank]# mkdir testdir2
[root@localhost itbank]#
[root@localhost itbank]# touch testfile2
[root@localhost itbank]#
[root@localhost itbank]# ls -l
합계 0
drwxr-xr-x. 2 root root 6  1월  4 22:15 testdir1
drw-r-xr--. 2 root root 6  1월  4 22:19 testdir2           // 654 = 777-123 
-rw-r--r--. 1 root root 0  1월  4 22:15 testfile1          
-rw-r--r--. 1 root root 0  1월  4 22:19 testfile2          // 543 = 666-122(123) 'x' 없음!  
[root@localhost itbank]#
[root@localhost itbank]# umask -S
u=rw,g=rx,o=r                // umask값은 123임. umask 계산 해줘야.., => --x-w--wx (123)
[root@localhost itbank]#

// 새 연결 접속

login as: root
root@192.168.8.174's password:
Last login: Thu Jan  4 12:35:42 2018 from 192.168.8.1
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# umask
0022                        // 다시 기본값 설정으로 바뀜
[root@localhost ~]#
[root@localhost ~]# vi /etc/profile

/umask

검색

[root@localhost ~]#
[root@localhost ~]# ls -ld /home/itbank
drwx------. 8 itbank itbank 207  1월  4 13:37 /home/itbank    // 700
[root@localhost ~]#
[root@localhost ~]# vi /etc/login.defs

/UMASK

검색

 

// 기존 접속

[준비물]

[root@localhost itbank]# pwd
/home/itbank
[root@localhost itbank]#
[root@localhost itbank]# rm -rf *
[root@localhost itbank]#
[root@localhost itbank]# umask 022
[root@localhost itbank]#
[root@localhost itbank]# passwd itbank
itbank 사용자의 비밀 번호 변경 중
새  암호:
잘못된 암호: 암호는 8 개의 문자 보다 짧습니다
새  암호 재입력:
passwd: 모든 인증 토큰이 성공적으로 업데이트 되었습니다.
[root@localhost itbank]#
[root@localhost itbank]# ls -l /usr/bin/passwd
-rwsr-xr-x. 1 root root 27832  6월 10  2014 /usr/bin/passwd
[root@localhost itbank]#
[root@localhost itbank]# chmod 4755 /usr/bin/passwd
[root@localhost itbank]#
[root@localhost itbank]# ls -l /usr/bin/passwd
-rwsr-xr-x. 1 root root 27832  6월 10  2014 /usr/bin/passwd

 

 

 

*  압축 (Compress)

- 용량을 줄이기 위해서

- 여러 개의 파일을 하나의 파일로 작업할 때

1> 종류

Windows 운영체제에서 사용되는 압축 프로그램

ex) 알집, 반디집, 7-zip, 빵집, WinRAR 등등

 

Linux 운영체제에서 사용되는 압축 프로그램

 

1) compress

- 초창기때 사용되었던 압축 프로그램

 

2) gzip

- 유닉스에서 사용되었던 compress보다 더 양호한 압축 기능을 가진 프로그램

 

장점으로는 압축속도가 빠르며 단점으로는 압축률이 좋지 않음

용량이 적은 파일에서 사용

압축레벨이 존재함(가장 안전하게, 가장 빠르게)

 

3) bzip2

- 버로우즈-휠러 변환 기법의 압축 알고리즘 및 압축 소프트웨어

bzip은 블럭 정렬을 이용해서 산술 부호화를 사용했지만 특허 문제로 인해서 bzip2에서는

사용하지 않음

 

장점으로는 압축률이 좋으며 단점으로는 압축속도가 느림

용량이 많은 파일에서 사용

압축레벨이 존재함(가장 안전하게, 가장 빠르게)

 

4) xz

- bzip2보다 압축률이 좋고 속도도 빠름

 

5) zip

-호환성이 좋음

(Windows에서 Linux로 압축된 파일을 해제하거나 압축해서 사용가능)

 

2> 사용법

1) 압축

[준비물]

# cp /backup/* /home/itbank

# touch testfile1

testfile1에다가 적당히 내용 입력

cp testfile1 testfile2

 

[사용형식]

gzip 파일명            // 용량 작으면 더 우세

bzip2 파일명          // 용량 크면 bzip2 더 우세

 

[특징]

- 확장자 생김(gzip은 *.gz, bzip2 *.bz2)

- 용량이 줄었음

- 생성날짜와 시간이 변경되지 않음

- 원본이 사라짐

- 압축한 파일을 다시 압축 하는 행위는 좋지 않음

 

2) 압축 해제

[사용형식]

gunzip 파일명

bunzip2 파일명

[특징]

- 압축을 해제할 경우 반드시 압축한 프로그램으로 사용

- bunzip2 관련 파일은 확장자 생략 불가

 

[option]

-d : decompress(압축해제)

 

 

// 1) 압축

[root@localhost tmp]# cp /backup/* /home/itbank
[root@localhost tmp]#
[root@localhost tmp]# cd /home/itbank
[root@localhost itbank]#
[root@localhost itbank]# ls
grub.cfg  inittab  login.defs  passwd  testfile2
[root@localhost itbank]#
[root@localhost itbank]# ls -l
합계 24
-rw-r--r--. 1 root root 5078  1월  4 14:44 grub.cfg
-rw-r--r--. 1 root root  511  1월  4 14:44 inittab
-rw-r--r--. 1 root root 2028  1월  4 14:44 login.defs
-rw-r--r--. 1 root root 2116  1월  4 14:44 passwd
-rw-r--r--. 1 root root   21  1월  4 14:44 testfile2
[root@localhost itbank]#
[root@localhost itbank]# touch testfile1
[root@localhost itbank]#
[root@localhost itbank]# vi testfile1
[root@localhost itbank]#
[root@localhost itbank]# cp testfile1 testfile2
cp: overwrite `testfile2'? y
[root@localhost itbank]#
[root@localhost itbank]# gzip testfile1
[root@localhost itbank]#
[root@localhost itbank]# ls -l
합계 28
-rw-r--r--. 1 root root 5078  1월  4 14:44 grub.cfg
-rw-r--r--. 1 root root  511  1월  4 14:44 inittab
-rw-r--r--. 1 root root 2028  1월  4 14:44 login.defs
-rw-r--r--. 1 root root 2116  1월  4 14:44 passwd
-rw-r--r--. 1 root root   37  1월  4 14:47 testfile1.gz
-rw-r--r--. 1 root root   66  1월  4 14:47 testfile2
[root@localhost itbank]#
[root@localhost itbank]# bzip2 testfile2
[root@localhost itbank]#
[root@localhost itbank]# ls -l
합계 28
-rw-r--r--. 1 root root 5078  1월  4 14:44 grub.cfg
-rw-r--r--. 1 root root  511  1월  4 14:44 inittab
-rw-r--r--. 1 root root 2028  1월  4 14:44 login.defs
-rw-r--r--. 1 root root 2116  1월  4 14:44 passwd
-rw-r--r--. 1 root root   37  1월  4 14:47 testfile1.gz
-rw-r--r--. 1 root root   47  1월  4 14:47 testfile2.bz2
[root@localhost itbank]#
[root@localhost itbank]# ls -l
합계 28
-rw-r--r--. 1 root root 5078  1월  4 14:44 grub.cfg
-rw-r--r--. 1 root root  511  1월  4 14:44 inittab
-rw-r--r--. 1 root root 2028  1월  4 14:44 login.defs
-rw-r--r--. 1 root root 2116  1월  4 14:44 passwd
-rw-r--r--. 1 root root   37  1월  4 14:47 testfile1.gz
-rw-r--r--. 1 root root   47  1월  4 14:47 testfile2.bz2


 

// 2) 압축 해제

 

[root@localhost itbank]# bzip2 testfile2.bz2
bzip2: Input file testfile2.bz2 already has .bz2 suffix.
[root@localhost itbank]# gzip testfile2.bz2
[root@localhost itbank]#
[root@localhost itbank]# bzip2 testfile1.gz
[root@localhost itbank]#
[root@localhost itbank]# ls -l
합계 28
-rw-r--r--. 1 root root 5078  1월  4 14:44 grub.cfg
-rw-r--r--. 1 root root  511  1월  4 14:44 inittab
-rw-r--r--. 1 root root 2028  1월  4 14:44 login.defs
-rw-r--r--. 1 root root 2116  1월  4 14:44 passwd
-rw-r--r--. 1 root root   92  1월  4 14:47 testfile1.gz.bz2
-rw-r--r--. 1 root root   82  1월  4 14:47 testfile2.bz2.gz
[root@localhost itbank]#
[root@localhost itbank]# gunzip testfile1.gz.bz2
gzip: testfile1.gz.bz2: unknown suffix -- ignored
[root@localhost itbank]#
[root@localhost itbank]# bunzip2 testfile2.bz2.gz
bunzip2: Can't guess original name for testfile2.bz2.gz -- using testfile2.bz2.gz.out
bunzip2: testfile2.bz2.gz is not a bzip2 file.
[root@localhost itbank]#
[root@localhost itbank]# gunzip testfile2.bz2.gz
[root@localhost itbank]#
[root@localhost itbank]# ls -l
합계 28
-rw-r--r--. 1 root root 5078  1월  4 14:44 grub.cfg
-rw-r--r--. 1 root root  511  1월  4 14:44 inittab
-rw-r--r--. 1 root root 2028  1월  4 14:44 login.defs
-rw-r--r--. 1 root root 2116  1월  4 14:44 passwd
-rw-r--r--. 1 root root   92  1월  4 14:47 testfile1.gz.bz2
-rw-r--r--. 1 root root   47  1월  4 14:47 testfile2.bz2
[root@localhost itbank]#
[root@localhost itbank]# gunzip testfile2.bz2
gzip: testfile2.bz2: unknown suffix -- ignored
[root@localhost itbank]# gunzip testfile2.bz2
gzip: testfile2.bz2: unknown suffix -- ignored
[root@localhost itbank]#
[root@localhost itbank]# bunzip2 testfile1.gz.bz2
[root@localhost itbank]#
[root@localhost itbank]# ls -l
합계 28
-rw-r--r--. 1 root root 5078  1월  4 14:44 grub.cfg
-rw-r--r--. 1 root root  511  1월  4 14:44 inittab
-rw-r--r--. 1 root root 2028  1월  4 14:44 login.defs
-rw-r--r--. 1 root root 2116  1월  4 14:44 passwd
-rw-r--r--. 1 root root   37  1월  4 14:47 testfile1.gz
-rw-r--r--. 1 root root   47  1월  4 14:47 testfile2.bz2
[root@localhost itbank]#
[root@localhost itbank]# gzip -d testfile2.bz2
gzip: testfile2.bz2: unknown suffix -- ignored
[root@localhost itbank]#
[root@localhost itbank]# bzip2 -d testfile1.gz
bzip2: Can't guess original name for testfile1.gz -- using testfile1.gz.out
bzip2: testfile1.gz is not a bzip2 file.
[root@localhost itbank]#
[root@localhost itbank]# gzip -d testfile1
[root@localhost itbank]#
[root@localhost itbank]# bzip2 -d testfile2
bzip2: Can't open input file testfile2: No such file or directory.
[root@localhost itbank]#
[root@localhost itbank]# bzip2 -d testfile2.bz2
[root@localhost itbank]#
[root@localhost itbank]# ls -l
합계 28
-rw-r--r--. 1 root root 5078  1월  4 14:44 grub.cfg
-rw-r--r--. 1 root root  511  1월  4 14:44 inittab
-rw-r--r--. 1 root root 2028  1월  4 14:44 login.defs
-rw-r--r--. 1 root root 2116  1월  4 14:44 passwd
-rw-r--r--. 1 root root   66  1월  4 14:47 testfile1
-rw-r--r--. 1 root root   66  1월  4 14:47 testfile2

 

* 다중압축?

=> 불가!!!

 

 

 

<실습1 -umask 

 

각 번호마다 작업 시 명령어 한 줄

 

1) /tmp/test 디렉터리는 stickybit를 가지고 있으며 모든 권한을 가지고 있음

   1000                            777    => 1777    

# mkdir -m 1777 /tmp/test

# ls -ld /tmp/test

 

# mkdir -m go+w,o+t /tmp/test    // 755 → 1777

 

2) /tmp/test/test2 디렉터리는 소유자가 모든 권한을 가지고 있으며, 그룹은 읽기 및 접근

권한을 가지고 있으며, 다른 유저는 쓰기와 접근을 가지고 있음

u=rwx,g=rx,o=wx

753

 

# mkdir -m 753 /tmp/test/test2

# ls -ld /tmp/test/test2

 

# mkdir -m g-w,o-r+w /tmp/test/test2    // 755(???) → 753

 

3) /tmp/test/test2/test3 디렉터리는 소유자가 모든 권한을 가지고 있으며, 그룹은 읽기

권한만 가지고 있으며, 다른 유저는 접근 권한만 가지고 있음

u=rwx,g=r,o=x

741

 

=> umask 755에서 계산해줘야..,

rwxr-xr-x

# mkdir -m 741 /tmp/test2/test3

 

# mkdir -m g-x,o-r /tmp/test/test2/test3    // 755 → 741

 

// 마무리

[root@localhost tmp]# rm -rf /tmp/test

 

답:  관리자(root) umask :  rwxr-xr-x    (755)  

mkdir -m 1777 /tmp/test

mkdir -m 753 /tmp/test/test2

mkdir -m 741 /tmp/test/test2/test3

--------------------------------

mkdir -m go+w,o+t /tmp/test

mkdir -m g-w,o-r+w /tmp/test/test2

mkdir -m g-x,o-r /tmp/test/test2/test3

반응형
LIST
Posted by 오정oI
, |
반응형
SMALL

※ 권한

- 허가권(Permission)

- 소유권(Ownership)

- 특수권한

 

2. 소유권 (Ownership)

 

1> 소유권 구문 정리

 

[준비물 2]

[root@localhost itbank]# ls -ld /home
drwxr-xr-x. 4 root root 87 12월 29 12:49 /home

|----> 소유권

[사용형식]

chown UID:6ID directory 또는 file

 

[준비물]

cp /backup/* /home/itbank

ex)

chown UID directory 또는 파일

→ 파일이나 디렉터리의 UID만 변경

 

ex)

chown UID:GID directory  또는 file

→ 파일이나 디렉터리의 UID와 GID를 변경

 

ex)

chown :GID  directory 또는 file

→ 파일이나 디렉터리의 GID만 변경

 

* :(콜론)을 .(닷)으로 대체 사용 가능

 

ex)

chown UID: directory  또는 file

→ GID가 UID를 따라간다 (GID is default UID)

 

1. 허가권(Permission)

 

사용형식

chmod [permission] directory 또는 파일

    |-------> numeric(숫자)

    |-------> symbolic(문자)

 

1) numeric (일반권한에 적용됨)

준비물

--x-w--wx       ->     r--r-xrw-

chmod 456 directory 또는 file

 

2) symbolic (특수권한에 적용됨)

준비물

rwxrw-r-x    ->    rw--wx-w-

chmod u-x,g-r,g+x,o-r,o+w,o-x  directory 또는 file

 

3. 특수권한(SetUID, SetGID, Sticky bit)

1> SetUID

r  w  x  r  w  x  r  w  x        →      777        // 일반권한

   |-->  'x'  자리에 관련 있음

r  w  s  r  w  x  r  w  x       →    4777         // 특수권한(SetUID) 

r  w  S  r  w  x  r  w  x       →    4677

 

[특징]

허가권의 UID 부분에 'x'가 's' 또는 'S'로 표현됨

's'(소문자)는 'x'가 있고, 'S'는 'x'가 없음

8진수 모드로 값이 4000

실행파일

SetUID가 설정되어 있는 실행파일을 실행 할 경우  UID의 권한으로 실행하게 됨

 

ex> other가 user 권한 행사함

잘못하면 악용 우려..,

cmd 관리자 권한으로 실행

 

rwxr-xr-x

 엄 엄 나

2> SetGID

r  w  x  r  w  x  r  w  x        →      777        // 일반권한

               |-->  'x'  자리에 관련 있음

r  w  x  r  w  s  r  w  x       →    2777         // 특수권한(SetGID) 

r  w  x  r  w  S  r  w  x       →    2767

 

[특징]

허가권의 GID 부분에 'x'가 's' 또는 'S'로 표현됨

's'(소문자)는 'x'가 있고, 'S'는 'x'가 없음

8진수 모드로 값이 2000

실행파일, 디렉터리(에서도 효과 봄)

SetGID는 SetUID와 동일하나 다만 그 권한이 GID에 있음(group 쪽)

설정되어 있는 실행파일을 실행 할 경우  GID의 권한으로 실행하게 됨

 

 

 

3> Sticky bit

r  w  x  r  w  x  r  w  x        →      777        // 일반권한

                          |-->  'x'  자리에 관련 있음

r  w  x  r  w  x  r  w  t       →    1777         // 특수권한(Sticky bit) 

r  w  x  r  w  x  r  w  T       →    1776

 

[특징]

허가권의 Other 부분에 'x'가 't' 또는 'T'로 표현됨

't'(소문자)는 'x'가 있고, 'T'는 'x'가 없음

8진수 모드로 값이 1000

공용 디렉터리

Sticky bit가 설정되어 있는 디렉터리에서는 누구든지 자유롭게 생성과 삭제를 할 수 있음.

다만! 삭제 시에는 해당 소유자와 관리자(슈퍼유저)만이 삭제할 수 있음

 

ex> 자유게시판

글쓴이가 삭제하고 또는 관리자가 삭제

 

// setGID

[puTTY - root]

[root@localhost itbank]# groupadd setgid
[root@localhost itbank]#
[root@localhost itbank]# tail -2 /etc/group
itbank:x:1000:
setgid:x:1001:
[root@localhost itbank]#

[puTTY - itbank]

login as: itbank
itbank@192.168.8.174's password:
Last login: Mon Sep 25 15:31:40 2017
[itbank@localhost ~]$
[itbank@localhost ~]$ ls
[itbank@localhost ~]$
[itbank@localhost ~]$ mkdir a b c
[itbank@localhost ~]$
[itbank@localhost ~]$ ls
a  b  c
[itbank@localhost ~]$ exit   // 접속 끊고

[puTTY - root]

// a, b dir. : setgid 로 gid 변경

[root@localhost itbank]# chown .setgid b c
[root@localhost itbank]#
[root@localhost itbank]# ls -l
합계 0
drwxrwxr-x. 2 itbank itbank 6  1월  3 14:31 a
drwxrwxr-x. 2 itbank setgid 6  1월  3 14:31 b
drwxrwxr-x. 2 itbank setgid 6  1월  3 14:31 c

// c : 특수권한 적용(setGID)

[root@localhost itbank]# chmod g+s c
[root@localhost itbank]#
[root@localhost itbank]# ls -l
합계 0
drwxrwxr-x. 2 itbank itbank 6  1월  3 14:31 a
drwxrwxr-x. 2 itbank setgid 6  1월  3 14:31 b
drwxrwsr-x. 2 itbank setgid 6  1월  3 14:31 c

[puTTY - itbank]

// 다시 재접속 (잘못된 설정 방지)

login as: itbank
itbank@192.168.8.174's password:
Last login: Wed Jan  3 14:31:16 2018 from 192.168.8.1
[itbank@localhost ~]$
[itbank@localhost ~]$
[itbank@localhost ~]$ ls -l
합계 0
drwxrwxr-x. 2 itbank itbank 6  1월  3 14:31 a
drwxrwxr-x. 2 itbank setgid 6  1월  3 14:31 b
drwxrwsr-x. 2 itbank setgid 6  1월  3 14:31 c
[itbank@localhost ~]$
[itbank@localhost ~]$ touch a/testfile1
[itbank@localhost ~]$
[itbank@localhost ~]$ ls -l
합계 0
drwxrwxr-x. 2 itbank itbank 23  1월  3 14:36 a
drwxrwxr-x. 2 itbank setgid  6  1월  3 14:31 b
drwxrwsr-x. 2 itbank setgid  6  1월  3 14:31 c
[itbank@localhost ~]$
[itbank@localhost ~]$ ls -l a/
합계 0
-rw-rw-r--. 1 itbank itbank 0  1월  3 14:36 testfile1
[itbank@localhost ~]$
[itbank@localhost ~]$ touch b/testfile2
[itbank@localhost ~]$
[itbank@localhost ~]$ ls -l b/
합계 0
-rw-rw-r--. 1 itbank itbank 0  1월  3 14:37 testfile2
[itbank@localhost ~]$
[itbank@localhost ~]$ touch c/testfile3
[itbank@localhost ~]$
[itbank@localhost ~]$ ls -l c/
합계 0
-rw-rw-r--. 1 itbank setgid 0  1월  3 14:38 testfile3        // itbank가 만들었다 해도 setGID 영향으로 gid는 변경 안됨!
[itbank@localhost ~]$ exit

[puTTY - root]

[root@localhost itbank]# rm -rf *
[root@localhost itbank]#
[root@localhost itbank]# groupdel setgid

// Sticky bit

[puTTY - root]

// 공용 디렉터리 생성

[root@localhost itbank]# mkdir /everone
[root@localhost itbank]#
[root@localhost itbank]# ls -ld /everone
drwxr-xr-x. 2 root root 6  1월  3 14:39 /everone
[root@localhost itbank]#
[root@localhost itbank]# chmod go+w /everone        // 허가권 : 755 → 777
[root@localhost itbank]#
[root@localhost itbank]# ls -ld /everone
drwxrwxrwx. 2 root root 6  1월  3 14:39 /everone

[puTTY - itbank]

login as: itbank
itbank@192.168.8.174's password:
Last login: Wed Jan  3 14:36:08 2018 from 192.168.8.1
[itbank@localhost ~]$
[itbank@localhost ~]$
[itbank@localhost ~]$
[itbank@localhost ~]$ cd /everone
[itbank@localhost everone]$
[itbank@localhost everone]$ pwd
/everone
[itbank@localhost everone]$ touch 2018년무술년
[itbank@localhost everone]$
[itbank@localhost everone]$ ls -l
합계 0
-rw-rw-r--. 1 itbank itbank 0  1월  3 14:42 2018년무술년
[itbank@localhost everone]$
[itbank@localhost everone]$ vi 2018년무술년
[itbank@localhost everone]$
[itbank@localhost everone]$ cat 2018년무술년
새해 복 많이 받엉~ ^^
[itbank@localhost everone]$

[itbank@localhost everone]$ exit

[puTTY - root]

[root@localhost itbank]# useradd badnom


[root@localhost itbank]#
[root@localhost itbank]#
[root@localhost itbank]# passwd badnom
badnom 사용자의 비밀 번호 변경 중
새  암호:
잘못된 암호: 암호는 8 개의 문자 보다 짧습니다
새  암호 재입력:
passwd: 모든 인증 토큰이 성공적으로 업데이트 되었습니다.
[root@localhost itbank]#

[puTTY - badnom]

login as: badnom
badnom@192.168.8.174's password:
[badnom@localhost ~]$
[badnom@localhost ~]$ ls -l
합계 0
[badnom@localhost ~]$
[badnom@localhost ~]$ cd /everone
[badnom@localhost everone]$
[badnom@localhost everone]$ ls -l
합계 4
-rw-rw-r--. 1 itbank itbank 29  1월  3 14:43 2018년무술년
[badnom@localhost everone]$ vi 2018년무술년
[badnom@localhost everone]$
[badnom@localhost everone]$ cat 2018년무술년
ㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋ
[badnom@localhost everone]$
[badnom@localhost everone]$

[badnom@localhost everone]$
[badnom@localhost everone]$ rm -rf 2018년무술년
[badnom@localhost everone]$
[badnom@localhost everone]$ ls
[badnom@localhost everone]$
[badnom@localhost everone]$ exit

[puTTY - root]

[root@localhost itbank]# chmod o+t /everone
[root@localhost itbank]#
[root@localhost itbank]# ls -ld /everone
drwxrwxrwt. 2 root root 6  1월  3 14:50 /everone
[root@localhost itbank]#

 

1) itbank 로 접속해서 파일생성

2) badnom으로 접속해서 수정이나 삭제 해보기!

 

// 1) itbank 로 접속해서 파일생성

login as: itbank
itbank@192.168.8.174's password:
Last login: Wed Jan  3 14:41:25 2018 from 192.168.8.1
[itbank@localhost ~]$
[itbank@localhost ~]$ ls /
AS      bin   dev  everone  lib    media  opt   root  sbin  sys   tmp  var
backup  boot  etc  home     lib64  mnt    proc  run   srv   test  usr
[itbank@localhost ~]$
[itbank@localhost ~]$ cd /everone/
[itbank@localhost everone]$
[itbank@localhost everone]$ ls
[itbank@localhost everone]$
[itbank@localhost everone]$ touch testfile1
[itbank@localhost everone]$
[itbank@localhost everone]$ vi testfile1
[itbank@localhost everone]$ exit

 

// 2) badnom으로 접속해서 수정이나 삭제 해보기!

login as: badnom
badnom@192.168.8.174's password:
Last login: Wed Jan  3 14:45:59 2018 from 192.168.8.1
[badnom@localhost ~]$
[badnom@localhost ~]$ ls /
AS      bin   dev  everone  lib    media  opt   root  sbin  sys   tmp  var
backup  boot  etc  home     lib64  mnt    proc  run   srv   test  usr
[badnom@localhost ~]$
[badnom@localhost ~]$ cd /everone/
[badnom@localhost everone]$
[badnom@localhost everone]$ ls
testfile1
[badnom@localhost everone]$
[badnom@localhost everone]$ cat testfile1
iglglglglglglglglglgl
[badnom@localhost everone]$
[badnom@localhost everone]$ vi testfile1        // 편집 불가
[badnom@localhost everone]$
[badnom@localhost everone]$ cat testfile1
iglglglglglglglglglgl
[badnom@localhost everone]$
[badnom@localhost everone]$ rm -rf *           // 삭제 불가    
rm: cannot remove `testfile1': 명령을 허용하지 않음
[badnom@localhost everone]$
[badnom@localhost everone]$ ls -l
합계 4
-rw-rw-r--. 1 itbank itbank 22  1월  3 14:55 testfile1
[badnom@localhost everone]$
[badnom@localhost everone]$ ls -ld
drwxrwxrwt. 2 root root 23  1월  3 14:57 .
[badnom@localhost everone]$ exit

 

// setUID

[puTTY - root]

[root@localhost everone]# rm -rf /everone/
[root@localhost everone]#
[root@localhost everone]# userdel -r badnom

[root@localhost everone]# find / -name passwd -type d
/sys/fs/selinux/class/passwd
[root@localhost everone]#
[root@localhost everone]# find / -name passwd -type f
/sys/fs/selinux/class/passwd/perms/passwd
/etc/pam.d/passwd
/etc/passwd
/usr/bin/passwd
/usr/share/bash-completion/completions/passwd
/backup/passwd
[root@localhost everone]#
[root@localhost everone]# find / -name passwd -type f -exec ls -l {} \;
-r--r--r--. 1 root root 0  1월  3 12:36 /sys/fs/selinux/class/passwd/perms/passwd
-rw-r--r--. 1 root root 188  6월 10  2014 /etc/pam.d/passwd
-rw-r--r--. 1 root root 2116  1월  3 15:02 /etc/passwd
-rwsr-xr-x. 1 root root 27832  6월 10  2014 /usr/bin/passwd                        // user에 s가 있고, other에 x가 있음
-rw-r--r--. 1 root root 514  6월 10  2014 /usr/share/bash-completion/completions/passwd
-rw-r--r--. 1 root root 2116 12월 15 14:44 /backup/passwd

 

<실습>

/usr/bin/passwd 파일의 허가권을 변경한 뒤 itbank 사용자 계정으로 로그인 후 비밀번호 변경 테스트

 

/usr/bin/passwd 허가권

명령실행(passwd)        

 비밀번호(변경)

 ① rwsr-xr-x (4755)

 ○

 ○ // 관리자 권한 빌림

 ② rwxr-xr-x (755)

 ○

 × 
 ③ rwsr-x--- (4750)  ×            ×  
   other에 'x' 유 무   user에 's' 유 무 (setUID)

 

(②, ③) 택 ?

어차피 못하게 할거면 확실하게 못하게 하는게..,

=> ③

 

// root

#  ls -l /usr/bin/passwd    //  비밀번호 설정 파일 관련 허가권 조회

 

// itbank

$ itbank

itbank

$ passwd

itb@nk!@#$

=> 성공~!!!

 

///////////////

// root

# chmod u-s /usr/bin/passwd
# ls -l /usr/bin/passwd

 

// itbank

$ itbank

itb@nk!@#$

$ passwd

itb@nk!@#$

오늘은목요일

passwd: 인증토큰수정 오류

$ exit

 

///////////////

// root

# chmod u+s,o-rx /usr/bin/passwd
# ls -l /usr/bin/passwd

 

// itbank

$ itbank

itb@nk!@#$

$ passwd

불가!!!

 

* 사용자 복구 (sol 1.)

 

 

 

// user3 userdel만 했을 때의 home dir. 과 mail 상태

[root@localhost /]# cd /home/itbank
[root@localhost itbank]# pwd
/home/itbank
[root@localhost itbank]#
[root@localhost itbank]# rm -rf *
[root@localhost itbank]#
[root@localhost itbank]# ls
[root@localhost itbank]#
[root@localhost itbank]# mkdir /test
[root@localhost itbank]#
[root@localhost itbank]# useradd user1
[root@localhost itbank]#
[root@localhost itbank]# useradd user2
[root@localhost itbank]#
[root@localhost itbank]# useradd -d /test/user3 user3
[root@localhost itbank]#
[root@localhost itbank]# userdel -r user1        

[root@localhost itbank]#
[root@localhost itbank]# userdel -r user2
[root@localhost itbank]#
[root@localhost itbank]# userdel user3
[root@localhost itbank]#
[root@localhost itbank]# ls -l /test/
합계 0
drwx------. 3 1003 1003 78  1월  3 12:41 user3    
[root@localhost itbank]#
[root@localhost itbank]# ls -l /var/spool/mail
합계 0
-rw-rw----. 1 itbank mail 0  9월 25 15:30 itbank
-rw-rw----. 1 rpc    mail 0  9월 25 14:53 rpc
-rw-rw----. 1   2014 mail 0 12월 28 13:15 user12
-rw-rw----. 1   1003 mail 0  1월  3 12:41 user3
[root@localhost itbank]#

[root@localhost itbank]# rm -rf /var/spool/mail/user12

// user1, user2 uid, gid 텀을 준 이유는 chown을 쓰기 위함.

 

// 1001, 1002, 1003 생성 되서 user1, user2 지우고 (-r)

// user3을 지우고 나면 1001, 1002, 1003 생성된게 남아있으므로


 

// 정상적인 home dir. 의 모습

[root@localhost itbank]#
[root@localhost itbank]# ls -la /home/itbank
합계 12
drwx------. 5 itbank itbank 128  1월  3 12:41 .                    // uid와 gid가 모두 itbank 소유이다
drwxr-xr-x. 4 root   root    87  1월  3 12:41 ..
-rw-------. 1 itbank itbank   0  9월 25 15:31 .bash_history
-rw-r--r--. 1 itbank itbank  18  9월  7 01:25 .bash_logout
-rw-r--r--. 1 itbank itbank 193  9월  7 01:25 .bash_profile
-rw-r--r--. 1 itbank itbank 231  9월  7 01:25 .bashrc
drwxrwxr-x. 3 itbank itbank  18  9월 25 15:31 .cache
drwxrwxr-x. 3 itbank itbank  18  9월 25 15:31 .config
drwxr-xr-x. 4 itbank itbank  39  9월 25 14:49 .mozilla

// 삭제된 user3 home dir. 의 모습

[root@localhost ~]# ls -la /test/user3
합계 12
drwx------. 3 1003 1003  78  1월  3 12:41 .                        // userdel로 user3을 날려버려서 uid, gid 붕 뜸
drwxr-xr-x. 3 root root  19  1월  3 12:41 ..
-rw-r--r--. 1 1003 1003  18  9월  7 01:25 .bash_logout
-rw-r--r--. 1 1003 1003 193  9월  7 01:25 .bash_profile
-rw-r--r--. 1 1003 1003 231  9월  7 01:25 .bashrc
drwxr-xr-x. 4 1003 1003  39  9월 25 14:49 .mozilla

[root@localhost ~]# chown user3:user3 /test/user3
chown: 잘못된 사용자: `user3:user3'                                // 사용자 정보 없으니까

// user3 계정 재 생성 및 home dir. 생성
[root@localhost ~]#
[root@localhost ~]# useradd -d /test/user3 user3         // 여기서  uid, gid 지정해주면??? (옵션으로) ******************
useradd: 경고: 홈디렉터리가 이미 있습니다.    // ok
skel 디렉터리에서 파일을 복사하지 않습니다.  // 이미 있으니까
메일함 파일을 만드는 중: 파일이 있습니다      // ok
[root@localhost ~]#
[root@localhost ~]# ls -l /var/spool/mail/
합계 0
-rw-rw----. 1 itbank mail 0  9월 25 15:30 itbank
-rw-rw----. 1 rpc    mail 0  9월 25 14:53 rpc
-rw-rw----. 1   1003 mail 0  1월  3 12:41 user3
[root@localhost ~]#
[root@localhost ~]# tail -1 /etc/passwd
user3:x:1001:1001::/test/user3:/bin/bash    // uid, gid까지 동일하게 복구되지는 않음.

// user3 - uid, gid까지 복구

[root@localhost ~]# chown user3:user3 /test/user3
[root@localhost ~]#
[root@localhost ~]# ls -la /test/user3
합계 12
drwx------. 3 user3 user3  78  1월  3 12:41 .
drwxr-xr-x. 3 root  root   19  1월  3 12:41 ..
-rw-r--r--. 1  1003  1003  18  9월  7 01:25 .bash_logout
-rw-r--r--. 1  1003  1003 193  9월  7 01:25 .bash_profile
-rw-r--r--. 1  1003  1003 231  9월  7 01:25 .bashrc
drwxr-xr-x. 4  1003  1003  39  9월 25 14:49 .mozilla
[root@localhost ~]#
[root@localhost ~]# chown user3: /test/user3/.*        // 숨김 파일 모두 소유권 변경
[root@localhost ~]#
[root@localhost ~]# ls -la /test/user3
합계 12
drwx------. 3 user3 user3  78  1월  3 12:41 .
drwxr-xr-x. 3 user3 user3  19  1월  3 12:41 ..
-rw-r--r--. 1 user3 user3  18  9월  7 01:25 .bash_logout
-rw-r--r--. 1 user3 user3 193  9월  7 01:25 .bash_profile
-rw-r--r--. 1 user3 user3 231  9월  7 01:25 .bashrc
drwxr-xr-x. 4 user3 user3  39  9월 25 14:49 .mozilla

[root@localhost ~]#
[root@localhost ~]# chown root. /test
[root@localhost ~]#
[root@localhost ~]# ls -la /test/user3
합계 12
drwx------. 3 user3 user3  78  1월  3 12:41 .
drwxr-xr-x. 3 root  root   19  1월  3 12:41 ..
-rw-r--r--. 1 user3 user3  18  9월  7 01:25 .bash_logout
-rw-r--r--. 1 user3 user3 193  9월  7 01:25 .bash_profile
-rw-r--r--. 1 user3 user3 231  9월  7 01:25 .bashrc
drwxr-xr-x. 4 user3 user3  39  9월 25 14:49 .mozilla

// user3 - mail 소유권 지정

[root@localhost ~]#
[root@localhost ~]# ls -l /var/spool/mail/
합계 0
-rw-rw----. 1 itbank mail 0  9월 25 15:30 itbank
-rw-rw----. 1 rpc    mail 0  9월 25 14:53 rpc
-rw-rw----. 1   1003 mail 0  1월  3 12:41 user3
[root@localhost ~]#
[root@localhost ~]# chown user3 /var/spool/mail/user3
[root@localhost ~]#
[root@localhost ~]# ls -l /var/spool/mail
합계 0
-rw-rw----. 1 itbank mail 0  9월 25 15:30 itbank
-rw-rw----. 1 rpc    mail 0  9월 25 14:53 rpc
-rw-rw----. 1 user3  mail 0  1월  3 12:41 user3

[root@localhost ~]#
[root@localhost ~]# userdel -r user3        // 에러 안 뜨면 잘 복구된거 ㅋ
[root@localhost ~]#


// sol 1> 위 처럼 소유권 설정

// sol 2> 애초에 uid, gid 별도로 지정해주면 chown 안 해도 됨

=> sol 2> 방식으로 해보기

 

 

* 2nd 실습

=> 일반 dir.을 home dir. 로 변경!!!

cf. 허가권

일반 dir. : 755

사용자 홈 dir. 생성시 : 700

 

[root@localhost itbank]# rm -rf /home/itbank
[root@localhost itbank]#
[root@localhost itbank]# ls -l
합계 0
[root@localhost itbank]# ls -l /home/
합계 0
drwxr-xr-x. 2 root root 6 12월 26 15:20 itbank2
[root@localhost itbank]#
[root@localhost itbank]#
[root@localhost itbank]# mkdir /home/itbank            // mkdir로 생성시 755로 만들어짐
[root@localhost itbank]#
[root@localhost itbank]# ls -l /home
합계 0
drwxr-xr-x. 2 root root 6  1월  3 13:10 itbank
drwxr-xr-x. 2 root root 6 12월 26 15:20 itbank2
 

// 0. 현재 상태

// 날리기 전

[root@localhost ~]# ls -l /var/spool/mail
합계 0
-rw-rw----. 1 itbank mail 0  9월 25 15:30 itbank
-rw-rw----. 1 rpc    mail 0  9월 25 14:53 rpc
-rw-rw----. 1 user3  mail 0  1월  3 12:41 user3

 

// 날린 후

[root@localhost itbank]# ls -l /home
합계 0
drwxr-xr-x. 2 root root 6  1월  3 13:10 itbank               // uid, gid가
drwxr-xr-x. 2 root root 6 12월 26 15:20 itbank2
[root@localhost itbank]#
[root@localhost itbank]# tail -1 /etc/passwd
itbank:x:1000:1000:dust:/home/itbank:/bin/bash            // 1) uid, gid 붕 뜸 (잘못 봄..,)
[root@localhost itbank]#
[root@localhost itbank]# ls -l /home/itbank
합계 0                                                                // home dir. 은 삭제 후 mkdir로 일반 dir. 만든 상태
[root@localhost itbank]#
[root@localhost itbank]# ls -la /home/itbank
합계 0
drwxr-xr-x. 2 root root  6  1월  3 13:10 .                    // 따라서 skel 도 없음!
drwxr-xr-x. 4 root root 87  1월  3 13:10 ..
[root@localhost itbank]#
[root@localhost itbank]# tail -1 /etc/group
itbank:x:1000:
[root@localhost itbank]#
[root@localhost itbank]# ls -l /var/spool/mail
합계 0
-rw-rw----. 1 itbank mail 0  9월 25 15:30 itbank         // 2) mail 정보 있음
-rw-rw----. 1 rpc    mail 0  9월 25 14:53 rpc

=> /home/itbank itbank의 home 만 날리고 나머지 정보는 다 그대로 있음

 

1) skel 넣주고,

2) 소유권 잡아주기!

3) 사용자   home dir.를 허가권 700으로 바꿔줘야!

 

// skel 내용 이동

[root@localhost itbank]# cp -r /etc/skel/. /home/itbank
[root@localhost itbank]#

// 소유권 변경

[root@localhost itbank]# ls -la /home/itbank
합계 12
drwxr-xr-x. 3 root root  78  1월  3 13:23 .
drwxr-xr-x. 4 root root  87  1월  3 13:10 ..
-rw-r--r--. 1 root root  18  1월  3 13:23 .bash_logout
-rw-r--r--. 1 root root 193  1월  3 13:23 .bash_profile
-rw-r--r--. 1 root root 231  1월  3 13:23 .bashrc
drwxr-xr-x. 4 root root  39  1월  3 13:23 .mozilla
[root@localhost itbank]#
[root@localhost itbank]# chown -R itbank. /home/itbank        // -R : /home/itbank 하위에 있는 것들 다 변경(.. 제외)
[root@localhost itbank]#
[root@localhost itbank]# ls -la /home/itbank
합계 12
drwxr-xr-x. 3 itbank itbank  78  1월  3 13:23 .
drwxr-xr-x. 4 root   root    87  1월  3 13:10 ..
-rw-r--r--. 1 itbank itbank  18  1월  3 13:23 .bash_logout
-rw-r--r--. 1 itbank itbank 193  1월  3 13:23 .bash_profile
-rw-r--r--. 1 itbank itbank 231  1월  3 13:23 .bashrc
drwxr-xr-x. 4 itbank itbank  39  1월  3 13:23 .mozilla

 

// 사용자 home dir. 허가권 700으로 변경 => 나만 읽고 쓰고 접근할거!

[root@localhost itbank]# chmod go-rx /home/itbank
[root@localhost itbank]#
[root@localhost itbank]# ls -la /home/itbank
합계 12
drwx------. 3 itbank itbank  78  1월  3 13:23 .
drwxr-xr-x. 4 root   root    87  1월  3 13:10 ..
-rw-r--r--. 1 itbank itbank  18  1월  3 13:23 .bash_logout
-rw-r--r--. 1 itbank itbank 193  1월  3 13:23 .bash_profile
-rw-r--r--. 1 itbank itbank 231  1월  3 13:23 .bashrc
drwxr-xr-x. 4 itbank itbank  39  1월  3 13:23 .mozilla

 

// 끝나면 재 접근 해 보기~!

[root@localhost itbank]#
[root@localhost itbank]# cd /
[root@localhost /]#
[root@localhost /]# cd /home/itbank
[root@localhost itbank]#
[root@localhost itbank]# pwd
/home/itbank

반응형
LIST
Posted by 오정oI
, |
반응형
SMALL

※ 권한

- 허가권(Permission)

- 소유권(Ownership)

 

2. 소유권 (Ownership)

 

1> 소유권 구문 정리

 

[준비물 2]

[root@localhost itbank]# ls -ld /home
drwxr-xr-x. 4 root root 87 12월 29 12:49 /home

|----> 소유권

[사용형식]

chown UID:6ID directory 또는 file

 

[준비물]

cp /backup/* /home/itbank

ex)

chown UID directory 또는 파일

→ 파일이나 디렉터리의 UID만 변경

 

ex)

chown UID:GID directory  또는 file

→ 파일이나 디렉터리의 UID와 GID를 변경

 

ex)

chown :GID  directory 또는 file

→ 파일이나 디렉터리의 GID만 변경

 

* :(콜론)을 .(닷)으로 대체 사용 가능

 

ex)

chown UID: directory  또는 file

→ GID가 UID를 따라간다 (GID is default UID)

 

// 준비물

[root@localhost itbank]# cp /backup/* .
[root@localhost itbank]#
[root@localhost itbank]# ls -l
합계 24
-rw-r--r--. 1 root root 5078  1월  2 14:22 grub.cfg
-rw-r--r--. 1 root root  511  1월  2 14:22 inittab
-rw-r--r--. 1 root root 2028  1월  2 14:22 login.defs
-rw-r--r--. 1 root root 2116  1월  2 14:22 passwd
-rw-r--r--. 1 root root   21  1월  2 14:22 testfile2

// 파일이나 디렉터리의 UID만 변경

[root@localhost itbank]# chown itbank grub.cfg
[root@localhost itbank]#
[root@localhost itbank]# ls -l
합계 24
-rw-r--r--. 1 itbank root 5078  1월  2 14:22 grub.cfg
-rw-r--r--. 1 root   root  511  1월  2 14:22 inittab
-rw-r--r--. 1 root   root 2028  1월  2 14:22 login.defs
-rw-r--r--. 1 root   root 2116  1월  2 14:22 passwd
-rw-r--r--. 1 root   root   21  1월  2 14:22 testfile2

// 파일이나 디렉터리의  UID와 GID를 변경

[root@localhost itbank]# chown itbank:itbank inittab
[root@localhost itbank]#
[root@localhost itbank]# ls -l
합계 24
-rw-r--r--. 1 itbank root   5078  1월  2 14:22 grub.cfg
-rw-r--r--. 1 itbank itbank  511  1월  2 14:22 inittab
-rw-r--r--. 1 root   root   2028  1월  2 14:22 login.defs
-rw-r--r--. 1 root   root   2116  1월  2 14:22 passwd
-rw-r--r--. 1 root   root     21  1월  2 14:22 testfile2

[root@localhost itbank]# chown root:bonwon inittab    // 없는 그룹은 안됨!
chown: 잘못된 그룹: `root:bonwon'

[root@localhost itbank]# chown itbank:root login.defs
[root@localhost itbank]#
[root@localhost itbank]# ls -l
합계 24
-rw-r--r--. 1 itbank root   5078  1월  2 14:22 grub.cfg
-rw-r--r--. 1 itbank itbank  511  1월  2 14:22 inittab
-rw-r--r--. 1 itbank root   2028  1월  2 14:22 login.defs
-rw-r--r--. 1 root   root   2116  1월  2 14:22 passwd
-rw-r--r--. 1 root   root     21  1월  2 14:22 testfile2

// 파일이나 디렉터리의 GID만 변경

[root@localhost itbank]# chown :itbank passwd
[root@localhost itbank]#
[root@localhost itbank]# ls -l
합계 24
-rw-r--r--. 1 itbank root   5078  1월  2 14:22 grub.cfg
-rw-r--r--. 1 itbank itbank  511  1월  2 14:22 inittab
-rw-r--r--. 1 itbank root   2028  1월  2 14:22 login.defs
-rw-r--r--. 1 root   itbank 2116  1월  2 14:22 passwd
-rw-r--r--. 1 root   root     21  1월  2 14:22 testfile2

:(콜론)을 .(닷)으로 대체 사용 가능

[root@localhost itbank]# chown root.itbank grub.cfg
[root@localhost itbank]#
[root@localhost itbank]# ls -l
합계 24
-rw-r--r--. 1 root   itbank 5078  1월  2 14:22 grub.cfg
-rw-r--r--. 1 itbank itbank  511  1월  2 14:22 inittab
-rw-r--r--. 1 itbank root   2028  1월  2 14:22 login.defs
-rw-r--r--. 1 root   itbank 2116  1월  2 14:22 passwd
-rw-r--r--. 1 root   root     21  1월  2 14:22 testfile2
[root@localhost itbank]#
[root@localhost itbank]# chown root.root inittab
[root@localhost itbank]#
[root@localhost itbank]# ls -l
합계 24
-rw-r--r--. 1 root   itbank 5078  1월  2 14:22 grub.cfg
-rw-r--r--. 1 root   root    511  1월  2 14:22 inittab
-rw-r--r--. 1 itbank root   2028  1월  2 14:22 login.defs
-rw-r--r--. 1 root   itbank 2116  1월  2 14:22 passwd
-rw-r--r--. 1 root   root     21  1월  2 14:22 testfile2
[root@localhost itbank]#
[root@localhost itbank]# chown .root passwd
[root@localhost itbank]#
[root@localhost itbank]# ls -l
합계 24
-rw-r--r--. 1 root   itbank 5078  1월  2 14:22 grub.cfg
-rw-r--r--. 1 root   root    511  1월  2 14:22 inittab
-rw-r--r--. 1 itbank root   2028  1월  2 14:22 login.defs
-rw-r--r--. 1 root   root   2116  1월  2 14:22 passwd
-rw-r--r--. 1 root   root     21  1월  2 14:22 testfile2

// GID가 UID를 따라간다 (GID is default UID)

[root@localhost itbank]# chown itbank: login.defs
[root@localhost itbank]#
[root@localhost itbank]# ls -l
합계 24
-rw-r--r--. 1 root   itbank 5078  1월  2 14:22 grub.cfg
-rw-r--r--. 1 root   root    511  1월  2 14:22 inittab
-rw-r--r--. 1 itbank itbank 2028  1월  2 14:22 login.defs
-rw-r--r--. 1 root   root   2116  1월  2 14:22 passwd
-rw-r--r--. 1 root   root     21  1월  2 14:22 testfile2

2> 권한 개념 정리

 

① 소유권 먼저 봐야 (UID, GID.., 권한 있나 없나..,)

- 동일한 소유권이면(UID == GID) UID 먼저 봐야

   gid가  uid 따라감!

=> other에 'x'가 있으면,

1> index.html이 존재해야하고,

2> rw-r--r-- other에 'r'이 있어야..,

② root가 접속하면 소유권 허가권 다 무시!

=> 슈퍼 유저이므로.., (관리자 이므로..,)

 

/home/itbank     r    w    x    -    -    -    -    -    -    -

  itbank   ←   itbank                // 동일한 소유권이면 UID 먼저 봐야

/home/itbank/testfile1        // user에 'r'이 있어야..,

// 현재 itbank가 접속 중임..,

/var/www/html     -    w    x    -    -    x   r    w    -    

     root          root       // cd로 접근 가능? dir.소유권=> other를 봐야.., 소유권이 itbank 일 때, 접근 못함

    // itbank는 user도 아니고, group 권한도 없으므로 other임~!!!

     root          itbank    // dir.소유권=> group을 봐야..,upload(X) /  웹(인터넷) 허가권=> other 'x'

     itbank        root      // dir.소유권=> user, upload(○) /  웹(인터넷) 허가권=> other 'x'         

     itbank   ←  itbank    // dir.소유권=> user, upload(○) /  웹(인터넷) 허가권=> other 'x'   

    // 똑같으면 UID만 보자!

if                         itbank   ←   itbank

     r - -            r w x    // UID를 따르므로 접근불가!

 

내용은 이 디렉터리 안에 index.html의 권한을 봐야..,

 

* /home 디렉터리 날라갔을 때?

 

# ls -l /home

# rm -rf /home/itbank

 

#  cd /

# userdel -r itbank

# useradd -c dust itbank

# passwd itbank

itbank

# cd /home/itbank


 

 

[준비물 1]

[root@localhost itbank]# chmod 700 .
[root@localhost itbank]#
[root@localhost itbank]# ls -ld
drwx------. 5 itbank itbank 144  1월  2 13:55 .
[root@localhost itbank]#
[root@localhost itbank]# pwd
/home/itbank
[root@localhost itbank]#
[root@localhost itbank]# rm -rf *
[root@localhost itbank]#
[root@localhost itbank]# ls
반응형
LIST
Posted by 오정oI
, |
반응형
SMALL

※ 권한

- 허가권(Permission)

- 소유권(Ownership)

 

1. 허가권(Permission)

 

1> 허가권

 

[준비물]

// 허가권

[root@localhost ~]# ls -ld /home
drwxr-xr-x. 4 root root 87 12월 29 12:49 /home
[root@localhost ~]#
[root@localhost ~]# ls -l /etc/passwd
-rw-r--r--. 1 root root 2116 12월 29 13:19 /etc/passwd


      Owner(User)         Group             Other

      2^2 2^1 2^0    2^2 2^1 2^0   2^2 2^1 2^0   

d (directory)    |    r    w    x    |    r    w    x    |    r    w    x    |

- (file)            |    4    2    1    |    4    2    1    |    4    2    1   |

   x 100                x 10                 x 1

 

각 구간마다 최대로 나올 수 있는 값은? 7

각 구간마다 최소로 나올 수 있는 값은? 0

허가권은 8진수 모드로 이루어져 있음

 

8진수 기반

rwx = 7

rw- = 6

r-x = 5

r-- = 4

-wx = 3

-w- = 2

--x = 1

--- = 0

 

2> r w x 의미

r(read) : 읽기

w(write) : 쓰기

x(execute) : 실행(또는 접근)

 

* 특징

'x'에 대해서

file에 'x'가 없으면 문서파일(텍스트 파일)

file에 'x'가 있으면 실행파일

directory에 'x'가 있으면 접근이 가능하다

또는

directory에 'x'가 없으면 접근이 불가능하다

 

file에서 'r'은 문서 내용 출력(cat..,), 'w'는 문서 편집(vi), 'x'는 실행(execute)

(단! 문서파일에는 'x'가 없음)

 

directory에서 'r'은 디렉터리 목록 출력(ls), 'w'는 생성, 이동, 복사, 삭제(mkdir, mv, cp, rm), 'x'는 접근(cd)

 

[root@localhost ~]# ls -l /etc/passwd
-rw-r--r--. 1 root root 2116 12월 29 13:19 /etc/passwd        // 문서파일
[root@localhost ~]#
[root@localhost ~]# ls -l /usr/bin/ls
-rwxr-xr-x. 1 root root 117656 11월  6  2016 /usr/bin/ls      // 실행파일
root@localhost ~]#
[root@localhost ~]# ls -ld /home
drwxr-xr-x. 4 root root 87 12월 29 12:49 /home               // 접근 가능 dir.

 

[Key point]

- 각 내용에서 어디가 중요한가?

문서파일 r w -         // 보여줄지 말지..,

실행파일 r w x        // 접근을 줄지 말지..,

디렉터리 r w x        // 접근(x), 보기(r)는 되는데, 편집권한(w)을 줄지 말지..,

 

 

3> 허가권 변경

사용형식

chmod [permission] directory 또는 파일

    |-------> numeric(숫자)

    |-------> symbolic(문자)

 

1) numeric (일반권한에 적용됨)

준비물

--x-w--wx       ->     r--r-xrw-

chmod 456 directory 또는 file

 

2) symbolic (특수권한에 적용됨)

준비물

rwxrw-r-x    ->    rw--wx-w-

chmod u-x,g-r,g+x,o-r,o+w,o-x  directory 또는 file

 

// 기타 처리

[root@localhost ~]# userdel -r battlegrounds
[root@localhost ~]#
[root@localhost ~]# groupdel lol
[root@localhost ~]#
[root@localhost ~]# rm -rf /overwatch/
[root@localhost ~]#
[root@localhost ~]# rm -rf /fifaonline3
[root@localhost ~]#
[root@localhost ~]# ls /
AS      bin   dev  home  lib64  mnt  proc  run   srv  tmp  var
backup  boot  etc  lib   media  opt  root  sbin  sys  usr
[root@localhost ~]#
[root@localhost ~]# tail -1 /etc/passwd
itbank:x:1000:1000:dust:/home/itbank:/bin/bash
[root@localhost ~]#
[root@localhost ~]# tail -1 /etc/group
itbank:x:1000:
[root@localhost ~]#
[root@localhost ~]#

 

<실습 1>

 

허가권 변경 실습

/backup/grub.cfg 파일을 /home/itbank 홈 디렉터리에 복사한 후 변경

 

numeric → rw--w--wx        // 623

symbolic → -wxr-xrw-      // 356

numeric → r-x-w-rw-        // 526

symbolic → -w--wxr-x      // 235

 

[root@localhost itbank]# cp /backup/grub.cfg ./     //  /home/itbank
[root@localhost itbank]#
[root@localhost itbank]# ls -l /home/itbank
합계 8
-rw-r--r--. 1 root root 5078 12월 29 14:25 grub.cfg
[root@localhost itbank]#
[root@localhost itbank]# chmod 623 grub.cfg
[root@localhost itbank]#
[root@localhost itbank]# ls -l      // grub.cfg
-rw--w--wx. 1 root root 5078 12월 29 14:25 grub.cfg
[root@localhost itbank]#
[root@localhost itbank]# chmod u-r,u+x,g+r,g-w,g+x,o+r,o-x grub.cfg
[root@localhost itbank]#
[root@localhost itbank]# ls -l
--wxr-xrw-. 1 root root 5078 12월 29 14:25 grub.cfg
[root@localhost itbank]#
[root@localhost itbank]# chmod 526 grub.cfg
[root@localhost itbank]#
[root@localhost itbank]# ls -l
-r-x-w-rw-. 1 root root 5078 12월 29 14:25 grub.cfg
[root@localhost itbank]#
[root@localhost itbank]# chmod u-r,u+w,u-x,g+x,g+w,o-w,o+x grub.cfg
[root@localhost itbank]#
[root@localhost itbank]# ls -l
합계 8
--w--wxr-x. 1 root root 5078 12월 29 14:25 grub.cfg
[root@localhost itbank]#

=> r-x-w-r--

chmod u+r,u-w,u+x,g-x,o-x

chmod u+r-w+x,go-x

chmod u+rx-w,go-x

 

chmod ugo+r     ==   chmod a+r        // a: all

 

=> rw-r--r--    (644)

chmod a+r,go-wx grub.cfg

또는

chmod u=rw,go=r grub.cfg

 

<실습2>

[준비물]

1) Internet Explorer  리눅스 ip 입력 192.168.8.174

2) 각자 windows 개인폴더 안에 ' 새 텍스트 문서' 파일 생성

3) 셍성한 파일에 내용 입력

4) 다른이름으로 저장 눌러서

   파일 이름: index.html / 파일형식 : 모든 파일 / 인코딩 : utf-8

5) ftp 서비스 이용 index.html > 리눅스 /home/itbank 홈 디렉터리 하위에 업로드

   index.html 파일이 존재하는지 확인

6) /home/itbank/index.html 을 /var/www/html로 이동

7) 인터넷 웹 브라우저 F5

 

위 설정이 다 되었으면 아래의 실습을 진행!

/var/www/html/index.html의 허가권을 바꾸어서 웹 페이지 내용을 확인하는 테스트

-w-r--r--(numeric)        // 244 : User쪽에 x는 원래 없고 w가 있으므로 접근 가능=> Other 쪽을 봐야 하는듯..,

rw----r--(symbolic)       // 604 : w가 여전히 있음..,

rw-r-----(symbolic)       // 640 : r 없음!

 

 

// 5)

 

[cmd]

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.

C:\Users\user>e:

E:\>cd 2*

E:\201709월JAVA심야반 (지우지마세요)>cd ..

E:\>cd 2_12*

E:\2_12월_평일12시_리눅스1_Junga>dir
 E 드라이브의 볼륨: 새 볼륨
 볼륨 일련 번호: 0AAB-DADF

 E:\2_12월_평일12시_리눅스1_Junga 디렉터리

2017-12-29  오후 02:51    <DIR>          .
2017-12-29  오후 02:51    <DIR>          ..
2017-12-29  오후 12:38    <DIR>          1_압축푼거
2013-05-28  오후 05:56         1,816,712 HangulPuTTY-0[1].60h.setup.exe
2017-12-29  오후 02:52                24 index.html
2017-12-28  오후 02:46    <DIR>          temp
2017-12-18  오후 03:06                33 testfile.txt
2017-12-18  오후 03:06                15 testfile2.txt
2017-12-29  오후 02:51                21 새 텍스트 문서.txt
               5개 파일           1,816,805 바이트
               4개 디렉터리  339,256,086,528 바이트 남음

E:\2_12월_평일12시_리눅스1_Junga>ftp
ftp> open 192.168.8.174
192.168.8.174에 연결되었습니다.
220 (vsFTPd 3.0.2)
사용자(192.168.8.174:(none)): itbank
331 Please specify the password.
암호:
230 Login successful.
ftp>
ftp> pwd
257 "/home/itbank"
ftp> put index.html
200 PORT command successful. Consider using PASV.
150 Ok to send data.
226 Transfer complete.
ftp: 0.00초 24.00KB/초
ftp>
ftp>

[puTTY]

[root@localhost itbank]# ifconfig | head -n2
ens32: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.8.174  netmask 255.255.255.0  broadcast 192.168.8.255

[root@localhost itbank]# ls -l
합계 12
-rw-r--r--. 1 root   root   5078 12월 29 14:25 grub.cfg
-rw-r--r--. 1 itbank itbank   24 12월 29 14:56 index.html

// 6)

[root@localhost itbank]# mv index.html /var/www/html
[root@localhost itbank]#
[root@localhost itbank]# ls -l /var/www/html/
합계 4
-rw-r--r--. 1 itbank itbank 24 12월 29 14:56 index.html

 

// 실습

=> 인터넷 출력은 Other에 영향이 있다

[root@localhost itbank]# cd /var/www/html/
[root@localhost html]#
[root@localhost html]# ls -l
합계 4
-rw-r--r--. 1 itbank itbank 24 12월 29 14:56 index.html
[root@localhost html]#
[root@localhost html]# chmod 244 index.html
[root@localhost html]#
[root@localhost html]# ls -l
합계 4
--w-r--r--. 1 itbank itbank 24 12월 29 14:56 index.html
[root@localhost html]#
[root@localhost html]# chmod u=rw,o=r index.html
[root@localhost html]#
[root@localhost html]# ls -l
합계 4
-rw-r--r--. 1 itbank itbank 24 12월 29 14:56 index.html
[root@localhost html]#
[root@localhost html]# chmod u=rw,g=,o=r index.html
[root@localhost html]#
[root@localhost html]# ls -l
합계 4
-rw----r--. 1 itbank itbank 24 12월 29 14:56 index.html
[root@localhost html]#
[root@localhost html]# chmod u=rw,g=r,o= index.html
[root@localhost html]#
[root@localhost html]# ls -l
합계 4
-rw-r-----. 1 itbank itbank 24 12월 29 14:56 index.html
[root@localhost html]#
[root@localhost html]# chmod 244 index.html
[root@localhost html]#
[root@localhost html]# ls -; /var/www/html/
ls: cannot access -: 그런 파일이나 디렉터리가 없습니다
-bash: /var/www/html/: 디렉터리입니다
[root@localhost html]# ls -l /var/www/html/
합계 4
--w-r--r--. 1 itbank itbank 24 12월 29 14:56 index.html
[root@localhost html]# chmod 003 index.html
[root@localhost html]#
[root@localhost html]# ls -l
합계 4
--------wx. 1 itbank itbank 24 12월 29 14:56 index.html
[root@localhost html]# chmod 004 index.html
[root@localhost html]#
[root@localhost html]# ls -l
합계 4
-------r--. 1 itbank itbank 24 12월 29 14:56 index.html
[root@localhost html]# chmod 000 index.html
[root@localhost html]#
[root@localhost html]# ls -l
합계 4
----------. 1 itbank itbank 24 12월 29 14:56 index.html
[root@localhost html]#
[root@localhost html]# chmod 004 index.html
[root@localhost html]#
[root@localhost html]# ls -l
합계 4
-------r--. 1 itbank itbank 24 12월 29 14:56 index.html
[root@localhost html]#

 

<실습 3>

/var/www/html 디렉터리의 허가권을 바꾸면서 내용 출력 test!

    r w x r w x r - x (numeric)    // 775

               - w x r - x r - x (numeric)     // 355

                r - x r - x r - x (numeric)     // 555

                r w - r - x r - x (numeric)    // 655

                r w x - - x r - x (symbolic)  // 715

                r w x r - - r - x (symbolic)  // 745

                r w x r - x - - x (symbolic) // 751

                r w x r - x r - - (symbolic) // 754    ==> other에 x가 없음! Internet은 other~!!!

리눅스 캐시 메모리 비우기?

[정리]

/var/www/html/index.html

   ↓    rw-r--r--

rwxr-xr--

  접근 x

=> other에 접근(x) 이 없어서 html 디렉터리 내부에 index.html 파일이 존재하는지 알 수 없음!

 

 

[root@localhost www]# pwd
/var/www
[root@localhost www]#
[root@localhost www]# chmod 775 html
[root@localhost www]#
[root@localhost www]# ls -ld
drwxr-xr-x. 4 root root 33  9월 25 15:21 .
[root@localhost www]#
[root@localhost www]# ls
cgi-bin  html
[root@localhost www]# ls -ld html/
drwxrwxr-x. 2 root root 24 12월 29 15:02 html/
[root@localhost www]#
[root@localhost www]# cd /home/itbank
[root@localhost itbank]#
[root@localhost itbank]# chmod 355 /var/www/html
[root@localhost itbank]#
[root@localhost itbank]# ls -ld
drwx------. 5 itbank itbank 144 12월 29 15:02 .
[root@localhost itbank]# ls -ld
drwx------. 5 itbank itbank 144 12월 29 15:02 .
[root@localhost itbank]# ls -l
합계 8
-rw-r--r--. 1 root root 5078 12월 29 14:25 grub.cfg
[root@localhost itbank]# ls -ld /var/www/html/
d-wxr-xr-x. 2 root root 24 12월 29 15:02 /var/www/html/
[root@localhost itbank]#
[root@localhost itbank]#
[root@localhost itbank]# chmod 555 /var/www/html/
[root@localhost itbank]#
[root@localhost itbank]# ls -ld /var/www/html/
dr-xr-xr-x. 2 root root 24 12월 29 15:02 /var/www/html/
[root@localhost itbank]#
[root@localhost itbank]# chmod 655 /var/www/html/
[root@localhost itbank]#
[root@localhost itbank]# ls -ld /var/www/html/
drw-r-xr-x. 2 root root 24 12월 29 15:02 /var/www/html/
[root@localhost itbank]# chmod u+x,g-r /var/www/html
[root@localhost itbank]#
[root@localhost itbank]# ls -ld /var/www/html
drwx--xr-x. 2 root root 24 12월 29 15:02 /var/www/html
[root@localhost itbank]#
[root@localhost itbank]# chmod g+r-x /var/www/html/
[root@localhost itbank]#
[root@localhost itbank]# ls -ld /var/www/html/
drwxr--r-x. 2 root root 24 12월 29 15:02 /var/www/html/
[root@localhost itbank]#
[root@localhost itbank]# chmod g+x,o-r /var/www/html/
[root@localhost itbank]#
[root@localhost itbank]# ls -ld /var/www/html/
drwxr-x--x. 2 root root 24 12월 29 15:02 /var/www/html/
[root@localhost itbank]#
[root@localhost itbank]# chmod o+r-x /var/www/html/
[root@localhost itbank]#
[root@localhost itbank]# ls -ld /var/www/html/
drwxr-xr--. 2 root root 24 12월 29 15:02 /var/www/html/
[root@localhost itbank]# chmod o+x /var/www/html/
[root@localhost itbank]#
[root@localhost itbank]# ls -ld /var/www/html
drwxr-xr-x. 2 root root 24 12월 29 15:02 /var/www/html

 

<실습 4>

/home/itbank 홈 디렉터리의 허가권을 변경하면서 테스트 해보기

r w x - - - - - -

1) ftp 접속이 되는가?  ○

2) testfile1 이 보이는가?   (ftp> ls)

3) index.html 파일 업로드 되는가? (ftp> put index.html)

 4) 600, 500, 400, 300, 200, 100을 실습!!

 

디렉터리와 파일의 소유권은 다름.

- 디렉터리에 r이 없으면 ls 검색 시, 파일명 등이 ??? 로 뜸

- 파일 내용은 파일의 소유권을 봐야..,

(∵ 파일 내용 : cat 

    디렉터리 목록 : ls )

 

[준비물]

[root@localhost itbank]# rm -rf /var/www/html/index.html
[root@localhost itbank]#
[root@localhost itbank]# ls -l /var/www/html/
합계 0
[root@localhost itbank]#
[root@localhost itbank]# rm -rf *
[root@localhost itbank]#
[root@localhost itbank]# touch testfile1
[root@localhost itbank]#
[root@localhost itbank]# ls -l
합계 0
-rw-r--r--. 1 root root 0  1월  2 13:20 testfile1    

///////////////////// TEST 7 /////////////////////

[puTTY]

[root@localhost itbank]# chmod 100 /home/itbank
[root@localhost itbank]#
[root@localhost itbank]# ls -ld
d--x------. 5 itbank itbank 144  1월  2 13:55 .

[cmd]

E:\2_12월_평일12시_리눅스1_Junga>ftp
ftp> open 192.168.8.174
192.168.8.174에 연결되었습니다.
220 (vsFTPd 3.0.2)
사용자(192.168.8.174:(none)): itbank
331 Please specify the password.
암호:
230 Login successful.
ftp> ls
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
226 Transfer done (but failed to open directory).
ftp>
ftp> put index.html
200 PORT command successful. Consider using PASV.
553 Could not create file.
ftp>
ftp>


[puTTY]

[root@localhost itbank]# ls
testfile

=> 1) (○)

=> 2) (X)

=> 1) (X)

///////////////////// TEST 6 /////////////////////

[puTTY]

[root@localhost itbank]# chmod 200 /home/itbank
[root@localhost itbank]#
[root@localhost itbank]# ls -ld
d-w-------. 5 itbank itbank 144  1월  2 13:55 .

[cmd]

E:\2_12월_평일12시_리눅스1_Junga>ftp
ftp> open 192.168.8.174
192.168.8.174에 연결되었습니다.
220 (vsFTPd 3.0.2)
사용자(192.168.8.174:(none)): itbank
331 Please specify the password.
암호:
500 OOPS: cannot change directory:/home/itbank
원격 호스트에 의해 연결이 닫혔습니다.
ftp>


[puTTY]

[root@localhost itbank]# ls
index.html  testfile1

=> 1) (X)

///////////////////// TEST 5 /////////////////////

[puTTY]

[root@localhost itbank]# chmod 300 /home/itbank
[root@localhost itbank]#
[root@localhost itbank]# ls -ld
d-wx------. 5 itbank itbank 145  1월  2 13:31 .

[cmd]

E:\2_12월_평일12시_리눅스1_Junga>ftp
ftp> open 192.168.8.174
192.168.8.174에 연결되었습니다.
220 (vsFTPd 3.0.2)
사용자(192.168.8.174:(none)): itbank
331 Please specify the password.
암호:
230 Login successful.
ftp>
ftp> ls
200 PORT command successful. Consider using PASV.    // ls는 먹힘
150 Here comes the directory listing.                
226 Transfer done (but failed to open directory).          // 그런데 파일은 못 봄
ftp>
ftp> put index.html
200 PORT command successful. Consider using PASV.
150 Ok to send data.
226 Transfer complete.
ftp: 0.00초 24000.00KB/초
ftp>
[puTTY]

[root@localhost itbank]# ls
index.html  testfile1

=> 1) (○)

=> 2) (X)

=> 3) (○) 

// 파일 편집은 되나?

: 편집은 되는데 내용이 정확히 안보임..,

 

   

///////////////////// TEST 4 /////////////////////

[puTTY]

[root@localhost itbank]# chmod 400 /home/itbank
[root@localhost itbank]#
[root@localhost itbank]# ls -ld
dr--------. 5 itbank itbank 145  1월  2 13:31 .

 

[cmd]

E:\2_12월_평일12시_리눅스1_Junga>ftp
ftp> open 192.168.8.174
192.168.8.174에 연결되었습니다.
220 (vsFTPd 3.0.2)
사용자(192.168.8.174:(none)): itbank
331 Please specify the password.
암호:
500 OOPS: cannot change directory:/home/itbank
원격 호스트에 의해 연결이 닫혔습니다.

[puTTY]

[root@localhost itbank]# ls
testfile1

=> 1) (X)

   

///////////////////// TEST 3 /////////////////////

[puTTY]

[root@localhost itbank]# chmod 500 /home/itbank    
[root@localhost itbank]#
[root@localhost itbank]# ls -ld /home/itbank
dr-x------. 5 itbank itbank 145  1월  2 13:31 /home/itbank

 

[cmd]

E:\2_12월_평일12시_리눅스1_Junga>
E:\2_12월_평일12시_리눅스1_Junga>ftp
ftp> open 192.168.8.174
192.168.8.174에 연결되었습니다.
220 (vsFTPd 3.0.2)
사용자(192.168.8.174:(none)): itbank
331 Please specify the password.
암호:
230 Login successful.
ftp>
ftp> ls
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
testfile1
226 Directory send OK.
ftp: 0.00초 11.00KB/초
ftp>
ftp> put index.html
200 PORT command successful. Consider using PASV.
553 Could not create file.
ftp>
ftp>

[puTTY]

[root@localhost itbank]# ls
testfile1

=> 1) (○)

=> 2) (○)

=> 3) (X)    // upload는 'w' 와 관련되어 있다! 쓰기가 안됨

// [cmd]

# pwd

/home/itbank // 얘 한테 업로드 해주는데, 얘가 w가 없어서 안됨..,

 

 

 

 

///////////////////// TEST 2 /////////////////////

[puTTY]

[root@localhost itbank]# chmod 600 /home/itbank
[root@localhost itbank]#
[root@localhost itbank]# ls -ld /home/itbank
drw-------. 5 itbank itbank 145  1월  2 13:31 /home/itbank    // 600

[cmd]

E:\2_12월_평일12시_리눅스1_Junga>
E:\2_12월_평일12시_리눅스1_Junga>ftp
ftp> open 192.168.8.174
192.168.8.174에 연결되었습니다.
220 (vsFTPd 3.0.2)
사용자(192.168.8.174:(none)): itbank
331 Please specify the password.
암호:
500 OOPS: cannot change directory:/home/itbank
원격 호스트에 의해 연결이 닫혔습니다.            
ftp>
ftp>

//==> 접근불가~!! (owner에 x가 없으므로)

// => 1) (x)

// => 2) (x)

// => 3) (x)

///////////////////// TEST 1 /////////////////////

[puTTY]

[root@localhost itbank]# ls -ld
drwx------. 5 itbank itbank 145  1월  2 13:20 .        // 700
[root@localhost itbank]#

[cmd]

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.

C:\Users\user>E:

E:\>cd 2_12*

E:\2_12월_평일12시_리눅스1_Junga>pwd
'pwd'은(는) 내부 또는 외부 명령, 실행할 수 있는 프로그램, 또는
배치 파일이 아닙니다.

E:\2_12월_평일12시_리눅스1_Junga>
E:\2_12월_평일12시_리눅스1_Junga>ls
'ls'은(는) 내부 또는 외부 명령, 실행할 수 있는 프로그램, 또는
배치 파일이 아닙니다.

E:\2_12월_평일12시_리눅스1_Junga>cd
E:\2_12월_평일12시_리눅스1_Junga

E:\2_12월_평일12시_리눅스1_Junga>
E:\2_12월_평일12시_리눅스1_Junga>dir
 E 드라이브의 볼륨: 새 볼륨
 볼륨 일련 번호: 0AAB-DADF

 E:\2_12월_평일12시_리눅스1_Junga 디렉터리

2017-12-29  오후 02:51    <DIR>          .
2017-12-29  오후 02:51    <DIR>          ..
2018-01-02  오후 12:34    <DIR>          1_압축푼거
2013-05-28  오후 05:56         1,816,712 HangulPuTTY-0[1].60h.setup.exe
2017-12-29  오후 02:52                24 index.html
2018-01-02  오후 12:59    <DIR>          temp
2017-12-18  오후 03:06                33 testfile.txt
2017-12-18  오후 03:06                15 testfile2.txt
2017-12-29  오후 02:51                21 새 텍스트 문서.txt
               5개 파일           1,816,805 바이트
               4개 디렉터리  339,256,086,528 바이트 남음

E:\2_12월_평일12시_리눅스1_Junga>ftp
ftp> open 192.168.8.174
192.168.8.174에 연결되었습니다.
220 (vsFTPd 3.0.2)
사용자(192.168.8.174:(none)): itbank
331 Please specify the password.
암호:
230 Login successful.
ftp>
ftp> pwd
257 "/home/itbank"
ftp>
ftp> ls
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
testfile1
226 Directory send OK.
ftp: 0.00초 11000.00KB/초
ftp>
ftp> put index.html
200 PORT command successful. Consider using PASV.
150 Ok to send data.
226 Transfer complete.
ftp: 0.00초 24.00KB/초
ftp>
ftp> quit
221 Goodbye.

E:\2_12월_평일12시_리눅스1_Junga>

[puTTY]

// cmd 접속 끊기 전

[root@localhost itbank]# ls
index.html  testfile1


// cmd 접속 끊은 후

[root@localhost itbank]# rm -rf index.html

반응형
LIST
Posted by 오정oI
, |
반응형
SMALL

* 그룹(Group)

- 함께 행동하거나 공통점이 있어서 한데 묶일 수 있는 사람들의 무리

0> 추가

# useradd -g 그룹명 계정명

→ 사용자 계정 생성시 그룹을 지정 

별도의 그룹이 필요할 때

-----------------------------

# usermod -g 그룹명 계정명

→ 사용자 계정의 기본 그룹을 수정

# usermod -G 그룹명 계정명

→ 사용자 계정의 그룹을 추가 (2차 그룹 생성됨)

(참고로 -G  옵션을 사용할 때 

-a 옵션을 같이 사용할 수 있음)

 

id

- 사용자 계정의 UID와 GID, 소속된 그룹을 ls 확인할 때

사용형식

# id 계정명

 

1> 그룹생성

 

사용형식

groupadd 그룹명

→ 그룹을 생성할 때

groupadd [option] [argument] 그룹명

→ 그룹을 생성할 때 옵션을 사용해서

option

-g : gid를 지정

 

2> 그룹 수정

사용형식

groupmod [option] [argument]

option

-g : gid를 수정할 때

-n : 그룹명을 수정할 때

 

3> 그룹 삭제

사용형식

groupdel 그룹명

 

 

[root@localhost itbank]# tail -1 /etc/passwd
itbank:x:1000:1000:dust:/home/itbank:/bin/bash
[root@localhost itbank]#


// 그룹 생성

[root@localhost itbank]# groupadd a1
[root@localhost itbank]#
[root@localhost itbank]# tail -2 /etc/group
itbank:x:1000:
a1:x:1001:
[root@localhost itbank]#

// 그룹 생성시 그룹만 만들어지고 사용자는 안 생성됨

// 거꾸로 사용자 생성시 그룹도 자동 만들어짐

 

// gid 지정 그룹 생성

[root@localhost itbank]# groupadd -g 2000 a2
[root@localhost itbank]#
[root@localhost itbank]# tail -3 /etc/group
itbank:x:1000:
a1:x:1001:
a2:x:2000:
[root@localhost itbank]# groupadd a3
[root@localhost itbank]#
[root@localhost itbank]# tail -4 /etc/group
itbank:x:1000:
a1:x:1001:
a2:x:2000:
a3:x:2001:

 

 

// 그룹 gid 수정 -g

[root@localhost itbank]# groupmod -g 1002 a3
[root@localhost itbank]#
[root@localhost itbank]# tail -4 /etc/group
itbank:x:1000:
a1:x:1001:
a2:x:2000:
a3:x:1002:
[root@localhost itbank]#

// 그룹 name 수정 -n

[root@localhost itbank]# groupmod -n a4 a3
[root@localhost itbank]#
[root@localhost itbank]# tail -4 /etc/group
itbank:x:1000:
a1:x:1001:
a2:x:2000:
a4:x:1002:

// 그룹 삭제

[root@localhost itbank]# groupdel a4
[root@localhost itbank]# groupdel a2
[root@localhost itbank]# groupdel a1
[root@localhost itbank]#
[root@localhost itbank]# tail -4 /etc/group
ntp:x:38:
tcpdump:x:72:
apache:x:48:
itbank:x:1000:

 


 

// useradd -g를 통한 그룹 생성 및 삭제

[root@localhost itbank]# useradd user100
[root@localhost itbank]#
[root@localhost itbank]# tail -2 /etc/passwd
itbank:x:1000:1000:dust:/home/itbank:/bin/bash
user100:x:1001:1001::/home/user100:/bin/bash
[root@localhost itbank]#
[root@localhost itbank]# tail -2 /etc/group
itbank:x:1000:
user100:x:1001:
[root@localhost itbank]#
[root@localhost itbank]# ls -la /home/user100
합계 12
drwx------. 4 user100 user100  92 12월 28 14:13 .
drwxr-xr-x. 5 root    root    102 12월 28 14:13 ..
-rw-r--r--. 1 user100 user100  18  9월  7 01:25 .bash_logout
-rw-r--r--. 1 user100 user100 193  9월  7 01:25 .bash_profile
-rw-r--r--. 1 user100 user100 231  9월  7 01:25 .bashrc
drwxr-xr-x. 4 user100 user100  39  9월 25 14:49 .mozilla
drwxr-xr-x. 2 user100 user100   6 12월 27 13:52 public
[root@localhost itbank]#
[root@localhost itbank]# userdel -r user100
[root@localhost itbank]#
[root@localhost itbank]# groupadd testgroup
[root@localhost itbank]#
[root@localhost itbank]# tail -1 /etc/passwd
itbank:x:1000:1000:dust:/home/itbank:/bin/bash
[root@localhost itbank]#
[root@localhost itbank]# tail -2 /etc/group
itbank:x:1000:
testgroup:x:1001:
[root@localhost itbank]# useradd -g testgroup user100
[root@localhost itbank]#
[root@localhost itbank]# tail -2 /etc/passwd
itbank:x:1000:1000:dust:/home/itbank:/bin/bash
user100:x:1001:1001::/home/user100:/bin/bash
[root@localhost itbank]#
[root@localhost itbank]# tail -2 /etc/group
itbank:x:1000:
testgroup:x:1001:
[root@localhost itbank]#
[root@localhost itbank]# ls -la /home/user100
합계 12
drwx------. 4 user100 testgroup  92 12월 28 14:15 .
drwxr-xr-x. 5 root    root      102 12월 28 14:15 ..
-rw-r--r--. 1 user100 testgroup  18  9월  7 01:25 .bash_logout
-rw-r--r--. 1 user100 testgroup 193  9월  7 01:25 .bash_profile
-rw-r--r--. 1 user100 testgroup 231  9월  7 01:25 .bashrc
drwxr-xr-x. 4 user100 testgroup  39  9월 25 14:49 .mozilla
drwxr-xr-x. 2 user100 testgroup   6 12월 27 13:52 public
[root@localhost itbank]#
[root@localhost itbank]# userdel -r user100
[root@localhost itbank]#
[root@localhost itbank]# tail -1 /etc/passwd
itbank:x:1000:1000:dust:/home/itbank:/bin/bash
[root@localhost itbank]#
[root@localhost itbank]# tail -2 /etc/group
itbank:x:1000:
testgroup:x:1001:
[root@localhost itbank]# groupdel testgroup
[root@localhost itbank]#
[root@localhost itbank]# tail -1 /etc/group
itbank:x:1000:
[root@localhost itbank]#

 

// usermod -g 기본그룹명 수정 

[root@localhost itbank]# useradd user100
[root@localhost itbank]#
[root@localhost itbank]# tail -1 /etc/passwd
user100:x:1001:1001::/home/user100:/bin/bash
[root@localhost itbank]# tail -1 /etc/group

user100:x:1001:
[root@localhost itbank]#
[root@localhost itbank]# groupadd soccer
[root@localhost itbank]#
[root@localhost itbank]# tail -2 /etc/group
user100:x:1001:
soccer:x:1002:
[root@localhost itbank]#
[root@localhost itbank]# id user100
uid=1001(user100) gid=1001(user100) groups=1001(user100)
[root@localhost itbank]#
[root@localhost itbank]# usermod -g soccer user100
[root@localhost itbank]#
[root@localhost itbank]# tail -1 /etc/passwd
user100:x:1001:1002::/home/user100:/bin/bash
[root@localhost itbank]#
[root@localhost itbank]# id user100
uid=1001(user100) gid=1002(soccer) groups=1002(soccer)
[root@localhost itbank]#

// usermod -G 그룹 추가

[root@localhost itbank]# usermod -g user100 user100
[root@localhost itbank]#
[root@localhost itbank]# tail -1 /etc/passwd
user100:x:1001:1001::/home/user100:/bin/bash
[root@localhost itbank]#
[root@localhost itbank]# id user100
uid=1001(user100) gid=1001(user100) groups=1001(user100)
[root@localhost itbank]#
[root@localhost itbank]# usermod -G soccer user100
[root@localhost itbank]#
[root@localhost itbank]# tail -1 /etc/passwd
user100:x:1001:1001::/home/user100:/bin/bash
[root@localhost itbank]#
[root@localhost itbank]# tail -2 /etc/group
user100:x:1001:
soccer:x:1002:user100
[root@localhost itbank]# id user100
uid=1001(user100) gid=1001(user100) groups=1001(user100),1002(soccer)
[root@localhost itbank]#

// usermod -G  3차그룹명 -a 그룹명

[root@localhost itbank]# groupadd golf
[root@localhost itbank]#
[root@localhost itbank]# usermod -G golf user100
[root@localhost itbank]#
[root@localhost itbank]# tail -3 /etc/group
user100:x:1001:
soccer:x:1002:
golf:x:1003:
user100
[root@localhost itbank]# id user100
uid=1001(user100) gid=1001(user100) groups=1001(user100),1003(golf)
[root@localhost itbank]#
[root@localhost itbank]# groupdel golf
[root@localhost itbank]#
[root@localhost itbank]# groupadd golf
[root@localhost itbank]#
[root@localhost itbank]#
[root@localhost itbank]# usermod -G golf -a user100
[root@localhost itbank]#
[root@localhost itbank]# tail -3 /etc/group
user100:x:1001:
soccer:x:1002:user100
golf:x:1003:user100
[root@localhost itbank]#
[root@localhost itbank]# id user100
uid=1001(user100) gid=1001(user100) groups=1001(user100),1002(soccer),1003(golf)
[root@localhost itbank]#

 

// vi 편집 관련

[root@localhost itbank]# vi /etc/group

golf:x:1003:user100 지움        // 해당 그룹 사용하지 않는 경우

:wq
[root@localhost itbank]#
[root@localhost itbank]# tail -3 /etc/group
user100:x:1001:
soccer:x:1002:user100
golf:x:1003                         //:user100 없어진거 확인
[root@localhost itbank]# id user100
uid=1001(user100) gid=1001(user100) groups=1001(user100),1002(soccer)    // golf그룹 없어진거 확인
[root@localhost itbank]#

// 원복

// 사용자 먼저 생성해 자동 그룹 생성된 경우, 사용자를 지운 후, 그룹을 지워야

[root@localhost itbank]# userdel -r user100
[root@localhost itbank]#
[root@localhost itbank]# groupdel soccer
[root@localhost itbank]#
[root@localhost itbank]# groupdel golf
[root@localhost itbank]#
[root@localhost itbank]# tail -1 /etc/passwd
itbank:x:1000:1000:dust:/home/itbank:/bin/bash
[root@localhost itbank]#
[root@localhost itbank]# tail -1 /etc/group
itbank:x:1000:
[root@localhost itbank]#
[root@localhost itbank]# rm -rf /bonwon
[root@localhost itbank]# rm -rf /centos
[root@localhost itbank]# rm -rf /jongno
[root@localhost itbank]# rm -rf /jongro/
[root@localhost itbank]# rm -rf /skel
[root@localhost itbank]# rm -rf /testskel
testskel/  testskel2/
[root@localhost itbank]# rm -rf /testskel
[root@localhost itbank]# rm -rf /testskel2
[root@localhost itbank]#
[root@localhost itbank]#
[root@localhost itbank]# tail /etc/passwd
pulse:x:171:171:PulseAudio System Daemon:/var/run/pulse:/sbin/nologin
gdm:x:42:42::/var/lib/gdm:/sbin/nologin
gnome-initial-setup:x:992:987::/run/gnome-initial-setup/:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
avahi:x:70:70:Avahi mDNS/DNS-SD Stack:/var/run/avahi-daemon:/sbin/nologin
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
ntp:x:38:38::/etc/ntp:/sbin/nologin
tcpdump:x:72:72::/:/sbin/nologin
apache:x:48:48:Apache:/usr/share/httpd:/sbin/nologin
itbank:x:1000:1000:dust:/home/itbank:/bin/bash
[root@localhost itbank]# tail /etc/group
gnome-initial-setup:x:987:
sshd:x:74:
avahi:x:70:
slocate:x:21:
postdrop:x:90:
postfix:x:89:
ntp:x:38:
tcpdump:x:72:
apache:x:48:
itbank:x:1000:

 

<실습>


사용자 계정과 그룹 실습
- 작업 환경

          User : battlegrounds
          UID : 2017
          GID : lol                    // 롤
          SHELL : /bin/csh        
          HOME : /overwatch    // 생성 경로
          SKEL : /fifaonline3
   COMMENT : maplestory
          Auto Creating Directory : dungeon_fighter
          Auto Creating File : .suddenattack

- 작업
(단, 모든 작업은 기본 정보(/etc/default/useradd, useradd -D)를 사용하지 말고
사용자를 생성할 때 옵션만을 이용해서 명령어 한 줄로만 작업할 것)

cf.

useradd -d /overwatch/battlegrounds  // 계정명 바꿔서 지정도 가능

useradd -b /overwatch                    // base, 기본 생성 경로

 

// 쌤

// lol group 생성

[root@localhost ~]# tail -1 /etc/group
itbank:x:1000:
[root@localhost ~]#
[root@localhost ~]# groupadd lol
[root@localhost ~]#
[root@localhost ~]# tail -2 /etc/group
itbank:x:1000:
lol:x:1001:
[root@localhost ~]#

// /overwatch home dir. 및 /fifaonline3 skel dir. 생성

[root@localhost ~]# ls -ld /overwatch
ls: cannot access /overwatch: 그런 파일이나 디렉터리가 없습니다
[root@localhost ~]#
[root@localhost ~]# mkdir /overwatch
[root@localhost ~]#
[root@localhost ~]# ls -ld /overwatch/
drwxr-xr-x. 2 root root 6 12월 29 12:57 /overwatch/
[root@localhost ~]#
[root@localhost ~]# ls -ld /fifaonline3
ls: cannot access /fifaonline3: 그런 파일이나 디렉터리가 없습니다
[root@localhost ~]#


// /fifaonline3 skel dir. 생성

[root@localhost ~]# cp -r /etc/skel /fifaonline3
[root@localhost ~]#
[root@localhost ~]# ls -la /fifaonline3/
합계 12
drwxr-xr-x.  4 root root  92 12월 29 12:58 .
dr-xr-xr-x. 21 root root 284 12월 29 12:58 ..
-rw-r--r--.  1 root root  18 12월 29 12:58 .bash_logout
-rw-r--r--.  1 root root 193 12월 29 12:58 .bash_profile
-rw-r--r--.  1 root root 231 12월 29 12:58 .bashrc
drwxr-xr-x.  4 root root  39 12월 29 12:58 .mozilla
drwxr-xr-x.  2 root root   6 12월 29 12:58 public
[root@localhost ~]#
[root@localhost ~]# mkdir /fifaonline3/dungeon_fighter
[root@localhost ~]#
[root@localhost ~]# touch /fifaonline3/.suddenattack
[root@localhost ~]#
[root@localhost ~]# ls -la /fifaonline3/
합계 12
drwxr-xr-x.  4 root root 122 12월 29 13:00 .
dr-xr-xr-x. 21 root root 284 12월 29 12:58 ..
-rw-r--r--.  1 root root  18 12월 29 12:58 .bash_logout
-rw-r--r--.  1 root root 193 12월 29 12:58 .bash_profile
-rw-r--r--.  1 root root 231 12월 29 12:58 .bashrc
drwxr-xr-x.  4 root root  39 12월 29 12:58 .mozilla
-rw-r--r--.  1 root root   0 12월 29 12:59 .suddenattack
drwxr-xr-x.  2 root root   6 12월 29 12:59 dungeon_fighter
[root@localhost ~]#
[root@localhost ~]# ls -la /etc/skel/
합계 24
drwxr-xr-x.   3 root root   78 12월 29 13:00 .
drwxr-xr-x. 135 root root 8192 12월 29 12:56 ..
-rw-r--r--.   1 root root   18  9월  7 01:25 .bash_logout
-rw-r--r--.   1 root root  193  9월  7 01:25 .bash_profile
-rw-r--r--.   1 root root  231  9월  7 01:25 .bashrc
drwxr-xr-x.   4 root root   39  9월 25 14:49 .mozilla

// useradd

[root@localhost ~]# useradd -c maplestory -mk /fifaonline3 -d /overwatch/battlegrounds -s /bin/csh -u 2017 -g 1001 battlegrounds
[root@localhost ~]#
[root@localhost ~]# tail -1 /etc/passwd
battlegrounds:x:2017:1001:maplestory:/overwatch/battlegrounds:/bin/csh
[root@localhost ~]#
[root@localhost ~]# tail -1 /etc/group
lol:x:1001:
[root@localhost ~]# id battlegrounds
uid=2017(battlegrounds) gid=1001(lol) groups=1001(lol)
[root@localhost ~]#
[root@localhost ~]# ls -la /overwatch/battlegrounds
합계 12
drwx------. 4 battlegrounds lol  122 12월 29 13:10 .
drwxr-xr-x. 3 root          root  27 12월 29 13:10 ..
-rw-r--r--. 1 battlegrounds lol   18 12월 29 12:58 .bash_logout
-rw-r--r--. 1 battlegrounds lol  193 12월 29 12:58 .bash_profile
-rw-r--r--. 1 battlegrounds lol  231 12월 29 12:58 .bashrc
drwxr-xr-x. 4 battlegrounds lol   39 12월 29 12:58 .mozilla
-rw-r--r--. 1 battlegrounds lol    0 12월 29 12:59 .suddenattack
drwxr-xr-x. 2 battlegrounds lol    6 12월 29 12:59 dungeon_fighter

// 내가 한거

// 디렉터리 확인 (home, skel)

[root@localhost ~]# ls /
bin     boot  etc   lib    media  opt   root  sbin  sys  usr
bonwon  dev   home  lib64  mnt    proc  run   srv   tmp  var

// 디렉터리 생성

[root@localhost itbank]# mkdir /overwatch
[root@localhost itbank]#
[root@localhost itbank]# mkdir /fifaonline3
[root@localhost itbank]#
[root@localhost ~]# ls /
bin     boot  etc          home  lib64  mnt  overwatch  root  sbin  sys  usr
bonwon  dev   fifaonline3  lib   media  opt  proc       run   srv   tmp  var

// shell 확인

[root@localhost itbank]# cat /etc/shells
/bin/sh
/bin/bash
/sbin/nologin
/usr/bin/sh
/usr/bin/bash
/usr/sbin/nologin
/bin/tcsh
/bin/csh
[root@localhost itbank]#

 

// /etc/skel 복사

[root@localhost ~]# ls -la /etc/skel
합계 24
drwxr-xr-x.   3 root root   78 12월 28 20:40 .
drwxr-xr-x. 133 root root 8192 12월 28 20:36 ..
-rw-r--r--.   1 root root   18  8월  3 06:11 .bash_logout
-rw-r--r--.   1 root root  193  8월  3 06:11 .bash_profile
-rw-r--r--.   1 root root  231  8월  3 06:11 .bashrc
drwxr-xr-x.   4 root root   39 12월 19 23:49 .mozilla
[root@localhost itbank]#
[root@localhost itbank]# cp -r /etc/skel/. /fifaonline3/
[root@localhost itbank]#
[root@localhost ~]# ls -la /fifaonline3/
합계 12
drwxr-xr-x.  3 root root  78 12월 28 20:41 .
dr-xr-xr-x. 20 root root 274 12월 28 20:39 ..
-rw-r--r--.  1 root root  18 12월 28 20:41 .bash_logout
-rw-r--r--.  1 root root 193 12월 28 20:41 .bash_profile
-rw-r--r--.  1 root root 231 12월 28 20:41 .bashrc
drwxr-xr-x.  4 root root  39 12월 28 20:41 .mozilla

[root@localhost ~]# mkdir /fifaonline3/dungeon_fighter
[root@localhost ~]# touch /fifaonline3/.suddenattack
[root@localhost ~]#
[root@localhost ~]# ls -la /fifaonline3/
합계 12
drwxr-xr-x.  4 root root 122 12월 28 20:41 .
dr-xr-xr-x. 20 root root 274 12월 28 20:39 ..
-rw-r--r--.  1 root root  18 12월 28 20:41 .bash_logout
-rw-r--r--.  1 root root 193 12월 28 20:41 .bash_profile
-rw-r--r--.  1 root root 231 12월 28 20:41 .bashrc
drwxr-xr-x.  4 root root  39 12월 28 20:41 .mozilla
-rw-r--r--.  1 root root   0 12월 28 20:41 .suddenattack
drwxr-xr-x.  2 root root   6 12월 28 20:41 dungeon_fighter
[root@localhost ~]#

// lol group 생성 및 battlegrounds user 생성

[root@localhost ~]# tail -1 /etc/passwd
user77:x:1010:1010::/home/user77:/bin/bash
[root@localhost ~]#
[root@localhost ~]# tail -1 /etc/group
user77:x:1010:
[root@localhost ~]#
[root@localhost ~]# groupadd lol
[root@localhost ~]#
[root@localhost ~]# tail -1 /etc/group
lol:x:1011:
[root@localhost ~]# tail -1 /etc/passwd
user7:x:1009:1009::/home/user7:/bin/bash

[root@localhost ~]# useradd -u 2017 -g lol -s /bin/csh -d /overwatch/battlegrounds -m -k     /fifaonline3/battlegrounds -c maplestory battlegrounds
[root@localhost ~]#
[root@localhost ~]# tail -1 /etc/passwd
battlegrounds:x:2017:1011:maplestory:/overwatch/battlegrounds:/bin/csh
[root@localhost ~]#
[root@localhost ~]# tail -1 /etc/group
lol:x:1011:

 

 

 

[root@localhost itbank]# ls -la /fifaonline3/
합계 12
drwxr-xr-x.  5 root root 135 12월 28 15:04 .
dr-xr-xr-x. 21 root root 284 12월 28 15:02 ..
-rw-r--r--.  1 root root  18 12월 28 15:03 .bash_logout
-rw-r--r--.  1 root root 193 12월 28 15:03 .bash_profile
-rw-r--r--.  1 root root 231 12월 28 15:03 .bashrc
drwxr-xr-x.  4 root root  39 12월 28 15:03 .mozilla
-rw-r--r--.  1 root root   0 12월 28 15:04 .suddeattack
drwxr-xr-x.  2 root root   6 12월 28 15:04 dungeon_fighter
drwxr-xr-x.  2 root root   6 12월 28 15:03 public
[root@localhost itbank]#
[root@localhost ~]# ls -la /overwatch/battlegrounds/
합계 12
drwx------. 4 battlegrounds lol  122 12월 28 20:51 .
drwxr-xr-x. 3 root          root  27 12월 28 20:51 ..
-rw-r--r--. 1 battlegrounds lol   18 12월 28 20:41 .bash_logout
-rw-r--r--. 1 battlegrounds lol  193 12월 28 20:41 .bash_profile
-rw-r--r--. 1 battlegrounds lol  231 12월 28 20:41 .bashrc
drwxr-xr-x. 4 battlegrounds lol   39 12월 28 20:41 .mozilla
-rw-r--r--. 1 battlegrounds lol    0 12월 28 20:41 .suddenattack
drwxr-xr-x. 2 battlegrounds lol    6 12월 28 20:41 dungeon_fighter
[root@localhost ~]#
[root@localhost ~]# id battlegrounds
uid=2017(battlegrounds) gid=1011(lol) groups=1011(lol)

 

cf. skel 만드는 법

/skel

cp -r /etc/skel /skel/test

 

/skel/test

cp -r /etc/skel/. /skel/test                // . : 현재 위치;  .* 을 쓰면 etc까지 들어가버려서 안됨!!!

반응형
LIST
Posted by 오정oI
, |
반응형
SMALL

* Review

1> 사용자 게정 생성

[사용형식]

# useradd 계정명

→ 계정을 생성하는데 기본설정을 토대로 생성이 됨

# useradd [option] [argument] 계정명

→ 계정을 생성시 옵션 사용하여 해당 값을 주어서 생성함

[option]

-u : uid를 지정

-g : gid를 지정(그룹 배운 후)

-c : comment 를 지정

-s : shell을 지정

-d : 사용자 계정의 홈 디렉터리 생성할 경로를 지정

-p:  사용자 계정을 생성할 때 비밀번호와 같이 부여하여 생성

 ex) useradd -p `openssl passwd 1` user6            // ` : 쿼터 (1앞에 키)

-m -k 또는 -mk : 사용자 지정 skel

 

 

* /etc/skel 디렉터리 하위에 파일들

 

 

 

(다시 말해 각 사용자 계정의 홈 디렉터리 하위)

 

.bash_logout

- 각각 사용자 계정이 로그아웃시 기록이 저장되는 파일

 

. bash_profile

- 각각 사용자 계정의 환경 변수 파일(PATH(경로) 설정)

cf) [root@localhost itbank]# ls -l /etc/profile        // 리눅스 전체
-rw-r--r--. 1 root root 1807  9월 25 15:27 /etc/profile

.bashrc

- 각각 사용자 계정의 alias 설정

 

[root@localhost itbank]# tail -8 /etc/passwd
linux1:x:1001:1001::/AS/Linux/linux1:/bin/bash
user1:x:1002:1002::/home/user1:/bin/bash
user2:x:1004:1004::/home/user2:/bin/bash
user3:x:1005:1005:testuser:/home/user3:/bin/bash
user4:x:1006:1006::/home/user4:/bin/sh
user5:x:1007:1007::/bonwon/userfive:/bin/csh
user6:x:1008:1008::/home/user6:/bin/bash
user7:x:1009:1009::/home/user7:/bin/bash
[root@localhost itbank]#
[root@localhost itbank]# ls -la /home/user7
합계 12
drwx------.  3 user7 user7  91 12월 26 15:05 .
drwxr-xr-x. 10 root  root  165 12월 26 15:20 ..
-rw-r--r--.  1 user7 user7  18  9월  7 01:25 .bash_logout
-rw-r--r--.  1 user7 user7 193  9월  7 01:25 .bash_profile
-rw-r--r--.  1 user7 user7 231  9월  7 01:25 .bashrc
drwxr-xr-x.  4 user7 user7  39  9월 25 14:49 .mozilla

-rw-r--r--.  1 user7 user7   0 12월 26 15:01 junga
[root@localhost itbank]#
[root@localhost itbank]# ls /home
itbank  itbank2  user1  user2  user3  user4  user6  user7
[root@localhost itbank]#
[root@localhost itbank]# /usr/bin/ls /home            // 원래 이런방식으로 써야 함
itbank  itbank2  user1  user2  user3  user4  user6  user7
[root@localhost itbank]#
[root@localhost itbank]# ls -l /etc/pro
profile    profile.d/ protocols
[root@localhost itbank]# ls -l /etc/profile
-rw-r--r--. 1 root root 1807  9월 25 15:27 /etc/profile

// user6 에만 적용(alias)

[root@localhost itbank]# vi /home/user6/.bashrc
alias fresh='clear'                    // line1에 추가
echo "hello~ I_m user6!"

// 전체 적용 가능한 파일

[root@localhost itbank]# ls -l /etc/bashrc
-rw-r--r--. 1 root root 2853 11월  6  2016 /etc/bashrc
[root@localhost itbank]#
[root@localhost itbank]# ls -l /etc/profile
-rw-r--r--. 1 root root 1807  9월 25 15:27 /etc/profile


 

* /etc/default/useradd(파일) 와

  useradd -D (명령어)

useradd -D

- 사용자 계정 생성시 관련된 기본 설정값을 출력

 

[사용형식]

useradd -D [option] [argument] 계정명

 

[root@localhost itbank]# useradd -D
GROUP=100                        ①
HOME=/home                     ②
INACTIVE=-1                       ③
EXPIRE=                             ④   
SHELL=/bin/bash                  ⑤   
SKEL=/etc/skel                     ⑥   
CREATE_MAIL_SPOOL=yes      ⑦

 

① GROUP=100

사용자 계정 생성시 기본 그룹을 지정-ㅠ

[option]

-g

 

② HOME=/home

- 사용자 계정 생성시 기본 생성 경로를 지정 

[option]

-b

 

③ INACTIVE=-1              

- 사용자 계정 생성시 만료 후 사용 불가능

값이 -1은 비활성화

값이 0은 사용 안 함

[option]

-f

 

④ EXPIRE=
- 만료일

값이 없으므로 무제한

[option]

-e

 

⑤ SHELL=/bin/bash

- 사용자 계정 생성시 기본 셸을 지정

[option]

-s

 

⑥ SKEL=/etc/skel
- 사용자 계정 생성시 기본 스켈을 지정

[option]

없음

옵션이 없으므로, # vi /etc/default/useradd 해서 수정!

 

⑦ CREATE_MAIL_SPOOL=yes

- 사용자 계정 생성시 사용자 관련 메일 파일 생성 허용 여부

(참고로 /var/spool/mail 디렉터리 하위에 사용자 계정 메일 파일이 존재함)

[option]

없음

 

// 작업 효율성 ↑

# vi /etc/default/useradd

다음 사항 수정

HOME=/bonwon

SHELL=/bin/tcsh

SKEL=/testskel

 

useradd -d /bonwon /test1 -s /bin/tcsh -m -k /testskel test2

대신

useradd test2

가능!

 

 

[root@localhost itbank]# tail /etc/passwd
user2:x:1004:1004::/home/user2:/bin/bash
user3:x:1005:1005:testuser:/home/user3:/bin/bash
user4:x:1006:1006::/home/user4:/bin/sh
user5:x:1007:1007::/bonwon/userfive:/bin/csh
user6:x:1008:1008::/home/user6:/bin/bash
user7:x:1009:1009::/home/user7:/bin/bash
user8:x:1010:1010::/home/user8:/bin/bash
user88:x:1011:1011::/home/user88:/bin/bash
test:x:1012:1012::/jongro/test:/bin/bash
test2:x:1013:1013::/jongno/test2:/bin/bash

[root@localhost itbank]# ls -l /etc/default/useradd
-rw-r--r--. 1 root root 119 11월  5  2016 /etc/default/useradd
[root@localhost itbank]#
[root@localhost itbank]# cat /etc/default/useradd
# useradd defaults file
GROUP=100
HOME=/home
INACTIVE=-1
EXPIRE=
SHELL=/bin/bash
SKEL=/etc/skel
CREATE_MAIL_SPOOL=yes

[root@localhost itbank]#
[root@localhost itbank]# useradd -D
GROUP=100
HOME=/home
INACTIVE=-1
EXPIRE=
SHELL=/bin/bash
SKEL=/etc/skel
CREATE_MAIL_SPOOL=yes

 

 

* 사용자 계정 수정

[사용형식]

usermod [option] [argument] 계정명

 

사용자 계정 수정은 사용형식

이 사용자 계정 생성과 동일함

 

[ption]

-u : uid를 수정할 때

-g : 그룹을 배운 후에

-G : 그룹을 배운 후에

-c : comment 를 수정할 때

-s : shell을 수정할 때

-l :  사용자 계정명을 수정할 때

-d :  사용자 계정의 홈 디렉터리 경로 또는 사용자 계정의 홈 디렉터리명을 수정할 때

(참고로 -d 옵션을 사용할 때 -m 옵션과 같이 사용할 수 있음)

 

 

 

[root@localhost ~]# tail /etc/passwd
user3:x:1005:1005:testuser:/home/user3:/bin/bash
user4:x:1006:1006::/home/user4:/bin/sh
user5:x:1007:1007::/bonwon/userfive:/bin/csh
user6:x:1008:1008::/home/user6:/bin/bash
user7:x:1009:1009::/home/user7:/bin/bash
user8:x:1010:1010::/home/user8:/bin/bash
user88:x:1011:1011::/home/user88:/bin/bash
test:x:1012:1012::/jongro/test:/bin/bash
test2:x:1013:1013::/jongno/test2:/bi
user9:x:1014:1014::/centos/user9:/bin/tcsh
[root@localhost ~]#

// uid 수정

[root@localhost ~]# usermod -u 2011 test2
[root@localhost ~]#
[root@localhost ~]# tail /etc/passwd
user3:x:1005:1005:testuser:/home/user3:/bin/bash
user4:x:1006:1006::/home/user4:/bin/sh
user5:x:1007:1007::/bonwon/userfive:/bin/csh
user6:x:1008:1008::/home/user6:/bin/bash
user7:x:1009:1009::/home/user7:/bin/bash
user8:x:1010:1010::/home/user8:/bin/bash
user88:x:1011:1011::/home/user88:/bin/bash
test:x:1012:1012::/jongro/test:/bin/bash
test2:x:2011:1013::/jongno/test2:/bin/bash
user9:x:1014:1014::/centos/user9:/bin/tcsh
[root@localhost ~]#

// comment 수정

[root@localhost ~]# usermod -c seoul test2
[root@localhost ~]#
[root@localhost ~]# tail /etc/passwd
user3:x:1005:1005:testuser:/home/user3:/bin/bash
user4:x:1006:1006::/home/user4:/bin/sh
user5:x:1007:1007::/bonwon/userfive:/bin/csh
user6:x:1008:1008::/home/user6:/bin/bash
user7:x:1009:1009::/home/user7:/bin/bash
user8:x:1010:1010::/home/user8:/bin/bash
user88:x:1011:1011::/home/user88:/bin/bash
test:x:1012:1012::/jongro/test:/bin/bash
test2:x:2011:1013:seoul:/jongno/test2:/bin/bash
user9:x:1014:1014::/centos/user9:/bin/tcsh

// 사용자 계정명 수정

[root@localhost ~]# usermod -l userfive user5
[root@localhost ~]#
[root@localhost ~]# tail /etc/passwd
user3:x:1005:1005:testuser:/home/user3:/bin/bash
user4:x:1006:1006::/home/user4:/bin/sh
user6:x:1008:1008::/home/user6:/bin/bash
user7:x:1009:1009::/home/user7:/bin/bash
user8:x:1010:1010::/home/user8:/bin/bash
user88:x:1011:1011::/home/user88:/bin/bash
test:x:1012:1012::/jongro/test:/bin/bash
test2:x:2011:1013:seoul:/jongno/test2:/bin/sh
user9:x:1014:1014::/centos/user9:/bin/tcsh
userfive:x:1007:1007::/bonwon/userfive:/bin/csh
[root@localhost ~]#

// 사용자 계정 홈 디렉터리 수정

[root@localhost itbank]# usermod -d /jongno/user8 user8
[root@localhost itbank]#
[root@localhost itbank]# tail -12 /etc/passwd
user1:x:1002:1002::/home/user1:/bin/bash
user2:x:1004:1004::/home/user2:/bin/bash
user3:x:1005:1005:testuser:/home/user3:/bin/bash
user4:x:1006:1006::/home/user4:/bin/sh
user6:x:1008:1008::/home/user6:/bin/bash
user7:x:1009:1009::/home/user7:/bin/bash
user8:x:1010:1010::/jongno/user8:/bin/bash
user88:x:1011:1011::/home/user88:/bin/bash
test:x:1012:1012::/jongro/test:/bin/bash
test2:x:2011:1013:seoul:/jongno/test2:/bin/sh
user9:x:1014:1014::/centos/user9:/bin/tcsh
userfive:x:1007:1007::/bonwon/userfive:/bin/csh
[root@localhost itbank]#
[root@localhost itbank]# ls -l /jongno/   //재 위치에 없으면 로긴시 bash셸이 borne 셸 처럼 깨짐
합계 0
drwx------. 4 test2 test2 92 12월 27 13:54 test2

[root@localhost itbank]# mv /home/user8 /jongno
[root@localhost itbank]#
[root@localhost itbank]# ls -l /jongno/
합계 0
drwx------. 4 test2 test2 92 12월 27 13:54 test2
drwx------. 3 user8 user8 78 12월 27 13:06 user8

 

// useradd -D 기본값 복원

[root@localhost itbank]# vi /etc/default/useradd

SKEL=/etc/skel

:wq
[root@localhost itbank]#
[root@localhost itbank]# useradd -D -b /home -s /bin/bash
[root@localhost itbank]#
[root@localhost itbank]# useradd -D
GROUP=100
HOME=/home
INACTIVE=-1
EXPIRE=
SHELL=/bin/bash
SKEL=/etc/skel
CREATE_MAIL_SPOOL=yes

[root@localhost itbank]# useradd user11
[root@localhost itbank]#
[root@localhost itbank]# tail -1 /etc/passwd
user11:x:2013:2013::/home/user11:/bin/bash
[root@localhost itbank]#
[root@localhost itbank]# ls /home
itbank  itbank2  user1  user11  user2  user3  user4  user6  user7  user88

// /home/user11 → /bonwon/user11

[root@localhost itbank]# usermod -d /bonwon/user11 user11
[root@localhost itbank]#
[root@localhost itbank]# tail -1 /etc/passwd
user11:x:2013:2013::/bonwon/user11:/bin/bash
[root@localhost itbank]# ls -l /bonwon/
합계 0
drwx------. 3 userfive user5 94 12월 26 15:00 userfive
[root@localhost itbank]#
[root@localhost itbank]# mv /home/user11 /bonwon
[root@localhost itbank]#
[root@localhost itbank]# ls /home /bonwon/
/bonwon/:
user11  userfive

/home:
itbank  itbank2  user1  user2  user3  user4  user6  user7  user88

// 한번에 home dir. 변경하는 방법

[root@localhost itbank]# tail -1 /etc/passwd
user11:x:2013:2013::/bonwon/user11:/bin/bash
[root@localhost itbank]#
[root@localhost itbank]# usermod -m -d /home/user11 user11
[root@localhost itbank]#
[root@localhost itbank]# tail -1 /etc/passwd
user11:x:2013:2013::/home/user11:/bin/bash
[root@localhost itbank]#
[root@localhost itbank]# ls /bonwon
userfive
[root@localhost itbank]# ls /home
itbank  itbank2  user1  user11  user2  user3  user4  user6  user7  user88
[root@localhost itbank]#
[root@localhost itbank]#


 

* 사용자 삭제

[사용형식]

# userdel 계정명

/etc/passwd, /etc/shadow, /etc/group 파일에 삭제한 계정의 정보가 없어짐  // 공통점

삭제한 사용자 계정의 홈 디렉터리는 남아있음

삭제한 사용자 계정의 메일파일이 남아있음

=> 나중에 복구할 수 있음

 

# userdel [option] 계정명

-r : 사용자 계정의 모든 것들

/etc/passwd, /etc/shadow, /etc/group 파일에 삭제한 계정의 정보가 없어짐  // 공통점

삭제한 사용자 계정의 홈 디렉터리는 남아있지 않음

삭제한 사용자 계정의 메일파일이 남아있지 않음

=> 나중에 복구할 수 없음

 

 

// 준비물

[root@localhost itbank]# useradd -d /bonwon/user12 user12
[root@localhost itbank]#
[root@localhost itbank]# tail -1 /etc/passwd
user12:x:2014:2014::/bonwon/user12:/bin/bash
[root@localhost itbank]#
[root@localhost itbank]# useradd -d /bonwon/user13 user13
[root@localhost itbank]#
[root@localhost itbank]# tail -2 /etc/passwd
user12:x:2014:2014::/bonwon/user12:/bin/bash
user13:x:2015:2015::/bonwon/user13:/bin/bash

// userdel user12        => 해당 사용자 관련 복구 정보는 남아 있음(home dir. mail)

[root@localhost itbank]# userdel user12
[root@localhost itbank]#
[root@localhost itbank]# tail -2 /etc/passwd
user11:x:2013:2013::/home/user11:/bin/bash
user13:x:2015:2015::/bonwon/user13:/bin/bash
[root@localhost itbank]#
[root@localhost itbank]# tail -2 /etc/shadow
user11:!!:17528:0:99999:7:::
user13:!!:17528:0:99999:7:::
[root@localhost itbank]#
[root@localhost itbank]# tail -2 /etc/group
user11:x:2013:
user13:x:2015:
[root@localhost itbank]#
[root@localhost itbank]# ls -l /bonwon/
합계 0
drwx------. 4     2014   2014 92 12월 28 13:15 user12    // 2014 : user12가 사용했던 uid. 헬스장 키 번호
drwx------. 4 user13   user13 92 12월 28 13:16 user13
drwx------. 3 userfive user5  94 12월 26 15:00 userfive
[root@localhost itbank]#
[root@localhost itbank]# ls -l /var/spool/mail/
합계 0
-rw-rw----. 1 itbank   mail 0  9월 25 15:30 itbank
-rw-rw----. 1 linux1   mail 0 12월 22 14:01 linux1
-rw-rw----. 1 rpc      mail 0  9월 25 14:53 rpc
-rw-rw----. 1 test     mail 0 12월 27 13:39 test
-rw-rw----. 1 test2    mail 0 12월 27 13:54 test2
-rw-rw----. 1 user1    mail 0 12월 26 14:17 user1
-rw-rw----. 1 user10   mail 0 12월 28 12:51 user10
-rw-rw----. 1 user11   mail 0 12월 28 12:58 user11
-rw-rw----. 1     2014 mail 0 12월 28 13:15 user12        // 2014 : user12가 사용했던 uid
-rw-rw----. 1 user13   mail 0 12월 28 13:16 user13
-rw-rw----. 1 user2    mail 0 12월 26 14:24 user2
-rw-rw----. 1 user3    mail 0 12월 26 14:26 user3
-rw-rw----. 1 user4    mail 0 12월 26 14:29 user4
-rw-rw----. 1 user6    mail 0 12월 26 14:42 user6
-rw-rw----. 1 user7    mail 0 12월 26 15:05 user7
-rw-rw----. 1 user8    mail 0 12월 27 13:06 user8
-rw-rw----. 1 user88   mail 0 12월 27 13:25 user88
-rw-rw----. 1 user9    mail 0 12월 27 14:31 user9
-rw-rw----. 1 userfive mail 0 12월 26 14:33 userfive
[root@localhost itbank]#

// userdel -r user13

[root@localhost itbank]# tail -1 /etc/passwd
user13:x:2015:2015::/bonwon/user13:/bin/bash
[root@localhost itbank]#
[root@localhost itbank]# userdel -r user13
[root@localhost itbank]#
[root@localhost itbank]# tail -1 /etc/passwd
user11:x:2013:2013::/home/user11:/bin/bash
[root@localhost itbank]#
[root@localhost itbank]# tail -1 /etc/shadow
user11:!!:17528:0:99999:7:::
[root@localhost itbank]#
[root@localhost itbank]# tail -1 /etc/group
user11:x:2013:
[root@localhost itbank]#
[root@localhost itbank]# ls -l /bonwon
합계 0
drwx------. 4     2014  2014 92 12월 28 13:15 user12
drwx------. 3 userfive user5 94 12월 26 15:00 userfive
[root@localhost itbank]#
[root@localhost itbank]# ls -l /var/spool/mail/user13
ls: cannot access /var/spool/mail/user13: 그런 파일이나 디렉터리가 없습니다
[root@localhost itbank]#
[root@localhost itbank]#

// 작업했던 user들 모두 삭제

 

[root@localhost itbank]# tail -19 /etc/passwd
ntp:x:38:38::/etc/ntp:/sbin/nologin
tcpdump:x:72:72::/:/sbin/nologin
apache:x:48:48:Apache:/usr/share/httpd:/sbin/nologin
itbank:x:1000:1000:dust:/home/itbank:/bin/bash
linux1:x:1001:1001::/AS/Linux/linux1:/bin/bash
user1:x:1002:1002::/home/user1:/bin/bash
user2:x:1004:1004::/home/user2:/bin/bash
user3:x:1005:1005:testuser:/home/user3:/bin/bash
user4:x:1006:1006::/home/user4:/bin/sh
user6:x:1008:1008::/home/user6:/bin/bash
user7:x:1009:1009::/home/user7:/bin/bash
user8:x:1010:1010::/jongno/user8:/bin/bash
user88:x:1011:1011::/home/user88:/bin/bash
test:x:1012:1012::/jongro/test:/bin/bash
test2:x:2011:1013:seoul:/jongno/test2:/bin/sh
user9:x:1014:1014::/centos/user9:/bin/tcsh
userfive:x:1007:1007::/bonwon/userfive:/bin/csh
user10:x:2012:2012::/centos/user10:/bin/tcsh
user11:x:2013:2013::/home/user11:/bin/bash
[root@localhost itbank]#
[root@localhost itbank]# userdel -r user1
[root@localhost itbank]# userdel -r user2
[root@localhost itbank]# userdel -r user3
[root@localhost itbank]# userdel -r user4
[root@localhost itbank]# userdel -r userfive
[root@localhost itbank]# userdel -r user6
[root@localhost itbank]# userdel -r user7
[root@localhost itbank]# userdel -r user8
[root@localhost itbank]# userdel -r user88
[root@localhost itbank]# userdel -r test
[root@localhost itbank]# userdel -r test2
[root@localhost itbank]# userdel -r user9
[root@localhost itbank]# userdel -r user10
[root@localhost itbank]# userdel -r user11
[root@localhost itbank]#

// passwd에 관한 정보는 지워지는데

// 에러 뜨는 경우는 (userdel -r 계정명 (home dir, mail까지 다 날림))

=> E1. user100 의 소유가 아닙니다.(root꺼 useradd시 home dir. 설정 안 해줌)

 

=> E2. not found(useradd 잘 해줬는데, 이미 home dir.을 rm -rf 로 날려버림)

// home dir.에 관한 거임

 

 

<실습 1>

/etc/skel 디렉터리 하위에 존재하는 모든 것들을 /testskel 디렉터리에 복사를 한 후 사용자를 생성하시오

(조건1. /etc/skel 디렉터리 자체를 복사하지 마시오

조건2. /etc/skel 디렉터리를 이름 바꾸어서 복사하지 마시오

조건3. /testskel 디렉터리 하위에 another 디렉터리를 생성하시오)

 

사용자 계정명은 user8

 

[준비물]

[root@localhost itbank]# rm -rf /etc/skel/junga
[root@localhost itbank]#
[root@localhost itbank]# ls -la /etc/skel/
합계 24
drwxr-xr-x.   3 root root   78 12월 27 12:53 .
drwxr-xr-x. 135 root root 8192 12월 27 12:36 ..
-rw-r--r--.   1 root root   18  9월  7 01:25 .bash_logout
-rw-r--r--.   1 root root  193  9월  7 01:25 .bash_profile
-rw-r--r--.   1 root root  231  9월  7 01:25 .bashrc
drwxr-xr-x.   4 root root   39  9월 25 14:49 .mozilla

// sol>

# mkdir /testskel

[root@localhost itbank]# ls -la /testskel/
합계 12
drwxr-xr-x.  4 root root  93 12월 27 13:05 .            // 현재 위치   /testskel
dr-xr-xr-x. 21 root root 278 12월 27 12:55 ..           // 최상위       /    (root)  

# cp -r /etc/skel/.bash_logout /etc/skel/.bash_profile /etc/skel/.bashrc /etc/skel/.mozilla /testskel

# cp /etc/skel/.* /testskel        // 안보이는 모든 것 copy /etc/skel의

                       // -r 옵션을 쓰면.  .. 까지 복사되므로 여기까지..,

# ls -la /testskel                    

파일까지만 됨

# cp -r /etc/skel/.mozila /testskel            // testskel skel dir.

[root@localhost itbank]# ls -la /testskel/
합계 12
drwxr-xr-x.  4 root root  93 12월 27 13:05 .
dr-xr-xr-x. 21 root root 278 12월 27 12:55 ..
-rw-r--r--.  1 root root  18 12월 27 13:02 .bash_logout
-rw-r--r--.  1 root root 193 12월 27 13:04 .bash_profile
-rw-r--r--.  1 root root 231 12월 27 13:02 .bashrc
drwxr-xr-x.  4 root root  39 12월 27 13:05 .mozilla
drwxr-xr-x.  2 root root   6 12월 27 12:56 another

// skel 지정 등록 (/testskel을 skel dir로 지정하겠다)
[root@localhost itbank]# useradd -mk /testskel user88            

[root@localhost itbank]# tail -10 /etc/passwd
linux1:x:1001:1001::/AS/Linux/linux1:/bin/bash
user1:x:1002:1002::/home/user1:/bin/bash
user2:x:1004:1004::/home/user2:/bin/bash
user3:x:1005:1005:testuser:/home/user3:/bin/bash
user4:x:1006:1006::/home/user4:/bin/sh
user5:x:1007:1007::/bonwon/userfive:/bin/csh
user6:x:1008:1008::/home/user6:/bin/bash
user7:x:1009:1009::/home/user7:/bin/bash
user8:x:1010:1010::/home/user8:/bin/bash
user88:x:1011:1011::/home/user88:/bin/bash
[root@localhost itbank]#
[root@localhost itbank]# ls -la /home/user88
합계 12
drwx------.  4 user88 user88  93 12월 27 13:25 .
drwxr-xr-x. 12 root   root   192 12월 27 13:25 ..
-rw-r--r--.  1 user88 user88  18 12월 27 13:02 .bash_logout
-rw-r--r--.  1 user88 user88 193 12월 27 13:04 .bash_profile
-rw-r--r--.  1 user88 user88 231 12월 27 13:02 .bashrc
drwxr-xr-x.  4 user88 user88  39 12월 27 13:05 .mozilla
drwxr-xr-x.  2 user88 user88   6 12월 27 12:56 another        // 자동생성 dir.

 

<실습 2>

/jongro/test(사용자)/public(자동 생성 디렉터리)

      ↑ home dir. 

0) /testskel2 생성

1) /testskel2에 /public dir 생성

2) test사용자 /jongro 홈 디렉터리로 지정하고. /testskel2 skel로 지정해서 useradd 'test'

 

// 쌤 풀이

[root@localhost itbank]# mkdir /etc/skel/public
[root@localhost itbank]#
[root@localhost itbank]# ls -la /etc/skel
합계 24
drwxr-xr-x.   4 root root   92 12월 27 13:52 .
drwxr-xr-x. 135 root root 8192 12월 27 13:39 ..
-rw-r--r--.   1 root root   18  9월  7 01:25 .bash_logout
-rw-r--r--.   1 root root  193  9월  7 01:25 .bash_profile
-rw-r--r--.   1 root root  231  9월  7 01:25 .bashrc
drwxr-xr-x.   4 root root   39  9월 25 14:49 .mozilla
drwxr-xr-x.   2 root root    6 12월 27 13:52 public
[root@localhost itbank]# mkdir /jongno
[root@localhost itbank]#
[root@localhost itbank]# ls -l /jongno
합계 0
[root@localhost itbank]#
[root@localhost itbank]# useradd -d /jongno/test2 test2
[root@localhost itbank]#
[root@localhost itbank]# tail /etc/passwd
user2:x:1004:1004::/home/user2:/bin/bash
user3:x:1005:1005:testuser:/home/user3:/bin/bash
user4:x:1006:1006::/home/user4:/bin/sh
user5:x:1007:1007::/bonwon/userfive:/bin/csh
user6:x:1008:1008::/home/user6:/bin/bash
user7:x:1009:1009::/home/user7:/bin/bash
user8:x:1010:1010::/home/user8:/bin/bash
user88:x:1011:1011::/home/user88:/bin/bash
test:x:1012:1012::/jongro/test:/bin/bash
test2:x:1013:1013::/jongno/test2:/bin/bash
[root@localhost itbank]#
[root@localhost itbank]# ls -la /jongno/test2
합계 12
drwx------. 4 test2 test2  92 12월 27 13:54 .
drwxr-xr-x. 3 root  root   19 12월 27 13:54 ..
-rw-r--r--. 1 test2 test2  18  9월  7 01:25 .bash_logout
-rw-r--r--. 1 test2 test2 193  9월  7 01:25 .bash_profile
-rw-r--r--. 1 test2 test2 231  9월  7 01:25 .bashrc
drwxr-xr-x. 4 test2 test2  39  9월 25 14:49 .mozilla
drwxr-xr-x. 2 test2 test2   6 12월 27 13:52 public
[root@localhost itbank]#

 

// 내가 한거

[root@localhost itbank]# mkdir /testskel2
[root@localhost itbank]#
[root@localhost itbank]# ls -la /etc/skel/
합계 24
drwxr-xr-x.   3 root root   78 12월 27 12:53 .            
drwxr-xr-x. 135 root root 8192 12월 27 13:25 ..
-rw-r--r--.   1 root root   18  9월  7 01:25 .bash_logout
-rw-r--r--.   1 root root  193  9월  7 01:25 .bash_profile
-rw-r--r--.   1 root root  231  9월  7 01:25 .bashrc
drwxr-xr-x.   4 root root   39  9월 25 14:49 .mozilla
[root@localhost itbank]#
[root@localhost itbank]# cp /etc/skel/.* /testskel2
cp: omitting directory `/etc/skel/.'
cp: omitting directory `/etc/skel/..'
cp: omitting directory `/etc/skel/.mozilla'
[root@localhost itbank]#
[root@localhost itbank]# ls -la /testskel2
합계 16
drwxr-xr-x.  2 root root   62 12월 27 13:37 .
dr-xr-xr-x. 22 root root 4096 12월 27 13:36 ..
-rw-r--r--.  1 root root   18 12월 27 13:37 .bash_logout
-rw-r--r--.  1 root root  193 12월 27 13:37 .bash_profile
-rw-r--r--.  1 root root  231 12월 27 13:37 .bashrc
[root@localhost itbank]#
[root@localhost itbank]# cp -r /etc/skel/.mozilla /testskel2
[root@localhost itbank]#
[root@localhost itbank]# ls -la /testskel2
합계 16
drwxr-xr-x.  3 root root   78 12월 27 13:37 .
dr-xr-xr-x. 22 root root 4096 12월 27 13:36 ..
-rw-r--r--.  1 root root   18 12월 27 13:37 .bash_logout
-rw-r--r--.  1 root root  193 12월 27 13:37 .bash_profile
-rw-r--r--.  1 root root  231 12월 27 13:37 .bashrc
drwxr-xr-x.  4 root root   39 12월 27 13:37 .mozilla
[root@localhost itbank]#
[root@localhost itbank]# mkdir /testskel2/public
[root@localhost itbank]#
[root@localhost itbank]# ls -la /testskel2
합계 16
drwxr-xr-x.  4 root root   92 12월 27 13:37 .
dr-xr-xr-x. 22 root root 4096 12월 27 13:36 ..
-rw-r--r--.  1 root root   18 12월 27 13:37 .bash_logout
-rw-r--r--.  1 root root  193 12월 27 13:37 .bash_profile
-rw-r--r--.  1 root root  231 12월 27 13:37 .bashrc
drwxr-xr-x.  4 root root   39 12월 27 13:37 .mozilla
drwxr-xr-x.  2 root root    6 12월 27 13:37 public

[root@localhost itbank]#
[root@localhost itbank]# mkdir /jongro
[root@localhost itbank]#
[root@localhost itbank]# ls /
AS      bonwon  etc     lib    mnt   root  srv       testskel2  var
backup  boot    home    lib64  opt   run   sys       tmp
bin     dev     jongro  media  proc  sbin  testskel  usr
[root@localhost itbank]#
[root@localhost itbank]# useradd -d /jongro/test -m -k /testskel2 test

또는

[root@localhost itbank]# useradd -m -k /testskel2 -d /jongro/test  test
[root@localhost itbank]#
[root@localhost itbank]# ls -la /jongro/test
합계 12
drwx------. 4 test test  92 12월 27 13:39 .
drwxr-xr-x. 3 root root  18 12월 27 13:39 ..
-rw-r--r--. 1 test test  18 12월 27 13:37 .bash_logout
-rw-r--r--. 1 test test 193 12월 27 13:37 .bash_profile
-rw-r--r--. 1 test test 231 12월 27 13:37 .bashrc
drwxr-xr-x. 4 test test  39 12월 27 13:37 .mozilla
drwxr-xr-x. 2 test test   6 12월 27 13:37 public
[root@localhost itbank]#
[root@localhost itbank]# tail -11 /etc/passwd
linux1:x:1001:1001::/AS/Linux/linux1:/bin/bash
user1:x:1002:1002::/home/user1:/bin/bash
user2:x:1004:1004::/home/user2:/bin/bash
user3:x:1005:1005:testuser:/home/user3:/bin/bash
user4:x:1006:1006::/home/user4:/bin/sh
user5:x:1007:1007::/bonwon/userfive:/bin/csh
user6:x:1008:1008::/home/user6:/bin/bash
user7:x:1009:1009::/home/user7:/bin/bash
user8:x:1010:1010::/home/user8:/bin/bash
user88:x:1011:1011::/home/user88:/bin/bash
test:x:1012:1012::/jongro/test:/bin/bash

 

<실습 3>

/etc/default/useradd

 

SHELL : /bin/tcsh : 문서를 이용한 변경

HOME : /centos : 명령어 이용한 변경

SKEL : /skel/test : 문서를 이용한 변경

User : user9

(조건! 사용자 계정을 생성할 대 옵션 쓰지 않고 생성하시오)

 // 백업

[root@localhost ~]# vi /etc/default/useradd

# useradd defaults file
GROUP=100
HOME=/home
INACTIVE=-1
EXPIRE=
SHELL=/bin/bash
SKEL=/etc/skel
CREATE_MAIL_SPOOL=yes

 

// 쌤

#  useradd -D -b /centos

# vi /etc/default/useradd

SHELL

SKELL

편집

[root@localhost ~]# cat /etc/default/useradd
# useradd defaults file
GROUP=100
HOME=/centos
INACTIVE=-1
EXPIRE=
SHELL=/bin/tcsh
SKEL=/skel/test
CREATE_MAIL_SPOOL=yes

[root@localhost ~]#
[root@localhost ~]# useradd -D
GROUP=100
HOME=/centos
INACTIVE=-1
EXPIRE=
SHELL=/bin/tcsh
SKEL=/skel/test
CREATE_MAIL_SPOOL=yes

 

# mkdir /centos

# ls -l /centos

#

// /skel/test 중    /skel

# mkdir /skel

# ls -l /skel

# cp -r /etc/skel /skel/test

# ls -la /skel/test

 

// /skel/test 중   

# cp -r /etc/skel /skel/test

# ls -la /skel/test

/test/ 안에 /skel 생성됨

# cp -r /etc/skel. /skel/test

# ls -la /skel/test

# rm -rf /etc/skel/public

#

# useradd user99

# tail -1 /etc/passwd

# ls -a /centos/user99

# ls -a /skel/test

 

cf. skel 만드는 법

/skel

cp -r /etc/skel /skel/test

 

/skel/test

cp -r /etc/skel/. /skel/test                // . : 현재 위치;  .* 을 쓰면 etc까지 들어가버려서 안됨!!!

 

 

// 내가 한거

[root@localhost ~]# cat /etc/shells  // shell 검색
/bin/sh
/bin/bash
/sbin/nologin
/usr/bin/sh
/usr/bin/bash
/usr/sbin/nologin
/bin/tcsh
/bin/csh
[root@localhost ~]# mkdir /centos
[root@localhost ~]#
[root@localhost ~]# mkdir -p /skel/test            ////////////
[root@localhost ~]#
[root@localhost ~]# ls -la /etc/skel
합계 24
drwxr-xr-x.   4 root root   92 12월 27 13:52 .
drwxr-xr-x. 135 root root 8192 12월 27 14:12 ..
-rw-r--r--.   1 root root   18  9월  7 01:25 .bash_logout
-rw-r--r--.   1 root root  193  9월  7 01:25 .bash_profile
-rw-r--r--.   1 root root  231  9월  7 01:25 .bashrc
drwxr-xr-x.   4 root root   39  9월 25 14:49 .mozilla
drwxr-xr-x.   2 root root    6 12월 27 13:52 public
[root@localhost ~]#
[root@localhost ~]# cp /etc/skel/.* /skel
cp: omitting directory `/etc/skel/.'
cp: omitting directory `/etc/skel/..'
cp: omitting directory `/etc/skel/.mozilla'
[root@localhost ~]#
[root@localhost ~]# ls -la /skel/
합계 16
drwxr-xr-x.  3 root root   74 12월 27 14:29 .
dr-xr-xr-x. 26 root root 4096 12월 27 14:28 ..
-rw-r--r--.  1 root root   18 12월 27 14:29 .bash_logout
-rw-r--r--.  1 root root  193 12월 27 14:29 .bash_profile
-rw-r--r--.  1 root root  231 12월 27 14:29 .bashrc
drwxr-xr-x.  2 root root    6 12월 27 14:28 test
[root@localhost ~]#
[root@localhost ~]# cp -r /etc/skel/.mozilla /skel
[root@localhost ~]#
[root@localhost ~]# ls -la /skel/
합계 16
drwxr-xr-x.  4 root root   90 12월 27 14:29 .
dr-xr-xr-x. 26 root root 4096 12월 27 14:28 ..
-rw-r--r--.  1 root root   18 12월 27 14:29 .bash_logout
-rw-r--r--.  1 root root  193 12월 27 14:29 .bash_profile
-rw-r--r--.  1 root root  231 12월 27 14:29 .bashrc
drwxr-xr-x.  4 root root   39 12월 27 14:29 .mozilla
drwxr-xr-x.  2 root root    6 12월 27 14:28 test
[root@localhost ~]#
[root@localhost ~]# useradd -D -b /centos
[root@localhost ~]#
[root@localhost ~]# vi /etc/default/useradd
[root@localhost ~]#
[root@localhost ~]# useradd user9
[root@localhost ~]#
[root@localhost ~]# tail /etc/passwd
user3:x:1005:1005:testuser:/home/user3:/bin/bash
user4:x:1006:1006::/home/user4:/bin/sh
user5:x:1007:1007::/bonwon/userfive:/bin/csh
user6:x:1008:1008::/home/user6:/bin/bash
user7:x:1009:1009::/home/user7:/bin/bash
user8:x:1010:1010::/home/user8:/bin/bash
user88:x:1011:1011::/home/user88:/bin/bash
test:x:1012:1012::/jongro/test:/bin/bash
test2:x:1013:1013::/jongno/test2:/bin/bash
user9:x:1014:1014::/centos/user9:/bin/tcsh
[root@localhost ~]#
[root@localhost ~]# ls -la /centos/user9
합계 0
drwx------. 2 user9 user9  6 12월 27 14:31 .
drwxr-xr-x. 3 root  root  19 12월 27 14:31 ..
[root@localhost ~]#
[root@localhost ~]# ls -la /skel/test
합계 0
drwxr-xr-x. 2 root root  6 12월 27 14:28 .
drwxr-xr-x. 4 root root 90 12월 27 14:29 ..
[root@localhost ~]#
[root@localhost ~]# ls -la /skel
합계 16
drwxr-xr-x.  4 root root   90 12월 27 14:29 .
dr-xr-xr-x. 26 root root 4096 12월 27 14:28 ..
-rw-r--r--.  1 root root   18 12월 27 14:29 .bash_logout
-rw-r--r--.  1 root root  193 12월 27 14:29 .bash_profile
-rw-r--r--.  1 root root  231 12월 27 14:29 .bashrc
drwxr-xr-x.  4 root root   39 12월 27 14:29 .mozilla
drwxr-xr-x.  2 root root    6 12월 27 14:28 test
[root@localhost ~]#
[root@localhost ~]#

 

 

 

 

반응형
LIST

'BigData_Off1 > 리눅스1' 카테고리의 다른 글

리눅스1> 2017.12.29_13일차 - 권한> 1.허가권(Permission)  (0) 2017.12.29
리눅스1> 2017.12.28_12일차 - 그룹  (0) 2017.12.28
리눅스1> 2017.12.26_10일차- 사용자, shell  (0) 2017.12.22
VI (2)  (0) 2017.12.21
VI (1)  (0) 2017.12.19
Posted by 오정oI
, |

최근에 달린 댓글

최근에 받은 트랙백

글 보관함