grup โ e โ rd.break ์
๋ ฅ โ ctrl+x ์
๋ ฅ
# sysmount ์์น์ ๋ง์ดํธ(read, write ๊ถํ)
mount -o remount,rw /sysroot
# chroot: ๋ฃจํธ ๋๋ ํ ๋ฆฌ ์ค์
# ๋ง์ดํธ ํด์ค ์์น๋ฅผ ๋ฃจํธ ๋๋ ํ ๋ฆฌ๋ก ์ค์
chroot /sysroot
passwd
touch /.autorelabel
exit
exit
๋จ ๋์คํฌ ์ด๊ธฐํ ๋จ๊ณ์์๋ ๋ฃจํธ ํ์ผ ์์คํ ์ด /sysroot์ ์ฝ๊ธฐ ์ ์ฉ์ผ๋ก ๋ง์ดํธ ๋์ด ์๊ธฐ ๋๋ฌธ์ ์ฝ๊ธฐ์ฐ๊ธฐ๋ก ๋ค์ ๋ง์ดํธ ํ๋ค. mount ๋ช ๋ น์ด์ '-o' ์ต์ ์ ์ฌ์ฉํด remount,rw ๋ฅผ ์ธ์๋ก ์ง์ ํ๋ฉด ์ฝ๊ธฐ์ ์ฉ์์ ์ฝ๊ธฐ-์ฐ๊ธฐ๋ก ๋ค์ ๋ง์ดํธ ๋๋ค.
SELinux๋ฅผ ์ฌ์ฉํ๋ฉด ํ์ผ๋ง๋ค ๋ ์ด๋ธ์ด ๋ถ์ฌ๋๋ค. ํ์ง๋ง chroot ๋ช ๋ น์ ์ฌ์ฉํ์ฌ ๋ฃจํธ ๋๋ ํ ๋ฆฌ๋ฅผ ๋ณ๊ฒฝํ๊ฒ ๋๋ฉด ํ์ผ์ ๋ํ ๋ ์ด๋ธ์ ๋ณด๊ฐ ์ ๋ถ ์ ๊ฑฐ๋๋ค. ๋ฐ๋ผ์ํ์ผ์ ๋ํ ๋ ์ด๋ธ์ ์ฌ์ง์ ํด์ผ ํ๋ค. ์ด ๋ /.autorelabel ํ์ผ์ ๋นํ์ผ๋ก ์์ฑํ๋ฉด ์์คํ ์ด ๋ถํ ๋ ๋ ์ด ํ์ผ์ ๋ฐ๊ฒฌํ๊ณ ํ์ผ์ ๋ํ ๋ ์ด๋ธ์ ์๋์ผ๋ก ๋ถ์ฌํ๋ค. ํ์ผ์ ๋ํ ๋ ์ด๋ธ์ด ์ข ๋ฃ๋๋ฉด ํด๋น ํ์ผ์ ์ญ์ ๋๋ฉฐ root ํจ์ค์๋๊ฐ ๋ณต๊ตฌ๋๋ค.
nmcli con add type ethernet con-name exam ifname eth0
nmcli con mod exam ipv4.address '192.168.56.200/24'
nmcli con mod exam ipv4.gateway '192.168.56.254'
nmcli con mod exam ipv4.dns '8.8.8.8'
nmcli con mod exam ipv4.method manual
nmcli con up exam
hostnamectl set-hostname test1.network.example.com
vi /etc/yum.repod.d/base.repo
# BaseOS, AppStream
[BaseOS]
name=base
baseurl=http://~
gpgcheck=0
enabled=1
# ๋ง์ฝ gpgkey ์
๋ ฅํ๋ผ๊ณ ํ๋ฉด gpgcheck=1๋ก ๋ฐ๊พธ๊ณ
gpgkey=~
(1) HTTP
yum -y install httpd
systemctl enable httpd
systemctl start htpd
systemctl reload httpd
systemctl status httpd
firewalld-cmd --list-all
semanage port -l | grep 8888
firewalld-cmd --add-port=8888/tcp # http port, protocol
firewall-cmd --add-port=8888/tcp --permanent
semanage port -a -t http_port_d 8888 -p tcp
systemctl restart httpd
(2) SSH
yum -y inistall openssh
vi /etc/ssh/sshd_config ์์ Port 22 ๋ถ๋ถ ์ฃผ์ ํด์
systemctl start openssh
systemctl enable openssh
systemctl reload openssh
firewall-cmd --add-port=22/tcp --permanent
semanage port -a -t ssh_port_t 22 -p tcp
systemctl restart openssh
group name: testgrp
testgrp ์ ๋ณด์กฐ ๊ทธ๋ฃน์ผ๋ก ์ํ ์ฌ์ฉ์: haha
testgrp ์ ๋ณด์กฐ ๊ทธ๋ฃน์ผ๋ก ์ํ ๋ค๋ฅธ ์ฌ์ฉ์: hihi
์์คํ ์์ ๋ํํ ์์ ๋ํ ์ก์ธ์ค ๊ถํ์ด ์์ผ๋ฉฐ testgrp์ ๋ฉค๋ฒ๊ฐ ์๋ hoho
haha, hihi, hoho ์๋ ๋ชจ๋ ์ํธ๊ฐ ์์ด์ผ ํ๋ค
# make group
groupadd testgrp
# add user to group(-aG)
useradd haha -G testgrp
useradd hihi -G testgrp
useradd hoho -s /sbin/nologin
# set password
passwd haha
passwd hihi
passwd hoho
useradd -m, -d, -u, -c, -s, -G ์ ์๋ฏธ
- m: create the user's home directiory
- d: home directory of the new account
- u: user ID of the new account(UID)
- c: GECOS field of the new account(comment, ์ฆ ์ฃผ์)
- s: login shell of the new account
- G: list of supplementary groups of the new account(๋ณด์กฐ ๊ทธ๋ฃน)
/bin๊ณผ /sbin
- /bin : For binaries usable before the /usr partition is mounted. This is used for trivial binaries used in the very early boot stage or ones that you need to have available in booting single-user mode. Think of binaries like cat, ls, etc.
- /sbin : Same, but for binaries with superuser (root) privileges required.
๊ณ์ ์์ฑ์ ๊ด์ฌํ๋ ๋๋ ํ ๋ฆฌ
- /etc/login.defs
- /etc/default/useradd
- /etc/skel
๋ง์ฝ ๋ฌธ์ ์์ ์์ผ๋ก ์์ฑ๋๋ ๊ณ์ ๋ค์ MAX_DAYS๋ฅผ ๋ณ๊ฒฝํ๋ผ๊ณ ํ๋ฉด
grep MAX_DAYS /etc/login.defs
์์ ํ์ผ์ ๋ค์ด๊ฐ์ ๋ณ๊ฒฝํ๋ฉด ๋จ
๋ง์ฝ ํน์ ์ฌ์ฉ์์ MAX_DAYS๋ฅผ ๋ณ๊ฒฝํ๋ ๊ฑฐ๋ฉด
chage -M ๋ ์ง ์ฌ์ฉ์๋ช
์ ์ด์ฉํด์ ๋ณ๊ฒฝํ๋ฉด ๋๋ค. ํ์ธ์ chage -l ์ฌ์ฉ์๋ช
์ ํตํด ํ ์ ์๋ค.
๊ณ์ ์์ฑ ํ
- /etc/passwd
- /etc/shadow
- /etc/gshadow
- /etc/group
ํ์ ๋๋ ํ ๋ฆฌ /home/test_share ์์ฑ ํ ๊ทธ๋ฃน ์์ ๊ถ์ testgrp์๊ฒ ์ค ๊ฒ โ ์์ ๋ฌธ์ ๋ฅผ ํธ๋ ๊ณผ์ ์ค ์ค์ํ๋ฉด ์ด ๋ฌธ์ ๋ ํ ์ ์์
๋๋ ํ ๋ฆฌ๋ testgrp์ ๋ฉค๋ฒ์ ๋ํด ์ฝ๊ณ , ์ฐ๊ณ , ์ก์ธ์คํ ์ ์์ด์ผ ํ์ง๋ง ๋ค๋ฅธ ์ฌ์ฉ์์๋ํด์๋ ํด๋น๋์ง ์๋๋ค. (๋ฃจํธ๋ ์์คํ ์ ์๋ ๋ชจ๋ ํ์ผ ๋ฐ ๋๋ ํ ๋ฆฌ์ ๋ํ ์ก์ธ์ค ๊ถํ์ด ์๋ค)
/home/test_share์์ ๋ง๋ค์ด์ง ํ์ผ์๋ ์๋์ผ๋ก testgrp ๊ทธ๋ฃน์ ์ค์ ๋ ๊ทธ๋ฃน ์์ ๊ถ์ด ์์ด์ผ ํ๋ค
mkdir /home/test_share
chown :testgrp /home/test_share
# ๋๋
chgrp testgrp -R /home/test_share
chmod 2770 /home/tset_share # ์คํ ์ guid ๊ถํ์ set๋์ด ์คํ๋จ
์ ๊ทผ ๊ถํ์ ์ค์ ํ ๋ 777๊ณผ 0777์ ๋์ผํ ํํ์ด๋ค. ๋ค์๋ฆฌ๊ฐ ๋์ง์๋ ํํ์ ์์ 0์ด ์๋ต๋๋ค.
์ฒซ ๋ฒ์งธ ๋นํธ๋ ํน์ ๊ถํ์ ์ฌ์ฉ๋๋ ๋นํธ๋ก 4๋ setuid, 2๋ setgid, 1์ sticky bit์ ๋ํ๋ธ๋ค. setuid๊ฐ ๋ถ์ ํ๋ก๊ทธ๋จ์ ์คํ ์ ์์ ์์ ๊ถํ์ผ๋ก ์ ํ๋๋ฉฐ, setgid๊ฐ ๋ถ์ ํ๋ก๊ทธ๋จ์ ์คํ ์ ์์ ๊ทธ๋ฃน์ ๊ถํ์ผ๋ก ์ ํ๋๋ค. setuid์ setgid๊ฐ ํ์ํ ์ด์ ๋, ์ผ๋ฐ ์ฌ์ฉ์๊ฐ ๋ณ๊ฒฝํ ์ ์๋ ํ์ผ์ด์ง๋ง ๋ณ๊ฒฝ์ด ํ์ํ ๊ฒฝ์ฐ๊ฐ ์์ด์๋ค.
hihi ๊ณ์ ๊ถํ์ผ๋ก 10๋ถ ๊ฐ๊ฒฉ์ผ๋ก echo hi ๋ช ๋ น์ ์ฃผ๊ธฐ์ ์ผ๋ก ์คํํ๋ ค๋ฉด ์๋์ ๊ฐ์ด ํ๋ค.
vi /etc/crontab
*/10 * * * * hihi echo "hi"
# Local โ Remote
scp ๋ณด๋ผํ์ผ๊ฒฝ๋ก ์ ์ ๋ช
@ip-addr:๋ฐ์ํ์ผ๊ฒฝ๋ก
# Remote โ Local
scp ์ ์ ๋ช
@ip-addr:๋ณด๋ผํ์ผ๊ฒฝ๋ก ๋ฐ์ํ์ผ๊ฒฝ๋ก
# Remote โ Remote
scp ์ ์ ๋ช
@ip-addr:๋ณด๋ผํ์ผ๊ฒฝ๋ก ์ ์ ๋ช
@ip-addr:๋ฐ์ํ์ผ๊ฒฝ๋ก
ip-addr ๋ง๊ณ ๋๋ฉ์ธ์ผ๋ก ๋์ฌ ์ ์์
๋๋ฉ์ธ์ผ๋ก ๋์๋ ๋๊ฐ์ด ์งํํ๋ฉด ๋จ.
์๋ฅผ ๋ค์ด์ scp root@naver.com:/files/test.txt .
์ ๊ฐ์ ํํ๋ก scp๋ฅผ ์ฌ์ฉํ๋ฉด ๋๋ค.
/etc/passwd ํ์ผ์ /var/tmp/passwd๋ก ๋ณต์ฌ
์๋ ๊ถํ์ ์ ์ธ
ํ์ผ /var/tmp/passwd๋ root์ฌ์ฉ์๊ฐ ๋ณด์
ํ์ผ /var/tmp/passwd๋ ๊ทธ๋ฃน root์ ์ํจ
ํ์ผ /var/tmp/passwd ๋ ๋๊ตฌ๋ ์ง ์คํ ํ ์ ์์ด์๋ ์๋จ โ x
์ฌ์ฉ์ haha๋ /var/tmp/passwd๋ฅผ ์ฝ๊ณ ์ธ ์ ์์ โ rw
์ฌ์ฉ์ hihi๋ /var/tmp/passwd๋ฅผ ์ฝ๊ฑฐ๋ ์ธ ์ ์์
๋ค๋ฅธ ๋ชจ๋ ์ฌ์ฉ์๋ /var/tmp/passwd๋ฅผ ์ฝ์ ์ ์์ โ r
cp /etc/passwd /var/tmp/passwd
chown root /var/tmp/passwd
chgrp root /var/tmp/passwd
# ๋๋ ์์ ๋๊ฐ๋ฅผ ํ๋ฒ์
chown root:root /var/tmp/passwd
ls -l /var/tmp/passwd # ํด์ ํ์ธํ๊ณ
setfacl -m u:haha:rw /var/tmp/passwd
setfacl -m u:hihi:--- /var/tmp/passwd
setfacl -m o::r-- /var/tmp/passwd
# ํ์ธ
getfacl /var/tmp/passwd
ACL์ ๋ง์คํฌ๋ ACL์์ ์ง์ ๋ ์ฌ์ฉ์์ ๊ทธ๋ฃน์ด ์ฌ์ฉํ ์ ์๋ ์ต๋ ๊ถํ์ ์ง์ ํ๋ค. ์ง์ ๋ ์ฌ์ฉ์๋ ๊ทธ๋ฃน์ ๊ถํ์ด ๋ง์คํฌ์ ์ค์ ๋ ๊ถํ์ ๋ฒ์ด๋๊ฒ ๋๋ฉด ํํฐ๋ง ๋์ด effective๊ฐ ์ถ๋ ฅ๋๊ณ ํด๋น ๊ถํ์ด ์ค์ง์ ์ธ ๊ถํ์ผ๋ก ์ ์ฉ๋๋ค(AND ์ฐ์ฐ์). ๋ํ ํ์ผ์ ACL์ด ์ ์ฉ๋๋ฉด 'ls -l'๋ช ๋ น์์ ๊ถํ ํ๋ ์ค ์ฌ์ฉ์ ๊ทธ๋ฃน์ ๊ถํ์ ACL์ ๋ง์คํฌ ๊ถํ์ผ๋ก ํ์๋๋ค.
๊ธฐ๋ณธ ํํ: find / (option) -exec (command) {} ;
ํน์ ์์ ์ ๋ฐ๋ณตํด์ ํ๊ฑฐ๋, ๋ณต์กํ ์ต์ ์ ์ฌ์ฉํ๋ ๋ฌธ์ ๊ฐ ๋์ฌ ์ ์๋ค. '{}'๋ ๊ฒฐ๊ณผ๋ฌผ์ ๋ณ์์ฒ๋ผ ๋ฃ์ด์ ๋ฐ๋ณตํ๋ค.
(1) haha ๊ณ์ ์ด ์์ ํ ๋ชจ๋ ํ์ผ์ ์ฐพ์์ /tmp/results ๋๋ ํ ๋ฆฌ ์๋์ ์ฌ๋ณธ์ ๋ฐฐ์นํด์ฃผ์ธ์(***)
mkdir /tmp/results
find / -user haha -exec cp {} /tmp/results \;
(2) search_tset.sh ์คํฌ๋ฆฝํธ๋ฅผ PATH์ ๋ฑ๋ก๋ /usr/local/bin ์๋์ ๋ฐฐ์น ์ํค๊ณ ์คํ ํ๋๋ก ์ค๋นํด์ฃผ์ธ์
์คํฌ๋ฆฝํธ์ ๋ด์ฉ์ /usr ์๋์์ ํฌ๊ธฐ๊ฐ 15kb๋ณด๋ค ํฌ๊ณ 30kb๋ณด๋ค ์์ผ๋ฉด์ setuid ๊ถํ์ด ์๋ ๋ชจ๋ ํ์ผ์ ์ฐพ์์ /tmp/output ํ์ผ์ ์ ์ฅํด์ผ ํฉ๋๋ค
# vi /usr/local/bin/search_test.sh
#!/bin/bash
find /usr -size +15k -size -30k -perm -4000 > /tmp/output
# chmod +x ./search_test.sh
๋๋
# chmod 777 ./search_test.sh
- ํ์ฌ ๋๋ ํ ๋ฆฌ์ ์๋ ํ์ผ ๋ฐ ๋๋ ํ ๋ฆฌ ๋ฆฌ์คํธ ํ์
find
- ๋์ ๋๋ ํ ๋ฆฌ์ ์๋ ํ์ผ ๋ฐ ๋๋ ํ ๋ฆฌ ๋ฆฌ์คํธ ํ์
find [PATH]
- ํ์ฌ ๋๋ ํ ๋ฆฌ ์๋ ๋ชจ๋ ํ์ผ ๋ฐ ํ์ ๋๋ ํ ๋ฆฌ์์ ํ์ผ ๊ฒ์
find . -name [FILE]
- ์ ์ฒด ์์คํ
(๋ฃจํธ ๋๋ ํ ๋ฆฌ)์์ ํ์ผ ๊ฒ์
find / -name [FILE]
- ํ์ผ ์ด๋ฆ์ด ํน์ ๋ฌธ์์ด๋ก ์์ํ๋ ํ์ผ ๊ฒ์
fiind . name "STR*"
- ํ์ผ ์ด๋ฆ์ ํน์ ๋ฌธ์์ด์ด ํฌํจ๋ ํ์ผ ๊ฒ์
fiind . name "*STR*"
- ํ์ผ ์ด๋ฆ์ด ํน์ ๋ฌธ์์ด๋ก ๋๋๋ ํ์ผ ๊ฒ์
fiind . name "*STR"
- ๋น ๋๋ ํ ๋ฆฌ ๋๋ ํฌ๊ธฐ๊ฐ 0์ธ ํ์ผ ๊ฒ์
find . -empty
- ํน์ ํ์ฅ์๋ฅผ ๊ฐ์ง ๋ชจ๋ ํ์ผ ๊ฒ์ ํ ์ญ์
find . -name "*.EXT" -delete
- ๊ฒ์๋ ํ์ผ ๋ฆฌ์คํธ๋ฅผ ์ค ๋ฐ๊ฟ ์์ด ์ด์ด์ ์ถ๋ ฅํ๊ธฐ
find . -name [FILE] -print0
- ํ์ผ ๋๋ ๋๋ ํ ๋ฆฌ๋ง ๊ฒ์ํ๊ธฐ
find . -name [FILE] -type f
- ํ์ผ ํฌ๊ธฐ๋ฅผ ์ฌ์ฉํ์ฌ ํ์ผ ๊ฒ์
find . -size +[N]c -and -size -[M]c
+(์ด๊ณผ) ๋๋ -(๋ฏธ๋ง) ๊ธฐํธ๋ฅผ ์ฌ์ฉํ๋ค. ํ์ผ ํฌ๊ธฐ ๊ฐ ๋ค์ 'c'๋๋ 'k', 'M', 'G', ๋ฑ์ ๋ถ์ฌ์ ๋จ์๋ฅผ ์ง์ ํ ์ ์๋ค.
- ๊ฒ์๋ ํ์ผ์ ๋ํ ์์ธํ ์ ๋ณด ์ถ๋ ฅ(find+ls)
find . -name [FILE] -exec ls -l {} \;
-exec ํํ์์ find ๋ช ๋ น์ผ๋ก ๊ฒ์๋ ๊ฒฐ๊ณผ๋ฅผ ์ฌ์ฉํด ๋ค๋ฅธ ๋ช ๋ น์ ์คํํ ์ ์๊ฒ ํด์ค๋ค.
- ๊ฒ์๋ ํ์ผ์ ๋ผ์ธ ์ ์ถ๋ ฅ(find+wc)
find . -name [FILE] -exec wc-l {} \;
- ๊ฒ์๋ ํ์ผ์์ ๋ฌธ์์ด ์ฐพ๊ธฐ(find+grep)
find . -name [FILE] -exec grep "STR" {} \;
- ๊ฒ์ ๊ฒฐ๊ณผ๋ฅผ ํ์ผ๋ก ์ ์ฅ(find, redirection)
find . -name [FILE] > [SAVE_FILE]
- ๊ฒ์ ์ค ์๋ฌ ๋ฉ์์ง ์ถ๋ ฅํ์ง ์๊ธฐ(find, redirection)
find . -name [FILE] 2> /dev/null
- ํ์ ๋๋ ํ ๋ฆฌ ๊ฒ์ํ์ง ์๊ธฐ
find . -maxdepth 1 -name [FILE]
- ๊ฒ์๋ ํ์ผ ๋ณต์ฌ(find+cp)
find . -name [FILE] -exec cp {} [PATH] \;
gzip,bzip, tar ํ์ผ์ ์์ฑํ ๋๋ cvf, ํ์ผ์ ํ ๋๋ xvf๊ฐ ๋ค๊ฐ๋ค. gzip์ด๋ฉด z, bzip์ด๋ฉด j๋ฅผ ์ฌ์ฉํ๋ค.
tar๋ ์์นด์ด๋ธ ์ฉ๋๋ก ์ฌ์ฉํ๊ณ , gzip/bzip์ ์์ถ ์ฉ๋๋ก ์ฌ์ฉํ๋ค.
# ์์นด์ด๋ธ
tar cvf fruits.tar apple kiwi banana
# ํ์ผ ํํ ๋ณด๊ธฐ
file fruits.tar
# ์์นด์ด๋ธ๋ฅผ ํด์ ํ์ง ์๊ณ ๋ด๋ถ ํ์ผ๋ค์ ์ด๋ฆ ํ์ธํ๊ธฐ
tar tvf fruits.tar
# ์์นด์ด๋ธ ํด์
tar xvf fruits.tar
# ์์ถ
# gzip
gzip filename
gunzip filename
# bzip
bzip2 filename
bunzip2 filename
# ์์นด์ด๋ธ์ ์์ถ ๋์์ ํ๊ธฐ
# gzip
tar zcvf apple.tar.gz apple
tar zxvf apple.tar.gz
# bzip
tar jcvf apple.tar.bz2 apple
tar jxvf apple.tar.bz2
tar --help ๋ฅผ ํ๋ฉด ์์ ๋ช ๋ น์ด๋ฅผ ๋ค ํ์ธํ ์ ์๋ค. ์์นด์ด๋ธ๋ฅผ ์์ฑํ ๋๋ cvf, ํด์ ํ ๋๋ xvf๋ผ๋ ์ ๋ง ๊ธฐ์ตํด๋์.
๋ค์๊ณผ ๊ฐ์ด ์๊ฒฉ ์ฌ์ฉ์์ ํ ๋๋ ํ ๋ฆฌ๋ฅผ ์๋์ผ๋ก ๋ง์ดํธ ํ๋๋ก autofs ๋ฅผ ๊ตฌ์ฑํ์ธ์. ์์คํ ์ผ๋ก domain (10.0.2.100) nfs-export /netdir ๋ฅผ ์ ๊ณตํฉ๋๋ค. ์ด ํ์ผ ์์คํ ์๋ ์ฌ์ฉ์ remoteuserall ์ ๋ํด ๋ฏธ๋ฆฌ ๊ตฌ์ฑ๋ ํ ๋๋ ํ ๋ฆฌ๊ฐ ํฌํจ๋์ด ์์ต๋๋ค. remoteuserall ์ ํ ๋๋ ํ ๋ฆฌ๋ 10.0.2.100:/netdir/remoteuserall ์ ๋๋ค. ํ๋๋ ํ ๋ฆฌ๋ ์ฌ์ฉ์๊ฐ ์์ฑํ ์ ์์ด์ผ ํฉ๋๋ค. remoteuserall ์ฌ์ฉ์๋ ์ํธ๋ฅผ ์ฌ์ฉํฉ๋๋ค.
yum -y install autofs
rpm -qa | grep autofs
cat /etc/auto.master.d/exam.autofs
# /netdir /etc/auto.examc
cat /etc/auto.exam
# * -rw,sync 10.0.2.100:/netdir/&
systemctl start autofs
systemctl enable autofs
ssh remoteuserall@localhost
(ํํฐ์ ์ ๊ฑด๋๋ ๋ฌธ์ ๋ ์ฌ๋ถํ ํด๋ ๋ณ๊ฒฝ์ฌํญ์ด ์ ์ฉ๋์ด ์์ด์ผํ๋ฏ๋ก, ์ฌ๋ถํ ์ ํตํ ํ์ธ์ด ํ์ํ๋ค.)
500 MB์ ์ถ๊ฐ ์ค์ ํํฐ์ ์ ์์คํ ์ ์ถ๊ฐํฉ๋๋ค ์ค์ ํํฐ์ ์ ์์คํ ๋ถํ ์ ์๋์ผ๋ก ๋ง์ดํธ ๋์ด์ผ ํฉ๋๋ค ์์คํ ์์ ๊ธฐ์กด ์ค์ ํํฐ์ ์ ์ ๊ฑฐํ๊ฑฐ๋ ๋ณ๊ฒฝํ์ง ๋ง์ญ์์ค
# ๋์คํฌ ํ์ฌ ์ํ ํ์ธ
lsblk
fdisk -l /dev/sdb
์ํ์ฅ์์ ํํฐ์ ๋ช ์ sdb๊ฐ ์๋๋ผ vdb์ผ ์๋ ์๋ค. ์ด๋ฅผ ํ์ธํ๊ธฐ ์ํด lsvlk ๋ช ๋ น์ด๋ฅผ ์ฌ์ฉํด์ผ ํ๋ค.
[root@localhost ~]# fdisk /dev/sdb
Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p):
Using default response p.
Partition number (1-4, default 1):
First sector (2048-20971519, default 2048):
Last sector, +sectors or +size{K,M,G,T,P}
(2048-20971519, default 20971519): +500M
Created a new partition 1 of type 'Linux' and of size 500 MiB.
Command (m for help): p
Disk /dev/sdb: 10 GiB, 10737418240 bytes, 20971520 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: 0x516db603
Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 1026047 1024000 500M 83 Linux
Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): 82
Changed type of partition 'Empty' to 'Linux swap / Solaris'.
Command (m for help): p
Disk /dev/sdb: 10 GiB, 10737418240 bytes, 20971520 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: 0x516db603
Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 1026047 1024000 500M 82 Linux swap / Solaris
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: 10 GiB, 10737418240 bytes, 20971520 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: 0x516db603
Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 1026047 1024000 500M 82 Linux swap / Solaris
[root@localhost ~]# mkswap /dev/sdb1
Setting up swapspace version 1, size = 500 MiB (524283904 bytes)
no label, UUID=83085e90-593c-4945-b464-602006f93892
[root@localhost ~]# vim /etc/fstab
[root@localhost ~]# swapon /dev/sdb
swapon: /dev/sdb: read swap header failed
[root@localhost ~]# swapon /dev/sdb1
[root@localhost ~]# cat /etc/fstab
UUID=46399ec4-3bf7-48df-8097-438e3ef0ecc0 / xfs defaults 0 0
/dev/sdb1 swap swap defaults 0 0
์ค์ ํํฐ์ ์ ํ๋ ๊ณผ์ ์์ ์ค์๋ฅผ ํด ์ฌ๋ถํ ์ ์คํจํ๋ฉด ์ฑ๊ธ ๋ชจ๋์ ์ ๊ทผํด์ ์์ ํ๋ฉด ๋๋ค.
grup โ e โ re.break ์
๋ ฅ โ ctrl+x ์
๋ ฅ
root ๋น๋ฐ๋ฒํธ๋ฅผ ์ ๋ ฅํ ๋์ ๊ฐ์ ๊ณผ์ ์ ๊ฑฐ์น๋ฉด ์ฑ๊ธ ๋ชจ๋์ ์ ๊ทผ ํ ์ ์๋ค.
(1) ์ ํจํ์ง ์์ UUID ๊ฐ ๋๋ ์กด์ฌํ์ง ์์ ํํฐ์ ์ด๋ฆ์ ์ง์ ํ ๊ฒฝ์ฐ
/etc/fstab ํ์ผ์ ๋ด์ฉ์ ํ์ธํ๊ณ , blkid ๋ช ๋ น์ ์ฌ์ฉํด์ ํด๋น ๊ฐ์ ๋น๊ตํ๋ค. ์๋ชป๋ ๋ถ๋ถ์ ์์ ํ๊ณ ์์คํ ์ ์ฌ๋ถํ ํ๋ค.
(2) ์กด์ฌํ์ง ์๋ ๋ง์ดํธ ํฌ์ธํธ๋ฅผ ์ง์ ํ ๊ฒฝ์ฐ
/etc/fstab์ ๋ ๋ฒ์งธ ํ๋๋ ๋ง์ดํธ ํฌ์ธํธ์ ๊ฒฝ๋ก๋ฅผ ์ง์ ํ๋ค. ํด๋น ํ๋์ ์กด์ฌํ์ง ์๋ ๋ง์ดํธ ํฌ์ธํธ๋ฅผ ์ง์ ํ๋ฉด ์์คํ ์ด ๋ถํ ๋๋ฉด์ ๋ง์ดํธ ํฌ์ธํธ๋ฅผ ์๋์ผ๋ก ์์ฑํ๋ค. ๋ฐ๋ผ์ ๋ถํ ์ด ์ ์์ ์ผ๋ก ์๋ฃ๋๋ค.
(3) ํ์ผ์์คํ ์ ํ์ด ์ผ์นํ์ง ์๋ ๊ฒฝ์ฐ
/etc/fstab์ ์ธ ๋ฒ์งธ ํ๋๋ ํ์ผ์์คํ ์ ์ ํ์ ์ง์ ํ๋ค. ํํฐ์ ์ ์์ฑํ ํ์ผ์์คํ ์ ์ ํ๊ณผ ํด๋น ํ๋์ ์ง์ ํ ํ์ผ์์คํ ํ์์ด ์ผ์นํ์ง ์์ผ๋ฉด ๋ถํ ์ ๋ณต๊ตฌ ์๋ก ์ง์ ํ๋ค.
/etc/fstab ํ์ผ์ ๋ด์ฉ์ ํ์ธํ๊ณ , blkid ๋ช ๋ น์ ์ฌ์ฉํด์ ํด๋น ๊ฐ์ ๋น๊ตํ๋ค. ์๋ชป๋ ๋ถ๋ถ์ ์์ ํ๊ณ ์์คํ ์ ์ฌ๋ถํ ํ๋ค.
(4) ์๋ชป๋ ๋ง์ดํธ ์ต์
/etc/fstab ํ์ผ์ ๋ด์ฉ์ ํ์ธํ๊ณ ์๋ชป๋ ๋ถ๋ถ์ ์์ ํ๋ค.
๋ค์ ์๊ตฌ ์ฌํญ์ ๋ฐ๋ผ ์ ๋ ผ๋ฆฌ ๋ณผ๋ฅจ์ ๋ง๋ญ๋๋ค.
development ๋ณผ๋ฅจ ๊ทธ๋ฃน์ ๋ ผ๋ฆฌ ๋ณผ๋ฅจ์๋ 32MB์ ํ์ฅ ์์ญ ํฌ๊ธฐ๊ฐ ์์ด์ผ ํ๋ค
๋ ผ๋ฆฌ ๋ณผ๋ฅจ์ ์ด๋ฆ engineering , development ๋ณผ๋ฅจ ๊ทธ๋ฃน์ ์ํด์๊ณ 20 ํ์ฅ ์์ญ์ ํฌ๊ธฐ๊ฐ ์๋ค
ext3 ํ์ผ ์์คํ ์ผ๋ก ์ ๋ ผ๋ฆฌ ๋ณผ๋ฅจ์ ํฌ๋งท
๋ ผ๋ฆฌ ๋ณผ๋ฅจ์ ์์คํ ๋ถํ ์๊ฐ์ /mnt/engineering ์์ ์๋์ผ๋ก ๋ง์ดํธ ๋์ด์ผ ํ๋ค
fdisk /dev/sdb
> n
> t(8e)
fdisk -l /dev/sdb
partprobe /dev/sdb
pvcreate /dev/sdb3 <- ์๋ต ๊ฐ๋ฅ
vgcreate development /dev/sdb3 -s 32M
lvcreate -n engineering -l 20 development
mkfs.ext3 /dev/development/engineering
vi /etc/fstab
/dev/development/engineering /mnt/engineering ext3 defaults 0 0
partprobe
yum -y install kmod-kvdo.x86_64 vdo.x86_64
vdo create --vdoLogicalSize 50G -n vdough --device /dev/sdc
# ์ฉ๋์ด ๋ถ์กฑํด๋ logical size๋ผ ๋ฌผ๋ฆฌ ์ฉ๋์ด๋ ๊ด๊ณ์์ด์ ๊ด์ฐฎ๋ค.
mkfs.xfs -K /dev/mapper/vdough
vi /etc/fstab
#/dev/mapper/vdough <mount-point>
/dev/mapper/vdough /vtestdir xfs defaults,x-systemd.requires=vdo.service 0 0
# x- ๋น ์ง๋จ ๋ถํ
์ด ์๋๋ ์กฐ์ฌํด์ผํ๋ค.
# ์ฌ๋ถํ
ํ ์๋ ๋ช
๋ น์ด๋ก ํ์ธํ๊ธฐ
df -hTP
VDO ์ฉ๋๋ก ์ฌ์ฉํ ๊ณต๊ฐ์ด ์์ผ๋ฉด, ๋์คํฌ ์ ์ฒด๋ฅผ ์ญ์ ํ๊ณ ์๋ก ๋ฌธ์ ๋ฅผ ํ์ด์ผ ํ๋ค. ๋ฐ๋ผ์ LVM์ ๋ฌด์กฐ๊ฑด ๊ฐ์ ํํฐ์ ๋ด์์ ๋๋ด์ผ ํ๋ค.
VDO๋ ๋ณดํต ์ปจํ ์ด๋์์ ๋ง์ด ์ฌ์ฉํ๋ค.
ํธ๋ฌ๋ธ ์ํ ํ ๋ fstab ๋ด์ฉ ์ค x-systemd.requires ๋ถ๋ถ์ ์๋ชป ํ์์ ๊ฒฝ์ฐ ๋ถํ ์ด ๋๋ ์๋กญ๊ฒ ๋ฑ๋ก๋์ง ์๋๋ค.
vdo stop -n vdough
vdo remove -n vdough
์์ ๋ช ๋ น์ด๋ฅผ ์ ๋ ฅํ๊ณ vdo create ๋ถํฐ ๋ค์ ํ๋ฉด ๋๋ค.
# ์ฌ์ฉ์ ๋ฑ๋ก
testuser1 ALL=(ALL) ALL
# ๊ทธ๋ฃน ๋ฑ๋ก
%sudogrp ALL=(ALL) ALL
# ์ด ๋ ๋ฑ๋ก ํ ์ฌ์ฉ์๋ usermod useradd
# ์กด์ฌํ๋ ๊ณ์ ์ ๊ทธ๋ฃน์ ๋ฑ๋กํ๋ ๋ฌธ์
usermod -G sudogrp testuser1
# ์กด์ฌํ์ง ์๋ ๊ณ์ ์ ์๋กญ๊ฒ ์์ฑํ๋ฉด์ ๋ณด์กฐ ๊ทธ๋ฃน์ผ๋ก ๋ฑ๋กํ๋ ๋ฌธ์
useradd -G sudogrp testuser1
๋ ผ๋ฆฌ ๋ณผ๋ฅจ vol1 ํ์ผ ์์คํ ์ ํฌ๊ธฐ๋ฅผ 500MB๋ก ์กฐ์ ํ๊ธฐ
lvextend -L 500M /dev/testvol/vol1 -r
์๋ฒ์ฃผ์,dn name,TLS์ฌ์ฉ์ ๋ฌด,์ธ์ฆ ๋ฐฉ์,์ธ์ฆ์ ์ฃผ์ ๋ชจ๋ ์ ์ํ์ฌ ์ฃผ๋ฉฐ ์ํ๋ณด๋ PC ์์ ssh -X ๋ช ๋ น์ด๋ฅผ ์ด์ฉํ์ฌ vm์ ์ ์,
์ดํ yum install authconfig-gtk ๋ก gui authconfig ๋๊ตฌ ์ค์น,
authconfig-gtk ๋ช ๋ น์ด๋ก gui ์ธํฐํ์ด์ค๋ก ์ธ์ฆ์ ์ํํ๋ฉด ๋๋ฉฐ ๋จ์ํ ์ ์๋ ๊ฐ์ ๋ฃ๋ ์์ค, ์ดํ apply ๋จ kerberos ์ธ์ฆ์ ๊ฒฝ์ฐ krb ํจํค์ง ์ค์นํด์ผํจ, gui ์งํ์ ์ค์นํ๋ผ๋ ์ฐฝ์ด ๋์ค๊ณ ํด๋ฆญ๋งํ๋ฉด ์๋์ผ๋ก ์ค์น๋จ
getent passwd {user} ๋ฃ์ด ์ ๋๋ ํ์ธ
์ดํ ์ ์ํ user,passwd ์ด์ฉํ์ฌ ssh ์ ์ ํ ์คํธ ์งํ
groupvg๋ฅผ ๋ง๋ค๊ณ sharelv๋ฅผ ๋ง๋ค์ด /mnt/share ์ ์๊ตฌ ๋ง์ดํธ ํ์์ค ๋จ vg pe์ฌ์ด์ฆ๋ 8mb ์ฌ์ผํ๋ฉฐ sharelv์ ํฌ๊ธฐ๋ 100๊ฐ์ pe์ฌ์ผ ํฉ๋๋ค ๋ํ vfatํฌ๋งบ์ด์ด์ผ ํฉ๋๋ค
ํํฐ์ ๊ด๋ จ๋ ๋ด์ฉ์ ์์์ผ๋ fdisk -l ํด๋ณด๋ ์ด๋ฏธ 3๊ฐ์ ํํฐ์ ์ด ์์์,๋์คํฌ๋ ๋ก์ปฌ ํ๊ฐ
์ฐจํ์ ๋ค๋ฅธ ๋ฌธ์ ๊ฐ ๋์ฌ์๋ ์์ผ๋ ํ์ฅํํฐ์ ์ผ๋ก ๋ง๋ฌ(์ฐจํ์ swap๊ด๋ จ ๋ฌธ์ ๊ฐ ๋๋์์ ํ์ฅ์ผ๋ก ์๋ง๋ค์์ ๊ฐ์ ์์์ด์ผํจ)
ํ์ฅ ํํฐ์ ๋ง๋ ํ ๋๋์ก์ 1G ํํฐ์ ํ๋ ์์ฑ. lvm code(8e) ์ฌ์ฉ์ค์ธ ๋์คํฌ์ด๋ฏ๋ก ํํฐ์ ์์ ํ partprobe ํ์
#pvcreate /dev/vda5
๋ก ํด๋น ํํฐ์ ์ pv์์ฑ
#vgcreate -s 8 groupvg /dev/vda5
๋ก pe์ฌ์ด์ฆ 8,pvํ๋์ฐ๋ vg์์ฑ (-s ์ต์ ์ด pe์ฌ์ด์ฆ ์ง์ ํด์ค)
#lvcreate -n sharelv -l 100 groupvg
์์ ๋ช ๋ น์ด -n์ lv์ด๋ฆ ์ง์ -l ์ ์ฌ์ด์ฆ๋ฅผ pe๊ฐฏ์๋ก ์ง์ ํ ๋ ์ฌ์ฉ
๋ง๋ค์ด์ง lv๋ mapper๋ฅผ ํตํด ์๋ mapped๋๋ fdisk -l ๋ก ๊ฒฝ๋ก ํ์ธ, ๋ณดํต์ /dev/mapper/{vgname}-{lvname} ์ผ๋ก ๋จ
๋ง๋ค์ด์ง lv๋ฅผ vfat ํฌ๋งท ํ๊ธฐ
#mkfs.vfat /dev/mapper/groupvg-sharelv
xfs๋ ext4์ ๊ฒฝ์ฐ mkfs.๋ค์ ์์ ํ๋ฉด ๋จ ํฌ๋งท ํ fstab ์์
blkid์จ์ ๋์ค๋ UUID๋ก ํด๋ ๋๊ณ mapper์จ๋ ๋๊ณ ..
์ฅ์น๋ช ์ผ๋ก fstab ๋ฑ๋ก์ ๊ฐ์ ์ด ์๋ค๊ณ ํจ(๊ฐ์ฌํผ์ ) ๊ทธ๋ฌ๋ lvm์ ๊ฒฝ์ฐ ์ฅ์น๋ช ์ด ์๋๋ฏ๋ก(์ฅ์น๋ช ex:sda sdb ๋ฑ) ๋ณ๊ฒฝ๋ ๊ฐ๋ฅ์ฑ์ด ์์. ๊ทธ๋์ /dev๊ฒฝ๋ก๋ฅผ ์ง์ ํด์ฃผ์ด๋ ๊ฐ์ ์์์
๋ณธ์ธ์ mapper ๋ช ์ผ๋ก ์ป์
mkdir /mnt/share
vi /etc/fstab
/dev/mapper/groupvg-sharelv /mnt/share vfat default 0 2
๊ฐ ๋ฃ์ ํ mount -a ์ํํ์ฌ ์๋ฌ ์ฌ๋ถ ๋ฐ df -h ๋ก ๋ง์ดํธ ๋๊ฒ ํ์ธ
ํด๋๋ /share/test ์ด๋ฉฐ manager ๊ทธ๋ฃน์ ์ํ harry, sara ์ ์ ๊ฐ ์ฝ๊ณ ์ฐ๊ธฐ(์คํ๋)๊ฐ ๊ฐ๋ฅํด์ผ ํฉ๋๋ค
๋ค๋ฅธ ๋ชจ๋ ์ ์ ๋ ์๋ฌด๋ฐ ๊ถํ๋ ์์ด์ผ ํ๋ฉฐ root๋ ์์ธ์ ๋๋ค
๋ํ uid 642๋ฅผ ๊ฐ์ง harry2 ๊ณ์ ๋ manager๊ทธ๋ฃน์ ์ํด์ผ ํฉ๋๋ค
๋ํ ์ดํด๋์์ ์์ฑ๋๋ ํ์ผ์ ์์ ์ ๋ํ manager์ฌ์ผ๋ง ํฉ๋๋ค
#mkdir -p /share/test (ํด๋์์ฑ)
#chgrp manager /share/test (testํด๋์ ๊ทธ๋ฃน์์ ์ ๋ณ๊ฒฝ)
#chmod 070 /share/test ๊ทธ๋ฃน์ rwx๊ถํ ์ฃผ๊ณ ๋๋จธ์ง๋ ๋ป
#chmod g+s /share/test setgid ์ค์ (์ด๊ฑธ ํด๋์ผ๋ฉด root๊ฐ ํ์ผ์ ๋ง๋ค์ด๋ ํด๋น ํด๋๋ด์์๋ ์์ ๊ทธ๋ฃน์ด manager๋ก ์์ฑ๋จ)
#useradd -u 642 -G manager harry2 ์์ ์ ์ํ ์ ๋ณด๋ก ๊ณ์ ์์ฑ
/etc/fstab ํ์ผ์ /var/tmp/fstab ์ผ๋ก ๋ณต์ฌ ํํ ๊ถํ ์ค์ ์ ํ์์ค
harry ์ ์ ์ sarah ์ ์ ๋ ํด๋น ํ์ผ์ ์ฝ๊ณ ์ธ์ ์๊ณ sara ์ ์ ๋ ์๋ฌด๋ฐ ๊ถํ๋ ์์ด์ผ ํฉ๋๋ค ํ์ฌ ๋๋ ๋ฏธ๋์ ๋ชจ๋ ์ ์ ๋ค์ ์ฝ๊ธฐ ๊ถํ์ด ์์ด์ผํฉ๋๋ค
๋ณด๋ฉด chmod ํ๋๋ก ์ค์ ์ด ์๋๋๊ฑฐ๊ณ acl์จ์ผํฉ๋๋ค
#setfacl -m u:harry:rw- /var/tmp/fstab
#setfacl -m u:sarah:rw- /var/tmp/fstab
#setfacl -m u:sara:--- /var/tmp/fstab
#setfacl -m o::r-- OR #chmod o:r-- /var/tmp/fstab
์ต์ข getfacl /var/tmp/fstab ์ผ๋ก ํ์ธ
harry ์ ์ ๊ฐ ๋งค์ผ 14์23๋ถ์ ์ํํ๋ echo test ๋ฐ๋ณต์์ ์ ๋ฑ๋กํ์์ค
crontab -eu harry
23 14 * * * /usr/bin/echo test
server.example.com ์ผ๋ก ์๊ฐ์ ๋๊ธฐํํ๋ ํด๋ผ์ด์ธํธ ์ค์ ์ ํ์์ค
chrony ์๊น๋ ค ์์ผ๋ฉด ์ค์น ํ์๋ฉด ๋๊ณ ๊น๋ ค์์ผ๋ฉด
/etc/chrony.conf ์ด์ด์ ์๋ฒ ์์ ํ๋ฉด ๋ฉ๋๋ค
pool server.example.com iburst
ํ์ธ์ chronyc ์คํํ๊ณ sources -v ๋ก ํ์ธ
test์ ์ ๊ฐ ์์ ํ ํ์ผ์ ์ฐพ์์ /root/find ํด๋๋ก ๋ณต์ฌํ์์ค
#mkdir /root/find ํด๋ ์์ฑ
#find / -user test -type f -exec cp -rp {} /root/find/ \;
/sys/xxx ํ์ผ์ strat ๊ฐ ํฌํจ๋ ๋ผ์ธ์ /root/strat.txt ํ์ผ๋ก ์์ฑํ์์ค
๋จ ์๋ณธ ํ์ผ์ด ์์๋์ด์๋ ์๋๋ฉฐ strat.txt ํ์ผ์ ๋น์นธ์ด ์์ด์ ์๋๊ณ ๋ชจ๋ ์ค์ ์๋ณธํ์ผ ๋ด์ฉ์ ๋ณต์ฌ๋ณธ์ด์ฌ์ผ ํฉ๋๋ค
grep strat /sys/xxx > /root/strat.txt
ํด๋น ์ ์ฅ์์์ ์ปค๋์ ์ฐพ์ ์ ๋ฐ์ดํธ ํ์์ค (์ฃผ์๋ ์ ์ํด์ค)
์ ๋ฐ์ดํธํ ์ปค๋๋ก ๊ธฐ๋ณธ ๋ถํ ์ด ๋์ด์ผํ๊ณ ๊ธฐ์กด ์ปค๋๋ ์ญ์ ํด์๋ ์๋ฉ๋๋ค
์ฌ๋ฌ๊ฐ์ง ๋ฐฉ๋ฒ์ด ์์ต๋๋ค
์ ๋ wget {url}๋ก ์ปค๋์ ๋ฐ์ ํ
yum localinstall {๋ฐ์ํ์ผ์ด๋ฆ}.rpm ์ผ๋ก ์ค์น ํ์ต๋๋ค
์ดํ systemctl๋ก ๋ฆฌ๋ถํ๋ฉด ์๋ก์ด ์ปค๋์ด 1๋ฒ ๊ณผ๊ฑฐ์ปค๋์ด 2๋ฒ grub๋ฉ๋ด ์๋ ์์ ๋์ด ์์ต๋๋ค
๋ถํ ํ yum list kernel๋ก 2๊ฐ ๋ชจ๋ ์กด์ฌํ๋์ง ํ์ธ
selinux ๋ชจ๋๋ฅผ enforcing์ผ๋ก ๋ณ๊ฒฝํ์์ค
๊ธฐ๋ณธ๋ชจ๋๋ permissive ์์ต๋๋ค
/etc/selinux/config ํ์ผ์ ์ด์ด SELINUX=permissive ๋ฅผ SELINUX=enforcing ์ผ๋ก ์์ (์คํ์กฐ์ฌ,์คํ๋ด๋ฉด ์ ์๋ถํ ์๋จ)
์ดํ ์ฌ๋ถํ ํ์ ๋ ๋๊ณ setenforce=1 ๋ก enforcing ๋ชจ๋๋ก ๋ฐ๊พธ์ ๋ ๋ฉ๋๋ค ํ ์คํธ ํ์๋ ค๋ฉด ์ฌ๋ถํ ์ถ์ฒ
๋ฒ์์ ์ค์ ํ ldap (test6์ด๋ผ ๊ฐ์ )์ ์ ๋ก ๋ก๊ทธ์ธ์ homeํด๋๋ฅผ ์๋์ผ๋ก ๋ง์ดํธ ํ๊ฒ ํ์์ค
nfs๊ณต์ ์ค์ธ ์๋ฒ์ ํด๋๋ server6:/usr/test6 ์ด๋ฉฐ /mnt/test6์ผ๋ก ์๋๋ง์ดํธ ๋์ผํฉ๋๋ค
#yum install -y autofs nfs-utils ์ค์น ( ์ ์ ๊ฒฝ์ฐ์ ๋๋ค ๊น๋ ค์์์)
/etc/auto.master.d/xxx.autofs ํ์ผ ์์ฑ, ํ์ฅ์๋ ๊ผญ autofs์ฌ์ผํจ
์ง์ ๊ฒฝ๋ก ์ง์ ์ ์ํด ํ์ผ๋ด์ฉ ์ถ๊ฐ
/- /etc/nfs.auto
/- ์ง์ ๊ฒฝ๋ก
/xxx/xxx ๊ฐ์ ๊ฒฝ๋ก
/etc/nfs.autoํ์ผ์ ์ด์ด ์ค์ ๋ง์ดํธ ์ต์
๋ฑ์ ์ค์
/mnt/test6 -rw,sync server6:/usr/test6
๋ง์ฝ ์ฌ๋ฌ๊ฐ๋ฅผ ์ค์ ํด์ผ๋๋ค๋ฉด(ex test1~10๊น์ง ๋ชจ๋)
autofs์ ์๋๊ฒฝ๋ก๋ฅผ ์ง์ /- = /mnt/
nfs.autoํ์ผ์
* -rw,sync server6:/usr/&
ํด์ฃผ์๋ฉด ๋ฉ๋๋ค
์ดํ systemctl start autofs
systemctl start nfs-secure
systemctl enable autofs
systemctl enable nfs-secure
autofs ๋ nfs-secure์คํํ์๊ณ ์๋์คํ๋๊ฒ enable๋ํ์ธ์ ์๊ทธ๋ผ ์ฌ๋ถํ
ํ๋ฉด ์๋์ํจ~~
df -ah ๋ก autofs ์ค์ ์ฌ๋ผ์ ์๋๊ฒ ํ์ธ.
์ดํ su - test6 ํด์ ํํด๋ ์ ๋ณด์ด๋ ํ์ธ
์ฌ๋ถํ ํด์ ํ๋ฒ๋ ํ์ธ!
(1) centos8-python37 ๋ผ๋ ์ด๋ฏธ์ง๋ฅผ ์ฌ์ฉํ์ฌ ์ด๋ฆ์ด logserver์ธ ์ปจํ ์ด๋ ์์ฑ
๊ธฐ์กด ์ฌ์ฉ์ testA ๋ํด์๋ง ์คํํ๊ณ systemd์๋น์ค ๋ก ๋ฑ๋กํด์ ๊ตฌ์ฑ
์๋น์ค๋ container-logserver๋ก ์ด๋ฆ์ด ์ง์ ๋์ด์ผ ํ๋ฉฐ (์ด๋ถ๋ถ์ ์๋ ๋ช
๋ น์ ์ค์ ์์ด ์ ์ฉํ๋ฉด ์๋์ผ๋ก ์์ฑ๋ฉ๋๋ค. ) ์๋ ์กฐ์์์ด
์ฌ๋ถํ
ํ ์๋์ผ๋ก ์์๋์ด์ผ ํฉ๋๋ค.
[root@localhost ~]# ssh testA@localhost
testA@localhost's password:
Activate the web console with: systemctl enable --now cockpit.socket
Last login: Wed May 26 20:54:11 2021 from ::1
[testA@localhost ~]$ podman login
Username: testA
Password:
Login Succeeded!
[testA@localhost ~]$ podman search centos8
[testA@localhost ~]$ podman image pull docker.io/loging/centos8-python37
[testA@localhost ~]$ podman container run -d --name logserver docker.io/loging/centos8-python37
์ฌ๊ธฐ์ ๋ถํฐ๊ฐ ์ค์
[testA@localhost ~]$ mkdir -p ~/.config/systemd/user
[testA@localhost ~]$ cd ~/.config/systemd/user/
[testA@localhost user]$ podman generate systemd --name logserver --files --new
/home/testA/.config/systemd/user/container-logserver.service
[testA@localhost user]$ ls
container-logserver.service
[testA@localhost user]$ loginctl enable-linger โ-- systemctl --user ๋ช
๋ น์ ์ฌ์ฉ์ํ๊ฒฝ์ ์ฌ์ฉํ๊ฒ๋ ํ๊ธฐ ์ํ
[testA@localhost user]$ systemctl --user enable container-logserver.service
Created symlink /home/testA/.config/systemd/user/multi-user.target.wants/container-logserver.service โ /home/testA/.config/systemd/user/container-logserver.service.
Created symlink /home/testA/.config/systemd/user/default.target.wants/container-logserver.service โ /home/testA/.config/systemd/user/container-logserver.service.
[testA@localhost user]$ podman rm -f logserver
(2) ์ปจํ ์ด๋์ ์๊ตฌ ์ ์ฅ ์ฅ์น ๊ตฌ์ฑ
์ด๋ฆ์ด container_journal ์ธ ์ปจํ ์ด๋ ํธ์คํธ์ ๋๋ ํ ๋ฆฌ๋ฅผ /home/testA ์๋์ ๋ง๋ญ๋๋ค. ์ปจํ ์ด๋ ์๋น์ค๋ ์ปจํ ์ด๋์ /var/log/journal ์๋์ ์๋ ํธ์คํธ ๋๋ ํ ๋ฆฌ /home/testA/container_journal ์ ๋ง์ดํธ ํด์ผ ํฉ๋๋ค. ์๊ตฌ ์ ์ฅ์ฅ์น๋ ์ปจํ ์ด๋ ์๋น์ค๊ฐ ์์๋ ๋ ๋ง๋ค ์๋์ผ๋ก ๋ง์ดํธ ๋์ด์ผ ํฉ๋๋ค.
/home/testA/container_journal --- > container /var/log/journal
$ mkdir /home/testA/container_journal
$ podman run -d --name logserver -v /home/testA/container_journal:/var/log/journal:Z docker.io/loging/centos8-python37
$ cd ~/.config/systemd/user
$ podman generate systemd --name logserver --files --new
$ exit
(3) ๋ ๋ฌธ์ ๋ฅผ ํ๋ฒ์ ํด๊ฒฐํ๋ ๋ฐฉ๋ฒ
[root@localhost ~]# ssh testA@localhost
[testA@localhost ~]$ podman login
[testA@localhost ~]$ podman search centos8
[testA@localhost ~]$ podman image pull docker.io/loging/centos8-python37
[testA@localhost ~]$ mkdir /home/testA/container_journal
[testA@localhost ~]$ podman run -d --name logserver -v /home/testA/container_journal:/var/log/journal:Z docker.io/loging/centos8-python37
[testA@localhost ~]$ mkdir -p ~/.config/systemd/user
[testA@localhost ~]$ cd ~/.config/systemd/user/
[testA@localhost user]$ podman generate systemd --name logserver --files --new
/home/testA/.config/systemd/user/container-logserver.service
[testA@localhost user]$ loginctl enable-linger โ-- systemctl --user ๋ช
๋ น์ ์ฌ์ฉ์ํ๊ฒฝ์ ์ฌ์ฉํ๊ฒ๋ ํ๊ธฐ ์ํ
[testA@localhost user]$ systemctl --user enable container-logserver.service
[testA@localhost user]$ podman rm -f logserver
์ํ์์๋ ํ์ฑํ ์ํค๋ ๊ฒ์ ์๊ตฌํ๋๊ฒ ์๋. ์ผ๋จ ์์ฑํ๋ ๊ฒ์ ์์ฒญํด์ ์ฌ๊ธฐ๊น์ง๋ง ํ๋๊ฑฐ์. ์ฐ๋ฆฌ๊ฐ ๋ช ์๋ฅผ ํด์ ํ์ผ์ ๋ง๋ค์๋์ง๋ฅผ ์ฒดํฌํ๋๊ฑฐ๋๊น ์ฌ๊ธฐ๊น์ง๋ง ํ๋ฉด ๋จ (์ฌ๋ถํ ์์๋ ๋์ํด์ผ ํ๋๊ฑด ๋ณผ๋ฅจ ๊ทธ๋ฃน ๋ฑ ํํฐ์ ๊น์ง์)
tuned-adm profile โ ์ํ์ด๋์ ๊ด๊ณ์์ด ์ฌ์ฉํ ์ ์๋ ํ๋กํ์ผ ๋ชฉ๋ก
tuned-adm recommend
# ์ฌ์ฉ ๊ฐ๋ฅํ ํ๋กํ์ผ ์ค ํ๋๋ก ๋ณ๊ฒฝํ๋ ค๋ฉด, ๋ค์์ ์คํํฉ๋๋ค:
tuned-adm profile virtual-guest
# ํ์ฌ ํ์ฑํ๋ ํ๋กํ์ผ๋ง ํ์ํ๊ณ ์ถ๋ค๋ฉด, ๋ค์๊ณผ ๊ฐ์ด ํฉ๋๋ค:
tuned-adm active