일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
- ssh
- newbingai
- vagrant kubernetes
- pvcreate
- mount
- 엑셀파일명변경
- swapon
- docker
- 날짜변경
- 같은폴더
- 랜카드인식불량
- vgcreate
- yum
- MSBing
- chatGPT
- HTTPD
- ansible
- nmcli
- 프로세스
- chmod
- firewalld
- journalctl
- permission
- M365필터
- docker image
- docker network
- Kubernetes
- 리다이렉션
- tar
- lvcreate
- Today
- Total
becool
20210817 (화) 실습 본문
시험 대비 전체 실습
0. 가상머신을 2대 준비합니다. (8버전 2대, 혹은 7버전 1개 8버전 1개)
1. 각 가상머신의 네트워크를 다음과 같이 구성하세요.
IP : 10.0.2.100/24 , 10.0.2.200/24
GW : 10.0.2.1 (공통)
DNS : 8.8.8.8
HOSTNAME : vm1.exam.com , vm2.exam.com
2. 두 가상머신의 패키지는 다음 주소에서 다운로드 할 수 있습니다.
http://repository.centos.example.com/repo
(단, 실제 주소가 아니므로 설정 파일만 만들고 비활성화 해두세요.)
3. vm1 시스템에 다음과 같은 사용자 및 그룹을 만드세요.
이름 : sahara , UID : 1200 , 보조그룹 : desert
이름 : salt , 보조그룹 : desert , 로그인 못하는 사용자
패스워드는 동일하게 1234 로 설정
4. vm1 시스템에서는 /tmp/share 라는 협동 작업을 위한 디렉토리를 만드세요.
이 디렉토리는 desert 그룹의 소유이며 해당 그룹 사용자들은 모든 권한이 있지만
root 를 제외한 다른 모든 사용자들은 권한이 없습니다.
그리고 이후 만드는 모든 파일들은 desert 그룹이 소유그룹을 설정되어야 합니다.
5. 각각의 시스템은 3.centos.pool.ntp.org 만 NTP 서버로 사용해야 합니다.
6. vm1 시스템에서 5분마다 반복적으로 다음 작업을 실행하도록 구성하세요.
sahara 사용자에 의해 logger "Test exam" 실행
7. vm1 시스템에서 /etc/fstab 을 /tmp/fstab 으로 복사하고 권한을 다음과 같이 설정하세요.
파일의 소유자는 root 이며, 소유 그룹은 wheel 입니다.
모든 사용자는 실행권한이 없습니다.
sahara 사용자는 읽기 쓰기가 가능합니다.
salt 사용자는 모든 권한이 없습니다.
나머지 기타 사용자들은 파일을 읽어볼 수 있습니다.
8. vm2 시스템에서 4545 라는 UID 를 사용하는 newuser 를 만들고 패스워드를 1234 로 설정하세요.
9. vm1 에서 sahara 사용자 소유의 일반파일을 찾아서 모두 삭제하세요.
10. vm2 시스템에서 /usr/share/dict/words 파일에서 대소문자 구분 없이 cat 라는 글자로 시작하는 라인을 모두 찾아 /root/words 파일에 저장하세요.
11. vm2 시스템에서 /var/log 디렉토리에 있는 모든 파일과 디렉토리들을 묶어서 /root/arc.tar.xz 으로 만드세요.
이 파일은 XZ 방식으로 압축되어야 합니다.
12. vm1 시스템에서 8888 포트를 이용해서 웹서비스를 제공할 수 있도록 구성하세요.
/var/www/html/index.html 파일에서는 접속 시 "Hello" 라는 문자를 출력해줍니다.
13. vm1 에서 /usr/games , /usr/local , /usr/share 디렉토리를 NFS 를 통해 각각 제공합니다.
14. vm1 에서 제공하는 디렉토리 들을 /autoshare 디렉토리에 자동마운트 설정을 하세요.
15. vm1 에서 조건에 맞는 파일을 검색하는 스크립트를 만드세요.
크기가 100K 이상 10M 이하이며 set-uid 가 설정되어 있는 모든 파일을 찾습니다.
검색한 파일들의 이름은 /root/findout 파일에 저장합니다.
16. vm1 에 8G 디스크 장치를 추가하고 다음과 같이 논리볼륨을 확장하세요.
추가한 디스크에서 5G 크기의 파티션을 만들고
현재 사용 중인 root 디렉토리가 마운트되어 있는 논리볼륨에 해당 장치의 전체 크기를 다 추가해 확장합니다.
17. vm2 에 10G 디스크 장치를 추가하고 VDO 볼륨을 만드세요.
해당 장치를 vdotest 라는 이름의 볼륨으로 만듦니다.
논리적인 크기는 50G 입니다.
xfs 파일시스템으로 구성하며 /vdodir 에 부팅 시 자동 마운트 되도록 설정합니다.
18. vm2 에 8G 디스크를 하나 더 추가하고 논리볼륨을 만드세요.
newvg 라는 볼륨 그룹에 newlv 라는 논리볼륨을 만드세요.
이 논리볼륨 및 볼륨 그룹의 확장영역 크기는 16M 입니다.
파일시스템은 ext4 로 만들고 /mnt/lvm 디렉토리에 부팅 시 자동 마운트 됩니다.
19. vm1 에서 시스템에서 권장하는 튜닝 프로파일을 확인하고 해당 프로파일로 재설정하세요.
20. 16번에서 추가했던 장치의 남은 공간에서 1G 크기의 파티션을 만들어서 swap영역으로 영구설정하세요.
21. vm2 시스템에서 앞으로 만드는 사용자들은 패스워드 최소 사용일이 하루, 최대 30일로 제한됩니다. (경고는 3일)
22. 8버전 시스템에서(아무거나 하나 선택) 컨테이너로 웹서비스를 실행해서 영구적으로 부팅 시 자동실행 되도록 구성합니다.
httpd:latest 이미지를 web 이라는 이름의 컨테이를 생성
sahara 사용자에 의해서만 실행하는 systemd 로 등록
서비스는 container-web.service 라는 이름으로 지정되어 재부팅 시 자동실행 되어야 합니다.
====================
1.
nmcli con mod enp0s8 ipv4.address 10.0.2.100/24
nmcli con mod enp0s8 ipv4.gateway 10.0.2.1
nmcli con mod enp0s8 ipv4.dns 8.8.8.8
nmcli con mod enp0s8 ipv4.method manual
nmcli con up enp0s8
hostnamectl set-hostname vm1.exam.com
2.
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# [root@localhost yum.repos.d]# cat CentOS-Exam.repo
[Exam]
name=CentOS-$releasever - Exam
baseurl=http://repository.centos.example/com/repo
enabled=0
→ 활성화 : 1
gpgcheck=0
→ 0 , 1 (1인경우 gpgkey 도 작성)
3.
[root@localhost yum.repos.d]# groupadd desert
[root@localhost yum.repos.d]# useradd --uid 1200 -G desert sahara
[root@localhost yum.repos.d]# id sahara
uid=1200(sahara) gid=1200(sahara) groups=1200(sahara),1001(desert)
[root@localhost yum.repos.d]# useradd -G desert -s /sbin/nologin salt
[root@localhost yum.repos.d]# id salt
uid=1201(salt) gid=1201(salt) groups=1201(salt),1001(desert)
[root@localhost yum.repos.d]# passwd sahara
Changing password for user sahara.
New password:
BAD PASSWORD: The password is shorter than 8 characters
Retype new password:
passwd: all authentication tokens updated successfully.
[root@localhost yum.repos.d]# passwd salt
4.
[root@localhost yum.repos.d]# mkdir -p /tmp/share
[root@localhost yum.repos.d]# chown :desert /tmp/share
[root@localhost ~]# chmod 070 /tmp/share/
[root@localhost ~]# chmod g+s /tmp/share
[root@localhost ~]# getfacl /tmp/share/
getfacl: Removing leading '/' from absolute path names
# file: tmp/share/
# owner: root
# group: desert
# flags: -s-
user::---
group::rwx
other::---
[root@localhost ~]# ls -ld /tmp/share/
d---rws---. 2 root desert 6 Aug 17 15:18 /tmp/share/
[root@localhost ~]#
5.
[root@localhost ~]# vim /etc/chrony.conf
server 3.centos.pool.ntp.org iburst
[root@localhost ~]# timedatectl set-ntp true
[root@localhost ~]# timedatectl
Local time: Tue 2021-08-17 15:35:40 KST
Universal time: Tue 2021-08-17 06:35:40 UTC
RTC time: Tue 2021-08-17 06:35:40
Time zone: Asia/Seoul (KST, +0900)
System clock synchronized: no
NTP service: active
RTC in local TZ: no
6.
[root@vm1 ~]# cat /etc/crontab |grep sahara
*/5 * * * * sahara logger "Test exam"
7.
[root@vm1 tmp]# chown root:wheel fstab
[root@vm1 tmp]# chmod 004 fstab
[root@vm1 tmp]# setfacl -m u:sahara:rw fstab
[root@vm1 tmp]# setfacl -m u:sahara:rw fstab
[root@vm1 tmp]# setfacl -m u:salt:- fstab
[root@vm1 tmp]# getfacl fstab
# file: fstab
# owner: root
# group: wheel
user::---
user:sahara:rw-
user:salt:---
group::---
mask::rw-
other::r--
[root@vm1 tmp]# ls -l fstab
----rwxr--+ 1 root wheel 579 Aug 17 15:44 fstab
8.
[root@vm2 ~]# useradd --uid 4545 newuser
[root@vm2 ~]# id newuser
uid=4545(newuser) gid=4545(newuser) groups=4545(newuser)
[root@vm2 ~]# passwd newuser
9.
[root@vm1 tmp]# find / -type f -user "sahara" -exec rm {} +
10.
[root@vm2 ~]# cat /usr/share/dict/words |grep -i ^cat > /root/words
grep -i '^cat' > /root/words
11.
[root@vm2 ~]# tar Jcvf /root/arc.tar.xz /var/log
cd /var/log
tar Jcf /root/arc.tar.xz
12.
[root@vm1 tmp]# semanage port -a -t http_port_t -p tcp 8888
[root@vm1 tmp]# semanage port -l
[root@vm1 tmp]# yum install -y httpd
[root@vm1 tmp]# systemctl enable httpd --now
[root@vm1 tmp]# firewall-cmd --add-port=8888/tcp
success
[root@vm1 tmp]# firewall-cmd --add-port=8888/tcp --permanent
success
[root@vm1 html]# cat /etc/httpd/conf/httpd.conf |grep 8888
Listen 8888
[root@vm1 html]# curl http://localhost:8888
Hello
13.
[root@vm1 ~]# firewall-cmd --add-service=nfs
success
[root@vm1 ~]# firewall-cmd --add-service=nfs --permanent
success
[root@vm1 ~]# systemctl enable nfs-server --now
[root@vm1 ~]# cat /etc/exports
/usr/games *(rw,sync)
/usr/local *(rw,sync)
/usr/share *(rw,sync)
[root@vm1 ~]# exportfs -r
14.
[root@vm2 ~]# yum install -y autofs
[root@vm2 ~]# cat /etc/auto.master.d/exam.autofs
/autoshare /etc/auto.exam
[root@vm2 ~]# cat /etc/auto.exam
* -rw,sync 192.168.56.202:/usr/&
[root@vm2 ~]# systemctl restart autofs
[root@vm2 ~]# systemctl enable autofs --now
[root@vm2 ~]# cd /autoshare/share
[root@vm2 ~]# df -hT
Filesystem Type Size Used Avail Use% Mounted on
devtmpfs devtmpfs 903M 0 903M 0% /dev
tmpfs tmpfs 919M 18M 902M 2% /run
tmpfs tmpfs 919M 0 919M 0% /sys/fs/cgroup
/dev/mapper/centos-root xfs 17G 4.8G 13G 28% /
tmpfs tmpfs 184M 32K 184M 1% /run/user/0
192.168.56.202:/usr/games nfs4 17G 4.5G 13G 26% /autoshare/games
192.168.56.202:/usr/share nfs4 17G 4.5G 13G 26% /autoshare/share
15.
[root@vm1 ~]# cat test.sh
#!/bin/bash
find / -type f -size +100k -size -10M -perm -4000 >> /root/findout
16.
[root@vm1 ~]# fdisk /dev/sdb → 5G 파티션
[root@vm1 ~]# partprobe
[root@vm1 ~]# vgextend /dev/cl /dev/sdb1 → 볼륨그룹 cl에 장치를 추가확장
[root@vm1 ~]# lvextend -l 7677 /dev/cl/root -r
Size of logical volume cl/root unchanged from <29.99 GiB (7677 extents).
Logical volume cl/root successfully resized.
meta-data=/dev/mapper/cl-root isize=512 agcount=5, agsize=1113856 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=1, rmapbt=0
= reflink=1
data = bsize=4096 blocks=4979712, 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 4979712 to 7861248
17.
[root@vm2 ~]# vdo create --vdoLogicalSize 50G -n vdotest --device /dev/sdb^C
[root@vm2 ~]# mkfs.xfs /dev/mapper/vdotest ^C
[root@vm2 ~]# vim /etc/fstab ^C
[root@vm2 ~]# tail -n 1 /etc/fstab
/dev/mapper/vdotest /vdodir xfs defaults,x-systemd.requires=vdo.service 0 0
[root@vm2 ~]# mount -a
18.
[root@vm2 ~]# partprobe
[root@vm2 ~]# pvcreate /dev/sdc
Device /dev/sdc excluded by a filter.
[root@vm2 ~]#
[root@vm2 ~]# pvcreate /dev/sdc1
Physical volume "/dev/sdc1" successfully create
[root@vm2 ~]# vgcreate newvg -s 16 /dev/sdc1
Volume group "newvg" successfully created
[root@vm2 ~]# lvcreate -n newlv -l 511 newvg
Logical volume "newlv" created.
[root@vm2 ~]# tail -n 1 /etc/fstab
/dev/newvg/newlv /mnt/lvm ext4 defaults 0 0
19.
[root@vm1 home]# tuned-adm recommend
virtual-guest
20.
[root@vm1 home]# fdisk /dev/sdb → 1G추가 후 w
[root@vm1 home]# tail -n 1 /etc/fstab
/dev/sdb2 swap swap defaults 0 0
[root@vm1 home]# mount -a
21.
[root@vm1 home]# cat /etc/login.defs
PASS_MAX_DAYS 30
PASS_MIN_DAYS 1
PASS_MIN_LEN 5
PASS_WARN_AGE 3
22.
유저 sahara로 접속
[sahara@vm1 ~]$ mkdir -p .config/containers/systemd/user
[sahara@vm1 ~]$ cd .config/containers/systemd/user
[sahara@vm1 user]$ podman search httpd^C
[sahara@vm1 user]$ podman pull registry.access.redhat.com/rhscl/httpd-24-rhel7
[sahara@vm1 user]$ podman container run -d --name web registry.access.redhat.com/rhscl/httpd-24-rhel7:latest
2955a701701c2e32d87c3be29513d9990d01f8085ddf27d50adcc8ce37b7b10c
[sahara@vm1 user]$ podman generate systemd -n web -f
/home/sahara/.config/containers/systemd/user/container-web.service
[sahara@vm1 user]$ loginctl enable-linger sahara
[sahara@vm1 user]$ loginctl list-users
UID USER
0 root
42 gdm
1200 sahara
3 users listed.
[sahara@vm1 user]$ systemctl --user enable container-web.service --now
'linux' 카테고리의 다른 글
20210817 (화) autofs (0) | 2021.08.17 |
---|---|
20210816 (월 ) find (0) | 2021.08.17 |
20210816 (월) ganar un certificado (0) | 2021.08.16 |
20210719 (월) time zone 변경 (0) | 2021.07.19 |
윈도우터미널에서 ssh 암호없이 원격 접속 (0) | 2021.07.15 |