becool

20210816 (월) ganar un certificado 본문

linux

20210816 (월) ganar un certificado

gusalstm 2021. 8. 16. 18:21
반응형

CSA 시험 환경

 * 강의장

   → 예전에는 월 2회, 격주 금요일

 * 개인 원격 노트북 

   → 시간당 1명만 진행 가능

  준비물 :  신분증, 볼펜, 종이 ( 리눅스 편집기로 메모 대체 )

  시험 시간 : 3시간 ( 7은 2시간30분이었음 )

  가상머신 초기화 가능

  VM 2개로 진행 ( 헷갈리지 않게 )

  약 20문 ( 설정값대로 설정하는 형식 )

  시험 채점 방식 : 가상머신 설정을 확인하는 방식 (스크립트/앤서블로 실행 확인)

            ▶ 반드시 부팅이 되어져 있는 상태여야 채점이 가능

  콘솔 gui, vm cli : 네트워크 세팅 후에는 원격 접속해서 진행하는 것이 편함.

  

  

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

root사용자

1. 재부팅 후 커널 선택 메뉴

2. 'e' edit 입력 커널 명령줄 편집 실행

3. Linux~ 시작하는 라인 (밑에서 2째줄 정도)에서 rd.break 추가 후 부팅 (Ctrl + x)

4. 부팅 중 멈추고, 프롬프트에서 명령어 순차적으로 입력

  1) 쓰기가 가능하게 마운트 재 설정

  2) 디렉터리 격리 (임시 root 디렉터리로 설정)

  3) 패스워드 변경 및 적용

  switch_root:/# mount -o remount,rw /sysroot → 쓰기가 가능하게 마운트 재설정
  switch_root:/# chroot /sysroot  → 디렉터리 격리 (임시 root 디렉터리로 설정)
  sh-4.2# passwd      → 패스워드 변경 및 적용
  Changing password for user root.
  New password :
  Retype new password:
  passwd: all authentication tokens updated successfully.
  sh-4.2# touch /.autorelabel
  sh-4.2# exit
  exit  쉘종료
  switch_root:/# exit
  logout 재부팅

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

네트워크 세팅

[root@localhost ~]# nmcli con add type ethernet con-name test ifname eth0^C
[root@localhost ~]# nmcli con mod NAME ipv4.addresses IPAddress^C
[root@localhost ~]# nmcli con mod NAME ipv4.gateway GW^C
[root@localhost ~]# nmcli con mod NAME ipv4.DNS DNS^C
[root@localhost ~]# nmcli con mod NAME ipv4.method manual ^C
[root@localhost ~]# nmcli con up NAME^C
[root@localhost ~]# hostnamectl set-hostname HOSTNAME^C
[root@localhost ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.56.100 ansible.example.localhost ansible

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

패키지 관리

[root@localhost .ssh]# vim /etc/yum.repos.d/NAME.repo^C
[root@localhost .ssh]# vim /etc/yum.repos.d/CentOS-Base.repo

[REPOID]
name = REPO NAME
baseurl = REPO URL
gpgcheck = 1/0
enabled = 1
gpgkey = XXXXXXX


##### 기본값 비교 ######

[base]
name=CentOS-$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

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

마운트 관련 먼저... → FSTAB이 꼬이면 부팅이 안되므로

1. LVM 추가/확장

  생성 순서 ( 파티션 생성 - PV - VG - LV - FILE System - Mount )

 # lsblk

 # fdisk /dev/vdb ( 주어진 장치 )

      n : 새로 생성

      종류 → 번호 → 스타트섹터 → 라스트섹터

 # partprobe /dev/vdb

 # pvcreate /dev/vdb2

 # vgcreate VGNAME /dev/vdb2 -s PESIZE (조건이 있으면)

 # lvcreate -n LVNAME -L SIZE VGNAME 

 # mkfs -t FS LVPATH

 # vim /etc/fstab

       LVPATH MOUNTPOINT FILESYSTEM defaults (OPTION)  0 0

1-2. 크기 확장

 # fdisk /dev/vdb

 # partprobe

 # pvcreate /dev/vdb3

 # vgextend VGNAME /dev/vdb3   → 볼륨그룹 확장

 

 # lvextend -L SIZE LVPATH -r → 논리볼륨 확장 ( 기존에 쓰던 lv에 대해서는 -r 옵션 필수 )

( # xfs_growfs  MOUNTPOINT → r옵션이 없는경우 : xfs ) 

( # resize2fx LVPATH → r옵션이 없는경우 : ext )

 

2. SWAP

 # fdisk /dev/vdb

 # partprobe

 # mkswap /dev/vdb5

 # vim /etc/fstab

        DEVICE SWAP(MOUNTPOINT) SWAP(FILESYSTEM) defaults(OPTION)  0 0 

 

3. VDO ( Virtual Data Optimizer : 가상의 저장소 풀을 이용하는 방식 - LVM 과 비슷 )

 목적 : 사이즈를 줄여서 공간을 확보하기 위한 스토리지 관리 방식

 중복 제거되고 압축된 스토리지 풀을 생성

 0을 제거하는 방식 사용 ( 데이터를 지우면서 메타데이터로 저장 )

 중복데이터를 제거

 압축 기능 제공 ( kvdo 커널 모듈 )

 실제 사이즈에 비해 훨씬 큰 논리적인 사이즈 제공 ( 10:1 권장 )

 어플리케이션(VM)은 논리적인 사이즈를 인식

        → 실제 사용량에 대한 모니터링 및 알림 서비스 필요

   

 

kmod-kvdo.x86_64 : Kernel Modules for Virtual Data Optimizer
vdo.x86_64 : Management tools for Virtual Data Optimizer

 

yum

systemctl

vdo --activate = enabled --name=NAME vdoLogicalSize=SIZE -n NAME --device DEVICE

mkfs -t FILESYSTEM DEVICE

vim /etc/fstab

DEVICE MOUNTPOINT FILESYSTEM defaults,x-systemd.requires=vdo.service(OPTION) 0 0

 

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

tuned 대몬 

시스템 성능 향상을 위해서 사용하는 추가 구성

tuned 서비스가 동작하면 시스템의 용도에 따라 원하는 profile을 선택

  → profile에 맞게 시스템 내부 세팅을 변경해주는 서비스

 

                                             

yum list tuned

systemctl status tuned : Dynamic system tuning daemon

tuned-adm activate

tuned-adm list → 목록확인

tuned-adm recommend  → 추천 내용 

tuned-adm profile → profile 설정

tuned-adm verify

[root@localhost ~]# yum install -y tuned
[root@localhost ~]# systemctl enable tuned --now
[root@localhost ~]# tuned-adm active
Current active profile: virtual-guest
[root@localhost ~]# tuned-adm list
Available profiles:
- accelerator-performance     - Throughput performance based tuning with disabled higher latency STOP states
- balanced                    - General non-specialized tuned profile
- desktop                     - Optimize for the desktop use-case
- hpc-compute                 - Optimize for HPC compute workloads
- intel-sst                   - Configure for Intel Speed Select Base Frequency
- latency-performance         - Optimize for deterministic performance at the cost of increased power consumption
- network-latency             - Optimize for deterministic performance at the cost of increased power consumption, focused on low latency network performance
- network-throughput          - Optimize for streaming network throughput, generally only necessary on older CPUs or 40G+ networks
- optimize-serial-console     - Optimize for serial console use.
- powersave                   - Optimize for low power consumption
- throughput-performance      - Broadly applicable tuning that provides excellent performance across a variety of common server workloads
- virtual-guest               - Optimize for running inside a virtual guest
- virtual-host                - Optimize for running KVM guests
Current active profile: virtual-guest
[root@localhost ~]# tuned-adm profile virtual-host
[root@localhost ~]# tuned-adm active
Current active profile: virtual-host
[root@localhost ~]# tuned-adm recommend
virtual-guest
[root@localhost ~]# tuned-adm off
[root@localhost ~]# tuned-adm active
No current active profile.

 

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

 

0. 가상 머시에 새로운 디스크 2개 추가

1. 첫번째 디스크에 LVM 관리

  1) 1G 파티션해서 2개의 파티션으로 csa 라는 이름의 볼륨그룹 생성

      이때 PE 사이즈는 16M로 설정

  2) 크기 1G 사이즈로 논리볼륨 생성 ( 이름 ex200 )

  3) xfs로 파일시스템을 만들어서 /mnt/lvm 디렉터리에 영구마운트

  4) 파티션 하나 더 생성 후 csa 그룹에 추가

  5) ex200 논리볼륨을 1.5G 만큼 추가

 2. 첫번째 디스크에서 SWAP 관리

  1) 500M 사이즈의 파티션을 생성해서 SWAP 활성화

 3. 두번째 디스크에서는 VDO 설정

  0) 장치는 2G 사이즈의 파티션 생성

  1) 논리이름은 vdo_exam

  2) 논리 크기는 10G로 설정 후 FSTAB 등록

 

[root@localhost .ssh]# lsblk
[root@localhost ~]# fdisk /dev/sdb
 n -> p -> default -> default -> +1G 
 n -> p -> default -> default -> +1G 
 n -> p -> default -> default -> +500M -> w
[root@localhost ~]# partprobe
[root@localhost ~]# pvcreate /dev/sdb1
[root@localhost ~]# pvcreate /dev/sdb2
[root@localhost ~]# vgcreate csa /dev/sdb1 /dev/sdb2 -s 16M
[root@localhost ~]# lvcreate -n ex200 -L 1G csa
[root@localhost ~]# mkfs -t xfs /dev/csa/ex200
## [root@localhost ~]# mkfs.xfs /dev/csa/ex200
[root@localhost ~]# vim /etc/fstab
/dev/csa/ex200   /mnt/lvm   xfs   defaults   0   0   → 추가
[root@localhost ~]# mount -a 
[root@localhost ~]# vgextend csa /dev/sdb3
[root@localhost ~]# lvextend -L +1.5G /dev/csa/ex200 -r
[root@localhost ~]# df -h
Filesystem             Size  Used Avail Use% Mounted on
/dev/mapper/csa-ex200  2.5G   51M  2.5G   2% /mnt/lvm
[root@localhost ~]# mkswap /dev/sdb5
[root@localhost ~]# vim /etc/fstab
/dev/sdb5   swap   swap   defaults    0   0
[root@localhost ~]# swapon -a

[root@localhost ~]# yum install -y vdo kmod-kvdo
[root@localhost ~]# vdo create -n vdo_exam --device /dev/sdc --vdoLogicalsize 10G
[root@localhost ~]# vim /etc/fstab
/dev/mapper/vdo_exam    /mnt/vdo        xfs     defaults,x-systemd.requires=vdo.service 0       0

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

[root@localhost ~]# lsblk
NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda           8:0    0   20G  0 disk
├─sda1        8:1    0    1G  0 part /boot
└─sda2        8:2    0   19G  0 part
  ├─cl-root 253:0    0   17G  0 lvm  /
  └─cl-swap 253:1    0    2G  0 lvm  [SWAP]
sdb           8:16   0    8G  0 disk
sdc           8:32   0    8G  0 disk
sr0          11:0    1 1024M  0 rom
[root@localhost ~]# fdisk /dev/sdb

Welcome to fdisk (util-linux 2.32.1).
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.
Created a new DOS disklabel with disk identifier 0xe32c4e66.

Command (m for help):


Command (m for help): p

Disk /dev/sdb: 8 GiB, 8589934592 bytes, 16777216 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
Disklabel type: dos
Disk identifier: 0xe32c4e66

Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-16777215, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-16777215, default 16777215): +1G

Created a new partition 1 of type 'Linux' and of size 1 GiB.

Command (m for help): n
Partition type
   p   primary (1 primary, 0 extended, 3 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (2-4, default 2):
First sector (2099200-16777215, default 2099200):
Last sector, +sectors or +size{K,M,G,T,P} (2099200-16777215, default 16777215): +1G

Created a new partition 2 of type 'Linux' and of size 1 GiB.

Command (m for help): p
Disk /dev/sdb: 8 GiB, 8589934592 bytes, 16777216 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
Disklabel type: dos
Disk identifier: 0xe32c4e66

Device     Boot   Start     End Sectors Size Id Type
/dev/sdb1          2048 2099199 2097152   1G 83 Linux
/dev/sdb2       2099200 4196351 2097152   1G 83 Linux

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

[root@localhost ~]# lsblk
NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda           8:0    0   20G  0 disk
├─sda1        8:1    0    1G  0 part /boot
└─sda2        8:2    0   19G  0 part
  ├─cl-root 253:0    0   17G  0 lvm  /
  └─cl-swap 253:1    0    2G  0 lvm  [SWAP]
sdb           8:16   0    8G  0 disk
├─sdb1        8:17   0    1G  0 part
└─sdb2        8:18   0    1G  0 part
sdc           8:32   0    8G  0 disk
sr0          11:0    1 1024M  0 rom
[root@localhost ~]# partprobe
[root@localhost ~]# pvcreate /dev/sdb1
  Physical volume "/dev/sdb1" successfully created.
[root@localhost ~]# pvcreate /dev/sdb2
  Physical volume "/dev/sdb2" successfully created.
[root@localhost ~]# vgcreate csa /dev/sdb1 /dev/sdb2 -s 16M
  Volume group "csa" successfully created
[root@localhost ~]# lvcreate -n ex200 -L 1G csa
  Logical volume "ex200" created.
[root@localhost ~]# mkfs -t xfs /dev/csa/ex200
meta-data=/dev/csa/ex200         isize=512    agcount=4, agsize=65536 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=1, rmapbt=0
         =                       reflink=1
data     =                       bsize=4096   blocks=262144, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0, ftype=1
log      =internal log           bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

[root@localhost ~]# partprobe
[root@localhost ~]# vim /etc/fstab
/dev/csa/ex200 /mnt/lvm/ defaults 0	0
[root@localhost ~]# reboot

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

Welcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): p
Disk /dev/sdb: 8 GiB, 8589934592 bytes, 16777216 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
Disklabel type: dos
Disk identifier: 0xe32c4e66

Device     Boot   Start     End Sectors Size Id Type
/dev/sdb1          2048 2099199 2097152   1G 83 Linux
/dev/sdb2       2099200 4196351 2097152   1G 83 Linux

Command (m for help): n
Partition type
   p   primary (2 primary, 0 extended, 2 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (3,4, default 3):
First sector (4196352-16777215, default 4196352):
Last sector, +sectors or +size{K,M,G,T,P} (4196352-16777215, default 16777215): +2G

Created a new partition 3 of type 'Linux' and of size 2 GiB.

Command (m for help): w
The partition table has been altered.
Syncing disks.

[root@localhost ~]# lsblk
NAME          MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda             8:0    0   20G  0 disk
├─sda1          8:1    0    1G  0 part /boot
└─sda2          8:2    0   19G  0 part
  ├─cl-root   253:0    0   17G  0 lvm  /
  └─cl-swap   253:1    0    2G  0 lvm  [SWAP]
sdb             8:16   0    8G  0 disk
├─sdb1          8:17   0    1G  0 part
│ └─csa-ex200 253:2    0    1G  0 lvm  /mnt/lvm
├─sdb2          8:18   0    1G  0 part
│ └─csa-ex200 253:2    0    1G  0 lvm  /mnt/lvm
└─sdb3          8:19   0    2G  0 part
sdc             8:32   0    8G  0 disk
sr0            11:0    1 1024M  0 rom
[root@localhost ~]# partprobe
[root@localhost ~]# vgextend csa /dev/sdb3
  Physical volume "/dev/sdb3" successfully created.
  Volume group "csa" successfully extended
[root@localhost ~]# lvextend -L 2.5G /dev/csa/ex200 -r
  Size of logical volume csa/ex200 changed from 1.50 GiB (96 extents) to 2.50 GiB (160 extents).
  Logical volume csa/ex200 successfully resized.
meta-data=/dev/mapper/csa-ex200  isize=512    agcount=6, agsize=65536 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=1, rmapbt=0
         =                       reflink=1
data     =                       bsize=4096   blocks=393216, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0, ftype=1
log      =internal log           bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 393216 to 655360
[root@localhost ~]# partprobe
[root@localhost ~]# lvdisplay /dev/csa/ex200
  --- Logical volume ---
  LV Path                /dev/csa/ex200
  LV Name                ex200
  VG Name                csa
  LV UUID                Oah7bZ-FqaY-f1Yg-9Xmm-VhMu-a33T-jciga0
  LV Write Access        read/write
  LV Creation host, time localhost.localdomain, 2021-08-16 12:42:01 +0900
  LV Status              available
  # open                 1
  LV Size                2.50 GiB
  Current LE             160
  Segments               3
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:2

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

Welcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): n
Partition type
   p   primary (3 primary, 0 extended, 1 free)
   e   extended (container for logical partitions)
Select (default e): p

Selected partition 4
First sector (8390656-16777215, default 8390656):
Last sector, +sectors or +size{K,M,G,T,P} (8390656-16777215, default 16777215): +500M

Created a new partition 4 of type 'Linux' and of size 500 MiB.

Command (m for help): p
Disk /dev/sdb: 8 GiB, 8589934592 bytes, 16777216 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
Disklabel type: dos
Disk identifier: 0xe32c4e66

Device     Boot   Start     End Sectors  Size Id Type
/dev/sdb1          2048 2099199 2097152    1G 83 Linux
/dev/sdb2       2099200 4196351 2097152    1G 83 Linux

/dev/sdb3       4196352 8390655 4194304    2G 83 Linux
/dev/sdb4       8390656 9414655 1024000  500M 83 Linux

Command (m for help): w
The partition table has been altered.
Syncing disks.

[root@localhost ~]# partprobe
[root@localhost ~]# lsblk
NAME          MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda             8:0    0   20G  0 disk
├─sda1          8:1    0    1G  0 part /boot
└─sda2          8:2    0   19G  0 part
  ├─cl-root   253:0    0   17G  0 lvm  /
  └─cl-swap   253:1    0    2G  0 lvm  [SWAP]
sdb             8:16   0    8G  0 disk
├─sdb1          8:17   0    1G  0 part
│ └─csa-ex200 253:2    0  2.5G  0 lvm  /mnt/lvm
├─sdb2          8:18   0    1G  0 part
│ └─csa-ex200 253:2    0  2.5G  0 lvm  /mnt/lvm
├─sdb3          8:19   0    2G  0 part
│ └─csa-ex200 253:2    0  2.5G  0 lvm  /mnt/lvm
└─sdb4          8:20   0  500M  0 part
sdc             8:32   0    8G  0 disk
sr0            11:0    1 1024M  0 rom
[root@localhost ~]# mkswap /dev/sdb4
Setting up swapspace version 1, size = 500 MiB (524283904 bytes)
no label, UUID=a7bba362-055a-4146-9ae7-e393004d0949


==========================================================

[root@localhost mapper]# dd if=/dev/zero of=/dev/sdc count=60 bs=60k
60+0 records in
60+0 records out
3686400 bytes (3.7 MB, 3.5 MiB) copied, 0.00910983 s, 405 MB/s

[root@localhost ~]# lsblk
NAME          MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda             8:0    0   20G  0 disk
├─sda1          8:1    0    1G  0 part /boot
└─sda2          8:2    0   19G  0 part
  ├─cl-root   253:0    0   17G  0 lvm  /
  └─cl-swap   253:1    0    2G  0 lvm  [SWAP]
sdb             8:16   0    8G  0 disk
├─sdb1          8:17   0    1G  0 part
│ └─csa-ex200 253:2    0  2.5G  0 lvm  /mnt/lvm
├─sdb2          8:18   0    1G  0 part
│ └─csa-ex200 253:2    0  2.5G  0 lvm  /mnt/lvm
├─sdb3          8:19   0    2G  0 part
│ └─csa-ex200 253:2    0  2.5G  0 lvm  /mnt/lvm
└─sdb4          8:20   0  500M  0 part
sdc             8:32   0    8G  0 disk
└─vdo_exam    253:3    0   10G  0 vdo  /mnt/vdo
sdd             8:48   0    8G  0 disk
sr0            11:0    1 1024M  0 rom

[root@localhost ~]# vdo create -n vdo_exam2 --vdoLogicalSize 10G --device /dev/sdd
Creating VDO vdo_exam2


      The VDO volume can address 4 GB in 2 data slabs, each 2 GB.
      It can grow to address at most 16 TB of physical storage in 8192 slabs.
      If a larger maximum size might be needed, use bigger slabs.
Starting VDO vdo_exam2
Starting compression on VDO vdo_exam2
VDO instance 1 volume is ready at /dev/mapper/vdo_exam2

[root@localhost ~]# mkfs.xfs /dev/mapper/vdo_exam2
meta-data=/dev/mapper/vdo_exam2  isize=512    agcount=4, agsize=655360 blks
         =                       sectsz=4096  attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=1, rmapbt=0
         =                       reflink=1
data     =                       bsize=4096   blocks=2621440, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0, ftype=1
log      =internal log           bsize=4096   blocks=2560, version=2
         =                       sectsz=4096  sunit=1 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

[root@localhost ~]#
[root@localhost ~]# vim /etc/fstab
[root@localhost ~]# cat /etc/fstab |grep vdo
/dev/mapper/vdo_exam    /mnt/vdo        xfs     defaults,x-systemd.requires=vdo.service 0       0
/dev/mapper/vdo_exam2   /mnt/vdo2       xfs     defaults,x-systemd.requires=vdo.service 0       0
[root@localhost ~]# mkdir /mnt/vdo2
[root@localhost ~]# mount -a
[root@localhost ~]# df -h
Filesystem             Size  Used Avail Use% Mounted on
devtmpfs               1.9G     0  1.9G   0% /dev
tmpfs                  1.9G     0  1.9G   0% /dev/shm
tmpfs                  1.9G  9.2M  1.9G   1% /run
tmpfs                  1.9G     0  1.9G   0% /sys/fs/cgroup
/dev/mapper/cl-root     17G  4.3G   13G  26% /
/dev/mapper/csa-ex200  2.5G   51M  2.5G   2% /mnt/lvm
/dev/sda1              976M  193M  716M  22% /boot
/dev/mapper/vdo_exam    10G  104M  9.9G   2% /mnt/vdo
tmpfs                  378M  1.2M  377M   1% /run/user/42
tmpfs                  378M  4.0K  378M   1% /run/user/0
/dev/mapper/vdo_exam2   10G  104M  9.9G   2% /mnt/vdo2

 

/dev/mapper/vdo_exam /mnt/vdo xfs defaults,x-systemd.requires=vdo.sesrvice 0 0 

mkfs -t xfs /dev/sdc → 사이즈카 크면 오래 걸림

mkfs.xfs -K /dev/sdc → 사이즈가 큰경우 시간 단축 옵션

 

[root@localhost ~]# dd if=/dev/zero of=/dev/path count=60 bs=60k

 

728x90

 

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

사용자 관리

  useradd   공통 옵션 -u, -g, -G, -s

  usermod  수정 : -a, -L, -U ( LOCK,UNLOCK 잠금/잠금해제 )

  userdel    삭제 : -r

 

-s 쉘 : bin/bash /bin/nologin /bin/sh

-g 그룹 : 그룹먼저 생성 후 추가해야한다.

 

 groupadd group01

 usermod -G group01 user → 기존 보조그룹 모두 삭제후 group01 만 남겨둔다.

 usermod -a -G group01 user  → 기존 보조 그룹 유지

 passwd user

 chage -l user  : -m, -M, -W, -I, -E 등 옵션 ( -d 0 으로 설정시, 사용자가 강제로 비번을 바꾸게 함 )

 

그룹 관리

 groupadd  공통 옵션 -g

 groupmod 수정 : - n 

 groupdel 

 

패스워드

  passwd

  chage  패스워드에 대한 기간 설정

  [root@localhost ~]# vim /etc/login.defs (기본값 변경시 편집)

 

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

권한 관리

 chmod   파일권한 변경  ( 소유자/소유그룹/기타 )

 chown   소유권 변경

 umask   파일의 기본 권한 ( /etc/profile, ~/bashrc )

 setfacl     ACL설정  

   -m 추가/수정

   -x 특정항목 삭제

   -k default ACL 전체 삭제

   -b 모든 ACL 전체 삭제

  +@ 특수권한 디렉터리에 설정했을때, sticky bit

 

 

 

[root@localhost ~]# groupadd -g 1500 girl
[root@localhost ~]# groupadd -g 2000 john
[root@localhost ~]# tail /etc/group
rpcuser:x:29:
gnome-initial-setup:x:975:
sshd:x:74:
avahi:x:70:
slocate:x:21:
rngd:x:974:
tcpdump:x:72:
centos:x:1000:
girl:x:1500:
john:x:2000:
[root@localhost ~]# useradd -u 3000 -g 1500 -G wheel hera
[root@localhost ~]# useradd -u 2000 -g 2000 -s /bin/sh john
[root@localhost ~]# useradd -s /sbin/nologin ghost
[root@localhost ~]# tail -n 3 /etc/passwd
hera:x:3000:1500::/home/hera:/bin/bash
john:x:2000:2000::/home/john:/bin/sh
ghost:x:3001:3001::/home/ghost:/sbin/nologin
[root@localhost ~]# id hera
uid=3000(hera) gid=1500(girl) groups=1500(girl),10(wheel)
[root@localhost ~]# passwd hera
[root@localhost ~]# passwd john
[root@localhost ~]# passwd ghost
[root@localhost ~]# chage -m 1 -M 30 -W 3 hera
[root@localhost ~]# chage -E 30Aug2021 john
[root@localhost ~]# vim /etc/login.defs
PASS_MAX_DAYS   60
PASS_MIN_DAYS   0
PASS_MIN_LEN    5
PASS_WARN_AGE   5
[root@localhost ~]# useradd testuser   
[root@localhost ~]# tail -n 1 /etc/shadow  → default 작업 확인

[root@localhost home]# chown hera:wheel fileA
[root@localhost home]# chmod 640 fileA
[root@localhost home]# ls -l fileA
-rw-r-----+ 1 hera wheel 0 Aug 16 15:14 fileA
[root@localhost home]# setfacl -m u:john:rw fileA
[root@localhost home]# getfacl fileA
# file: fileA
# owner: hera
# group: wheel
user::rw-
user:john:rw-
group::r--
mask::rw-
other::---
[root@localhost home]# groupadd works
[root@localhost home]# mkdir dirA
[root@localhost home]# chown :works dirA
[root@localhost home]# chmod g+s dirA
[root@localhost home]# ls -ld dirA/
drwxr-sr-x. 2 root works 6 Aug 16 15:26 dirA/

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

검색 - find / grep

 - 파일 검색 : find

        검색 옵션 : -name, -size, -perm, -owner, -group, -type …

        동작 옵션 : -ls, -print, -delete, -exec, -ok

                                       → exec 명령어 {} 디렉터리 \;

 

 - 텍스트 파일에서 문자열 검색 : grep

        옵션 : -i, -v, -e, -w, -r, -A, -B, -C

        정규표현식 : ^, $, ., * …

 

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

 크론 - /etc/crontab/

  분 시 일 월 요일 사용자이름 명령어

          x        : 특정 시간(일)

         x,y,z     : 특정 시간(일) 여러개 리스트

         a-z      : 특정 범위 시간(일)

          *        : 모든값(무시)

          */n     : 반복 주기 (*/2 : 2분 단위로)

 

[root@localhost ~]# vim /etc/crontab

 0 20 * * * root rm -rf(디렉터리도 포함) -f(파일만) /tmp/* 대상디렉터리

 

 

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

 아카이브 - tar

        동작 옵션 : c, x, t

        필수 옵션 : f

        선택 옵션 : v, -C

        압축 옵션 : z, i, j, J

 Compression options:
  -j, --bzip2                filter the archive through bzip2
  -J, --xz                   filter the archive through xz
      --lzip                 filter the archive through lzip
      --lzma                 filter the archive through xz --format=lzma
      --lzop                 filter the archive through lzop
      --no-auto-compress     do not use archive suffix to determine the
                             compression program
  -z, --gzip, --gunzip, --ungzip   filter the archive through gzip
  -Z, --compress, --uncompress   filter the archive through compress

 

 NTP - /etc/chrony.conf, timedatectl, chronyd(서비스 활성화, 재시작)

    [root@localhost home]# timedatectl set-ntp true  → NTP service : active 활성화됨.
    [root@localhost home]# timedatectl |grep service
              NTP service: active

    [root@localhost home]# systemctl restart chronyd 
    [root@localhost ~]# timedatectl set-timezone Asia/Shanghai
    [root@localhost ~]# timedatectl
                   Local time: Mon 2021-08-16 16:11:11 CST
               Universal time: Mon 2021-08-16 08:11:11 UTC
                     RTC time: Mon 2021-08-16 08:11:10
                    Time zone: Asia/Shanghai (CST, +0800)
    System clock synchronized: yes
                  NTP service: active
              RTC in local TZ: no
    [root@localhost ~]# timedatectl set-timezone Asia/Seoul
    [root@localhost ~]# timedatectl
                   Local time: Mon 2021-08-16 17:11:28 KST
               Universal time: Mon 2021-08-16 08:11:28 UTC
                     RTC time: Mon 2021-08-16 08:11:28
                    Time zone: Asia/Seoul (KST, +0900)
    System clock synchronized: yes
                  NTP service: active
              RTC in local TZ: no
    [root@localhost ~]# vim /etc/chrony.conf
    pool 2.centos.pool.ntp.org iburst
    server test.ntp.org iburst

    [root@localhost ~]# chronyc sources -v
    [root@localhost ~]# systemctl restart chronyd

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

SELinux

 동작모드 : /etc/selinux/config

 컨텍스트 : semanage fcontext -a -t CONTEXT_NAME FILE(or DIR)

               restorecon -RFv FILE(or DIR)

 부울 : semanage boolean -l : 확인

         setsebool -P XXXX

 포트 : semanage port -l : 확인

         semanage port -a / -m / -d : 추가/수정/삭제

 

[root@localhost ~]# semanage port -l |grep -w 80
http_port_t                    tcp      80, 81, 443, 488, 8008, 8009, 8443, 9000

[root@localhost ~]# semanage port -a -t http_port_t -p tcp 8282
[root@localhost ~]# semanage port -l |grep -w 8282
http_port_t                    tcp      8282, 80, 81, 443, 488, 8008, 8009, 8443, 9000

 

 

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

Script 구문

 #!/bin/bash

 명령어 사용법 : if, for 조건문, 반복문

 실행권한 : chmod a+x FILE

 

   

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

 

728x90

'linux' 카테고리의 다른 글

20210817 (화) autofs  (0) 2021.08.17
20210816 (월 ) find  (0) 2021.08.17
20210719 (월) time zone 변경  (0) 2021.07.19
윈도우터미널에서 ssh 암호없이 원격 접속  (0) 2021.07.15
20210702 (금) dns - apache - tomcat - db  (0) 2021.07.02
Comments