root / redhat
<터미널 1>
touch f1
echo Hello1 >> f1
echo Hello2 >> f1
<터미널 2>
tail f1
tail -f f1
touch file-$(date +%H-%M).txt
* $ -> 값 / 끝
/etc/ : 환경설정 파일
^ -> 그 라인의 시작
f
systemctl set-default multi-user.target
reboot
systemctl set-default graphical.target
reboot
vim 사용 : 기존 파일 편집
redirection 기능 : > (덮어쓰기), >> (추가)
pipe : ps | --> ps
user 관리
useradd : -U, -G,
passwd
home directiory : -d, -m(move)
usermod : -s /sbin/nologin
su 명령 : 사용자 전환
group 관리
groupadd(보조 그룹 생성)
gpasswd -a, -d, -M, ....
sudo, wheel, /etc/sudoers
소유자(관리권한)
chmod
u, g, o ==> a(all
+, -, =
r(4), 2(2), x(1) none(0)
chown, chgrp
[root@linux1 ~]# cat -n /etc/passwd | tail
40 gdm:x:42:42::/var/lib/gdm:/sbin/nologin
41 rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin
42 gnome-initial-setup:x:977:975::/run/gnome-initial-setup/:/sbin/nologin
43 sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
44 avahi:x:70:70:Avahi mDNS/DNS-SD Stack:/var/run/avahi-daemon:/sbin/nologin
45 rngd:x:976:974:Random Number Generator Daemon:/var/lib/rngd:/sbin/nologin
46 tcpdump:x:72:72::/:/sbin/nologin
47 student:x:1000:1000:student:/home/student:/bin/bash
48 user1:x:1001:1001::/home/user1:/bin/bash
49 user2:x:1002:1002::/home/user2:/bin/bash
[root@linux1 ~]#
[root@linux1 ~]# cat -n /etc/passwd | tail
40 gdm:x:42:42::/var/lib/gdm:/sbin/nologin
41 rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin
42 gnome-initial-setup:x:977:975::/run/gnome-initial-setup/:/sbin/nologin
43 sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
44 avahi:x:70:70:Avahi mDNS/DNS-SD Stack:/var/run/avahi-daemon:/sbin/nologin
45 rngd:x:976:974:Random Number Generator Daemon:/var/lib/rngd:/sbin/nologin
46 tcpdump:x:72:72::/:/sbin/nologin
47 student:x:1000:1000:student:/home/student:/bin/bash
48 user1:x:1001:1001::/home/user1:/bin/bash
49 user2:x:1002:1002::/home/user2:/bin/bash
[root@linux1 ~]# userdel -r user2
[root@linux1 ~]# cat -n /etc/passwd | tail
39 colord:x:978:976:User for colord:/var/lib/colord:/sbin/nologin
40 gdm:x:42:42::/var/lib/gdm:/sbin/nologin
41 rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin
42 gnome-initial-setup:x:977:975::/run/gnome-initial-setup/:/sbin/nologin
43 sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
44 avahi:x:70:70:Avahi mDNS/DNS-SD Stack:/var/run/avahi-daemon:/sbin/nologin
45 rngd:x:976:974:Random Number Generator Daemon:/var/lib/rngd:/sbin/nologin
46 tcpdump:x:72:72::/:/sbin/nologin
47 student:x:1000:1000:student:/home/student:/bin/bash
48 user1:x:1001:1001::/home/user1:/bin/bash
[root@linux1 ~]#
[root@linux1 ~]# mkdir -pv /test
mkdir: created directory '/test'
[root@linux1 ~]# ll
합계 36
-rw-r--r--. 1 root root 24 8월 22 18:13 abc.txt
-rw-------. 1 root root 1386 8월 22 15:24 anaconda-ks.cfg
-rw-r--r--. 1 root root 65 8월 22 17:44 err1.txt
-rw-r--r--. 1 root root 20 8월 22 15:53 f1
-rw-r--r--. 1 root root 0 8월 22 16:16 file-16-16.txt
-rw-r--r--. 1 root root 0 8월 22 16:18 file-16-18.txt
-rw-r--r--. 1 root root 13 8월 31 11:09 file1
-rw-r--r--. 1 root root 32 8월 31 11:09 file2
-rw-r--r--. 1 root root 1496 8월 22 15:27 initial-setup-ks.cfg
drwxr-xr-x. 3 root root 17 9월 6 16:39 linux_ex
-rw-r--r--. 1 root root 777 8월 22 17:43 list0.txt
drwxr-xr-x. 3 root root 17 9월 6 16:08 temp
-rw-r--r--. 1 root root 43 8월 22 17:50 test1.txt
drwxr-xr-x. 2 root root 6 9월 6 16:04 tmp1
drwxr-xr-x. 2 root root 6 9월 6 16:04 tmp2
drwxr-xr-x. 2 root root 6 9월 5 13:16 user1
drwxr-xr-x. 2 root root 6 8월 22 15:28 공개
drwxr-xr-x. 2 root root 6 8월 22 15:28 다운로드
drwxr-xr-x. 2 root root 6 8월 22 15:28 문서
drwxr-xr-x. 2 root root 6 8월 22 15:28 바탕화면
drwxr-xr-x. 2 root root 6 8월 22 15:28 비디오
drwxr-xr-x. 2 root root 141 8월 31 11:54 사진
drwxr-xr-x. 2 root root 6 8월 22 15:28 서식
drwxr-xr-x. 2 root root 6 8월 22 15:28 음악
[root@linux1 ~]#
[root@linux1 ~]# ls -l /test
합계 0
[root@linux1 ~]# ls -ld /test
drwxr-xr-x. 2 root root 6 9월 19 10:04 /test
[root@linux1 ~]#
--------------------------------------------------------------------
[root@linux-1 test]# mkdir -pv /test2
mkdir: created directory '/test2'
[root@linux-1 test]# ll
합계 0
-rw-r--r--. 1 root root 0 10월 17 09:55 abc
drwxr-xr-x. 3 root root 16 10월 17 10:00 d4
drwxr-xr-x. 6 root root 42 10월 17 10:02 dir1
drwxr-xr-x. 3 root root 18 10월 17 09:55 dir2
[root@linux-1 test]# ln abc /test2/abc
[root@linux-1 test]# ls -li abc
34435756 -rw-r--r--. 2 root root 0 10월 17 09:55 abc
[root@linux-1 test]# ls -li /test2/abc
34435756 -rw-r--r--. 2 root root 0 10월 17 09:55 /test2/abc
[root@linux-1 test]#
[root@linux-1 test]# cat >> abc
aaa
bbb
ccc
[root@linux-1 test]# cat abc
aaa
bbb
ccc
[root@linux-1 test]# cat /test2/abc
aaa
bbb
ccc
[root@linux-1 test]#
[root@linux-1 test]# rm -rvf abc
removed 'abc'
[root@linux-1 test]#
[root@linux-1 test]# cat /test2/abc
aaa
bbb
ccc
[root@linux-1 test]# ll /test2/abc
-rw-r--r--. 1 root root 12 10월 17 10:06 /test2/abc
[root@linux-1 test]#
[root@linux-1 ~]# ln -s /etc/sysconfig/network-scripts/ifcfg-ens33 eth0
[root@linux-1 ~]# ls -li eth0
34436031 lrwxrwxrwx. 1 root root 42 10월 17 10:12 eth0 -> /etc/sysconfig/network-scripts/ifcfg-ens33
[root@linux-1 ~]# ls -i /etc/sysconfig/network-scripts/ifcfg-ens33
33575044 /etc/sysconfig/network-scripts/ifcfg-ens33
[root@linux-1 ~]#
[root@linux-1 test]# ln -s dir2/dir3 d3
[root@linux-1 test]# ll
합계 0
lrwxrwxrwx. 1 root root 9 10월 17 10:16 d3 -> dir2/dir3
drwxr-xr-x. 3 root root 16 10월 17 10:00 d4
drwxr-xr-x. 6 root root 42 10월 17 10:02 dir1
drwxr-xr-x. 3 root root 18 10월 17 09:55 dir2
[root@linux-1 test]# cd d3
[root@linux-1 d3]# pwd
/test/d3
[root@linux-1 d3]# ll
합계 4
-rw-r--r--. 1 root root 4 10월 17 09:57 test.txt
[root@linux-1 d3]#
[root@linux-1 test]# rm -rvf .*
rm: refusing to remove '.' or '..' directory: skipping '.'
rm: refusing to remove '.' or '..' directory: skipping '..'
[root@linux-1 test]#
[root@linux-1 test]# touch f1 f2 f3 f4 f5
[root@linux-1 test]# for FILE in data{1..9}; do touch $FILE; done
[root@linux-1 test]# ll
합계 0
lrwxrwxrwx. 1 root root 9 10월 17 10:16 d3 -> dir2/dir3
drwxr-xr-x. 3 root root 16 10월 17 10:00 d4
-rw-r--r--. 1 root root 0 10월 17 11:09 data1
-rw-r--r--. 1 root root 0 10월 17 11:09 data2
-rw-r--r--. 1 root root 0 10월 17 11:09 data3
-rw-r--r--. 1 root root 0 10월 17 11:09 data4
-rw-r--r--. 1 root root 0 10월 17 11:09 data5
-rw-r--r--. 1 root root 0 10월 17 11:09 data6
-rw-r--r--. 1 root root 0 10월 17 11:09 data7
-rw-r--r--. 1 root root 0 10월 17 11:09 data8
-rw-r--r--. 1 root root 0 10월 17 11:09 data9
drwxr-xr-x. 6 root root 42 10월 17 10:02 dir1
drwxr-xr-x. 3 root root 18 10월 17 09:55 dir2
-rw-r--r--. 1 root root 0 10월 17 11:07 f1
-rw-r--r--. 1 root root 0 10월 17 11:07 f2
-rw-r--r--. 1 root root 0 10월 17 11:07 f3
-rw-r--r--. 1 root root 0 10월 17 11:07 f4
-rw-r--r--. 1 root root 0 10월 17 11:07 f5
[root@linux-1 test]#
[root@linux-1 test]# find ./ -name data3
./data3
[root@linux-1 test]# find ./ -name data*
find: paths must precede expression: data2
Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [expression]
[root@linux-1 test]# find ./ -name data10
[root@linux-1 test]# find ./ -name 'data*'
./data1
./data2
./data3
./data4
./data5
./data6
./data7
./data8
./data9
[root@linux-1 test]#
[root@linux-1 test]# echo aaa > f1
[root@linux-1 test]# echo aaa > f2
[root@linux-1 test]# find ./ -empty
./dir1/a
./dir1/b
./dir1/c
./dir1/d
./d4/d5/d6
./f3
./f4
./f5
./data1
./data2
./data3
./data4
./data5
./data6
./data7
./data8
./data9
[root@linux-1 test]# find ./ -empty -name 'f?'
./f3
./f4
./f5
[root@linux-1 test]#
[root@linux-1 test]# find ./ -empty -name 'f?' -exec rm -rvf {} \;
removed './f3'
removed './f4'
removed './f5'
[root@linux-1 test]#
[root@linux-1 test]# useradd dax
[root@linux-1 test]# passwd dax
dax 사용자의 비밀 번호 변경 중
새 암호:
잘못된 암호: 암호가 앞뒤 어느쪽에서 읽어도 같은 문맥임
새 암호 재입력:
passwd: 모든 인증 토큰이 성공적으로 업데이트 되었습니다.
[root@linux-1 test]# su - dax
[dax@linux-1 ~]$ pwd
/home/dax
[dax@linux-1 ~]$ mkdir a b c
[dax@linux-1 ~]$ touch f1 f2 f3
[dax@linux-1 ~]$ touch /tmp/aaa /tmp/bbb
[dax@linux-1 ~]$ ll
합계 0
drwxrwxr-x. 2 dax dax 6 10월 17 11:17 a
drwxrwxr-x. 2 dax dax 6 10월 17 11:17 b
drwxrwxr-x. 2 dax dax 6 10월 17 11:17 c
-rw-rw-r--. 1 dax dax 0 10월 17 11:18 f1
-rw-rw-r--. 1 dax dax 0 10월 17 11:18 f2
-rw-rw-r--. 1 dax dax 0 10월 17 11:18 f3
[dax@linux-1 ~]$ ll /tmp/aaa
-rw-rw-r--. 1 dax dax 0 10월 17 11:18 /tmp/aaa
[dax@linux-1 ~]$ ll /tmp/bbb
-rw-rw-r--. 1 dax dax 0 10월 17 11:18 /tmp/bbb
[dax@linux-1 ~]$ exit
logout
[root@linux-1 test]# mkdir /root/found
[root@linux-1 test]# find / -user dax
find: ‘/proc/34099/task/34099/fd/6’: 그런 파일이나 디렉터리가 없습니다
find: ‘/proc/34099/task/34099/fdinfo/6’: 그런 파일이나 디렉터리가 없습니다
find: ‘/proc/34099/fd/7’: 그런 파일이나 디렉터리가 없습니다
find: ‘/proc/34099/fdinfo/7’: 그런 파일이나 디렉터리가 없습니다
/var/spool/mail/dax
/home/dax
/home/dax/.mozilla
/home/dax/.mozilla/extensions
/home/dax/.mozilla/plugins
/home/dax/.bash_logout
/home/dax/.bash_profile
/home/dax/.bashrc
/home/dax/.cache
/home/dax/a
/home/dax/b
/home/dax/c
/home/dax/f1
/home/dax/f2
/home/dax/f3
/home/dax/.bash_history
/tmp/aaa
/tmp/bbb
[root@linux-1 test]#
[root@linux-1 test]# find / -user dax -exec cp -rvpf {} /root/found/ \;
find: ‘/proc/34163/task/34163/fd/6’: 그런 파일이나 디렉터리가 없습니다
find: ‘/proc/34163/task/34163/fdinfo/6’: 그런 파일이나 디렉터리가 없습니다
find: ‘/proc/34163/fd/7’: 그런 파일이나 디렉터리가 없습니다
find: ‘/proc/34163/fdinfo/7’: 그런 파일이나 디렉터리가 없습니다
'/var/spool/mail/dax' -> '/root/found/dax'
cp: cannot overwrite non-directory '/root/found/dax' with directory '/home/dax'
'/home/dax/.mozilla' -> '/root/found/.mozilla'
'/home/dax/.mozilla/extensions' -> '/root/found/.mozilla/extensions'
'/home/dax/.mozilla/plugins' -> '/root/found/.mozilla/plugins'
'/home/dax/.mozilla/extensions' -> '/root/found/extensions'
'/home/dax/.mozilla/plugins' -> '/root/found/plugins'
'/home/dax/.bash_logout' -> '/root/found/.bash_logout'
'/home/dax/.bash_profile' -> '/root/found/.bash_profile'
'/home/dax/.bashrc' -> '/root/found/.bashrc'
'/home/dax/.cache' -> '/root/found/.cache'
'/home/dax/a' -> '/root/found/a'
'/home/dax/b' -> '/root/found/b'
'/home/dax/c' -> '/root/found/c'
'/home/dax/f1' -> '/root/found/f1'
'/home/dax/f2' -> '/root/found/f2'
'/home/dax/f3' -> '/root/found/f3'
'/home/dax/.bash_history' -> '/root/found/.bash_history'
'/tmp/aaa' -> '/root/found/aaa'
'/tmp/bbb' -> '/root/found/bbb'
[root@linux-1 test]# ll /root/found/
합계 0
drwxrwxr-x. 2 dax dax 6 10월 17 11:17 a
-rw-rw-r--. 1 dax dax 0 10월 17 11:18 aaa
drwxrwxr-x. 2 dax dax 6 10월 17 11:17 b
-rw-rw-r--. 1 dax dax 0 10월 17 11:18 bbb
drwxrwxr-x. 2 dax dax 6 10월 17 11:17 c
-rw-rw----. 1 dax mail 0 10월 17 11:16 dax
drwxr-xr-x. 2 dax dax 6 5월 14 2019 extensions
-rw-rw-r--. 1 dax dax 0 10월 17 11:18 f1
-rw-rw-r--. 1 dax dax 0 10월 17 11:18 f2
-rw-rw-r--. 1 dax dax 0 10월 17 11:18 f3
drwxr-xr-x. 2 dax dax 6 5월 14 2019 plugins
[root@linux-1 test]#
[root@linux-1 test]# timedatectl set-time "2020-10-10 10:10:10"
[root@linux-1 test]# date
2020. 10. 10. (토) 10:10:12 KST
[root@linux-1 test]# touch f1 f2 f3 f4 f5
[root@linux-1 test]# ll
합계 0
-rw-r--r--. 1 root root 0 10월 10 10:11 f1
-rw-r--r--. 1 root root 0 10월 10 10:11 f2
-rw-r--r--. 1 root root 0 10월 10 10:11 f3
-rw-r--r--. 1 root root 0 10월 10 10:11 f4
-rw-r--r--. 1 root root 0 10월 10 10:11 f5
[root@linux-1 test]# stat f1
File: f1
Size: 0 Blocks: 0 IO Block: 4096 일반 빈 파일
Device: fd00h/64768d Inode: 34435997 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Context: unconfined_u:object_r:default_t:s0
Access: 2020-10-10 10:11:02.134706254 +0900
Modify: 2020-10-10 10:11:02.134706254 +0900
Change: 2020-10-10 10:11:02.134706254 +0900
Birth: -
[root@linux-1 test]# touch -t 202010091010 f1
[root@linux-1 test]# stat f1
File: f1
Size: 0 Blocks: 0 IO Block: 4096 일반 빈 파일
Device: fd00h/64768d Inode: 34435997 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Context: unconfined_u:object_r:default_t:s0
Access: 2020-10-09 10:10:00.000000000 +0900
Modify: 2020-10-09 10:10:00.000000000 +0900
Change: 2020-10-10 10:12:55.894704628 +0900
Birth: -
[root@linux-1 test]# touch -t 202010080000 f2
[root@linux-1 test]# touch -t 202010070000 f3
[root@linux-1 test]# touch -t 202010060000 f5
[root@linux-1 test]# touch -t 202010040000 f4
[root@linux-1 test]# find ./ -atime 3
./f3
[root@linux-1 test]# find ./ -atime -3
./
./f1
./f2
[root@linux-1 test]# find ./ -atime +3
./f4
./f5
[root@linux-1 test]#
[root@linux-1 test]# cat f1
[root@linux-1 test]# stat f1
File: f1
Size: 0 Blocks: 0 IO Block: 4096 일반 빈 파일
Device: fd00h/64768d Inode: 34435997 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Context: unconfined_u:object_r:default_t:s0
Access: 2020-10-10 10:17:45.049700494 +0900
Modify: 2020-10-09 10:10:00.000000000 +0900
Change: 2020-10-10 10:12:55.894704628 +0900
Birth: -
[root@linux-1 test]# echo aaa > f1
[root@linux-1 test]# stat f1
File: f1
Size: 4 Blocks: 8 IO Block: 4096 일반 파일
Device: fd00h/64768d Inode: 34435997 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Context: unconfined_u:object_r:default_t:s0
Access: 2020-10-10 10:17:45.049700494 +0900
Modify: 2020-10-10 10:18:42.235699676 +0900
Change: 2020-10-10 10:18:42.235699676 +0900
Birth: -
[root@linux-1 test]#
[root@linux-1 test]# dd if=/dev/urandom of=img1 bs=1024 count=10
10+0 records in
10+0 records out
10240 bytes (10 kB, 10 KiB) copied, 0.000415822 s, 24.6 MB/s
[root@linux-1 test]# dd if=/dev/urandom of=img2 bs=1024 count=20
20+0 records in
20+0 records out
20480 bytes (20 kB, 20 KiB) copied, 0.00056944 s, 36.0 MB/s
[root@linux-1 test]# dd if=/dev/urandom of=img3 bs=1024 count=30
30+0 records in
30+0 records out
30720 bytes (31 kB, 30 KiB) copied, 0.00172495 s, 17.8 MB/s
[root@linux-1 test]# ls -lh
합계 68K
-rw-r--r--. 1 root root 4 10월 10 10:18 f1
-rw-r--r--. 1 root root 0 10월 8 00:00 f2
-rw-r--r--. 1 root root 0 10월 7 00:00 f3
-rw-r--r--. 1 root root 0 10월 4 00:00 f4
-rw-r--r--. 1 root root 0 10월 6 00:00 f5
-rw-r--r--. 1 root root 10K 10월 10 10:24 img1
-rw-r--r--. 1 root root 20K 10월 10 10:24 img2
-rw-r--r--. 1 root root 30K 10월 10 10:24 img3
[root@linux-1 test]# find ./ -size 10k
./img1
[root@linux-1 test]# find ./ -size -10k
./
./f1
./f2
./f3
./f4
./f5
[root@linux-1 test]# find ./ -size +10k
./img2
./img3
[root@linux-1 test]#
[root@linux-1 test]# gzip img1
[root@linux-1 test]# bzip2 img2
[root@linux-1 test]# xz img3
[root@linux-1 test]# ls -lh
합계 72K
-rw-r--r--. 1 root root 4 10월 10 10:18 f1
-rw-r--r--. 1 root root 0 10월 8 00:00 f2
-rw-r--r--. 1 root root 0 10월 7 00:00 f3
-rw-r--r--. 1 root root 0 10월 4 00:00 f4
-rw-r--r--. 1 root root 0 10월 6 00:00 f5
-rw-r--r--. 1 root root 11K 10월 10 10:24 img1.gz
-rw-r--r--. 1 root root 21K 10월 10 10:24 img2.bz2
-rw-r--r--. 1 root root 31K 10월 10 10:24 img3.xz
[root@linux-1 test]#
[root@linux-1 test]# ls -lh f3
-rw-r--r--. 1 root root 64K 10월 10 10:36 f3
[root@linux-1 test]# bzip2 f3
[root@linux-1 test]# ls -lh f3.bz2
-rw-r--r--. 1 root root 73 10월 10 10:36 f3.bz2
[root@linux-1 test]#
[root@linux-1 test]# ll
합계 80
-rw-r--r--. 1 root root 4 10월 10 10:18 f1
-rw-r--r--. 1 root root 23 10월 8 00:00 f2.gz
-rw-r--r--. 1 root root 73 10월 10 10:36 f3.bz2
-rw-r--r--. 1 root root 0 10월 4 00:00 f4
-rw-r--r--. 1 root root 0 10월 6 00:00 f5
-rw-r--r--. 1 root root 10268 10월 10 10:24 img1.gz
-rw-r--r--. 1 root root 20944 10월 10 10:24 img2.bz2
-rw-r--r--. 1 root root 30780 10월 10 10:24 img3.xz
[root@linux-1 test]# bzip2 -d f3.bz2
[root@linux-1 test]# ll
합계 140
-rw-r--r--. 1 root root 4 10월 10 10:18 f1
-rw-r--r--. 1 root root 23 10월 8 00:00 f2.gz
-rw-r--r--. 1 root root 65195 10월 10 10:36 f3
-rw-r--r--. 1 root root 0 10월 4 00:00 f4
-rw-r--r--. 1 root root 0 10월 6 00:00 f5
-rw-r--r--. 1 root root 10268 10월 10 10:24 img1.gz
-rw-r--r--. 1 root root 20944 10월 10 10:24 img2.bz2
-rw-r--r--. 1 root root 30780 10월 10 10:24 img3.xz
[root@linux-1 test]#
[root@linux-1 test]# ll
합계 140
-rw-r--r--. 1 root root 4 10월 10 10:18 f1
-rw-r--r--. 1 root root 23 10월 8 00:00 f2.gz
-rw-r--r--. 1 root root 65195 10월 10 10:36 f3
-rw-r--r--. 1 root root 0 10월 4 00:00 f4
-rw-r--r--. 1 root root 0 10월 6 00:00 f5
-rw-r--r--. 1 root root 10268 10월 10 10:24 img1.gz
-rw-r--r--. 1 root root 20944 10월 10 10:24 img2.bz2
-rw-r--r--. 1 root root 30780 10월 10 10:24 img3.xz
[root@linux-1 test]# gzip -d f2.gz
[root@linux-1 test]# gzip -d img1.gz
[root@linux-1 test]# bzip2 -d img2.bz2
[root@linux-1 test]# xz -d img3.xz
[root@linux-1 test]# ll
합계 132
-rw-r--r--. 1 root root 4 10월 10 10:18 f1
-rw-r--r--. 1 root root 0 10월 8 00:00 f2
-rw-r--r--. 1 root root 65195 10월 10 10:36 f3
-rw-r--r--. 1 root root 0 10월 4 00:00 f4
-rw-r--r--. 1 root root 0 10월 6 00:00 f5
-rw-r--r--. 1 root root 10240 10월 10 10:24 img1
-rw-r--r--. 1 root root 20480 10월 10 10:24 img2
-rw-r--r--. 1 root root 30720 10월 10 10:24 img3
[root@linux-1 test]#
[root@linux-1 test]# tar cvf file.tar f1 f2 f3 f4 f5
f1
f2
f3
f4
f5
[root@linux-1 test]# ll
합계 204
-rw-r--r--. 1 root root 4 10월 10 10:18 f1
-rw-r--r--. 1 root root 0 10월 8 00:00 f2
-rw-r--r--. 1 root root 65195 10월 10 10:36 f3
-rw-r--r--. 1 root root 0 10월 4 00:00 f4
-rw-r--r--. 1 root root 0 10월 6 00:00 f5
-rw-r--r--. 1 root root 71680 10월 17 12:27 file.tar
-rw-r--r--. 1 root root 10240 10월 10 10:24 img1
-rw-r--r--. 1 root root 20480 10월 10 10:24 img2
-rw-r--r--. 1 root root 30720 10월 10 10:24 img3
[root@linux-1 test]#
[root@linux-1 test]# tar cvf setting.tar /etc
[root@linux-1 test]# ls -lh
합계 27M
-rw-r--r--. 1 root root 4 10월 10 10:18 f1
-rw-r--r--. 1 root root 0 10월 8 00:00 f2
-rw-r--r--. 1 root root 64K 10월 10 10:36 f3
-rw-r--r--. 1 root root 0 10월 4 00:00 f4
-rw-r--r--. 1 root root 0 10월 6 00:00 f5
-rw-r--r--. 1 root root 70K 10월 17 12:27 file.tar
-rw-r--r--. 1 root root 10K 10월 10 10:24 img1
-rw-r--r--. 1 root root 20K 10월 10 10:24 img2
-rw-r--r--. 1 root root 30K 10월 10 10:24 img3
-rw-r--r--. 1 root root 26M 10월 17 12:29 setting.tar
[root@linux-1 test]#
[root@linux-1 test]# tar cvf home.tar /home
[root@linux-1 test]# ls -lh home.tar
-rw-r--r--. 1 root root 20K 10월 17 12:30 home.tar
[root@linux-1 test]#
[root@linux-1 test]# rm -rvf /home/*
removed directory '/home/dax/.mozilla/extensions'
removed directory '/home/dax/.mozilla/plugins'
removed directory '/home/dax/.mozilla'
removed '/home/dax/.bash_logout'
removed '/home/dax/.bash_profile'
removed '/home/dax/.bashrc'
removed directory '/home/dax/.cache'
removed directory '/home/dax/a'
removed directory '/home/dax/b'
removed directory '/home/dax/c'
removed '/home/dax/f1'
removed '/home/dax/f2'
removed '/home/dax/f3'
removed '/home/dax/.bash_history'
removed directory '/home/dax'
removed directory '/home/student/.mozilla/extensions'
removed directory '/home/student/.mozilla/plugins'
removed directory '/home/student/.mozilla'
removed '/home/student/.bash_logout'
removed '/home/student/.bash_profile'
removed '/home/student/.bashrc'
removed directory '/home/student'
[root@linux-1 test]# ll /home
합계 0
[root@linux-1 test]# tar xvf home.tar -C /
home/
home/student/
home/student/.mozilla/
home/student/.mozilla/extensions/
home/student/.mozilla/plugins/
home/student/.bash_logout
home/student/.bash_profile
home/student/.bashrc
home/dax/
home/dax/.mozilla/
home/dax/.mozilla/extensions/
home/dax/.mozilla/plugins/
home/dax/.bash_logout
home/dax/.bash_profile
home/dax/.bashrc
home/dax/.cache/
home/dax/a/
home/dax/b/
home/dax/c/
home/dax/f1
home/dax/f2
home/dax/f3
home/dax/.bash_history
[root@linux-1 test]# ll /home
합계 0
drwx------. 7 dax dax 170 10월 17 11:19 dax
drwx------. 3 student student 78 9월 29 09:26 student
[root@linux-1 test]#
[root@linux-1 test]# tar zcvf setting.tar.gz /etc/*
[root@linux-1 test]# ls -lh
합계 32M
-rw-r--r--. 1 root root 4 10월 10 10:18 f1
-rw-r--r--. 1 root root 0 10월 8 00:00 f2
-rw-r--r--. 1 root root 64K 10월 10 10:36 f3
-rw-r--r--. 1 root root 0 10월 4 00:00 f4
-rw-r--r--. 1 root root 0 10월 6 00:00 f5
-rw-r--r--. 1 root root 70K 10월 17 12:27 file.tar
-rw-r--r--. 1 root root 20K 10월 17 12:30 home.tar
-rw-r--r--. 1 root root 10K 10월 10 10:24 img1
-rw-r--r--. 1 root root 20K 10월 10 10:24 img2
-rw-r--r--. 1 root root 30K 10월 10 10:24 img3
-rw-r--r--. 1 root root 26M 10월 17 12:29 setting.tar
-rw-r--r--. 1 root root 5.9M 10월 17 12:38 setting.tar.gz
[root@linux-1 test]# date
2020. 10. 17. (토) 12:52:49 KST
[root@linux-1 test]# date +%Y
2020
[root@linux-1 test]# date +%M
54
[root@linux-1 test]# date +%m
10
[root@linux-1 test]# date +%d
17
[root@linux-1 test]# date +%D
10/17/20
[root@linux-1 test]#
[root@linux-1 test]# touch backup-2020-10.17.tar
[root@linux-1 test]# ll
합계 0
-rw-r--r--. 1 root root 0 10월 17 12:59 backup-2020-10.17.tar
[root@linux-1 test]# touch bak-$(date +%Y-%m-%d).tar
[root@linux-1 test]# ll
합계 0
-rw-r--r--. 1 root root 0 10월 17 12:59 backup-2020-10.17.tar
-rw-r--r--. 1 root root 0 10월 17 13:02 bak-2020-10-17.tar
[root@linux-1 test]# touch file-$(date +%H:%M).tar
[root@linux-1 test]# ll
합계 0
-rw-r--r--. 1 root root 0 10월 17 12:59 backup-2020-10.17.tar
-rw-r--r--. 1 root root 0 10월 17 13:02 bak-2020-10-17.tar
-rw-r--r--. 1 root root 0 10월 17 13:04 file-13:04.tar
[root@linux-1 test]#
[root@linux-1 test]# tar cvf etc_backup-$(date +%H:%M).tar /etc/*
tar: etc_backup-13에 연결할 수 없음: 주소 해석 실패
[root@linux-1 test]# tar cvf etc_backup-$(date +%H%M).tar /etc/*
[root@linux-1 test]# ll
합계 26500
-rw-r--r--. 1 root root 0 10월 17 12:59 backup-2020-10.17.tar
-rw-r--r--. 1 root root 0 10월 17 13:02 bak-2020-10-17.tar
-rw-r--r--. 1 root root 0 10월 17 13:07 cvf
-rw-r--r--. 1 root root 27136000 10월 17 13:07 etc_backup-1307.tar
-rw-r--r--. 1 root root 0 10월 17 13:07 etc_backup-13:07.tar
-rw-r--r--. 1 root root 0 10월 17 13:04 file-10월:04.tar
-rw-r--r--. 1 root root 0 10월 17 13:04 file-13:04.tar
Linux1>
[root@linux-1 test]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:VDmPYZWVBmznZIqF0mVt20Kq8/gZUU4JCP4CfKX+WcI root@linux-1.example.com
The key's randomart image is:
+---[RSA 3072]----+
| .ooB*=.. |
| . ..+O.=.X. |
| o =o O @+o |
| = oo +++ .|
| S E.o .. |
| oo+ . |
| o+. |
| . .o |
| .o |
+----[SHA256]-----+
[root@linux-1 test]# ssh-copy-id root@172.25.3.12
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@172.25.3.12's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'root@172.25.3.12'"
and check to make sure that only the key(s) you wanted were added.
[root@linux-1 test]# wall hi
Linux2>
[root@linux-2 ~]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:VDmPYZWVBmznZIqF0mVt20Kq8/gZUU4JCP4CfKX+WcI root@linux-2.example.com
The key's randomart image is:
+---[RSA 3072]----+
| .ooB*=.. |
| . ..+O.=.X. |
| o =o O @+o |
| = oo +++ .|
| S E.o .. |
| oo+ . |
| o+. |
| . .o |
| .o |
+----[SHA256]-----+
[root@linux-2 ~]# ssh-copy-id root@172.25.3.11
The authenticity of host '172.25.3.11 (172.25.3.11)' can't be established.
ECDSA key fingerprint is SHA256:RnXKaFZFxhTBjywM4XLlAF4wlyDJUme0XpXbcWYRq5o.
Are you sure you want to continue connecting (yes/no/[fingerprint])?
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
The authenticity of host '172.25.3.11 (172.25.3.11)' can't be established.
ECDSA key fingerprint is SHA256:RnXKaFZFxhTBjywM4XLlAF4wlyDJUme0XpXbcWYRq5o.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@172.25.3.11's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'root@172.25.3.11'"
and check to make sure that only the key(s) you wanted were added.
[root@linux-2 ~]# ssh root@172.25.3.11
Activate the web console with: systemctl enable --now cockpit.socket
Last login: Sat Oct 17 12:56:38 2020
Broadcast message from root@linux-1.example.com (pts/0) (Sat Oct 17 13:21:38 20
hi
[root@linux-1 bin]# vim home_backup.sh
#!/bin/bash
NOW=$(date +%H%M)
tar cvf /backup/home-$NOW.tar /home/*
[root@linux-1 bin]# ll
합계 4
-rw-r--r--. 1 root root 68 10월 17 15:04 home_backup.sh
[root@linux-1 bin]# chmod 777 home_backup.sh
[root@linux-1 bin]# ll
합계 4
-rwxrwxrwx. 1 root root 68 10월 17 15:04 home_backup.sh
[root@linux-1 backup]# crontab -e
* * * * /root/bin/home_backup.sh
[root@linux-1 bin]# systemctl restart crond
[root@linux-1 bin]# cd /backup
[root@linux-1 backup]# ll
합계 60
-rw-r--r--. 1 root root 20480 10월 17 15:06 home-1506.tar
-rw-r--r--. 1 root root 20480 10월 17 15:11 home-1511.tar
-rw-r--r--. 1 root root 20480 10월 17 15:12 home-1512.tar
[root@linux-1 backup]# ll
합계 80
-rw-r--r--. 1 root root 20480 10월 17 15:06 home-1506.tar
-rw-r--r--. 1 root root 20480 10월 17 15:11 home-1511.tar
-rw-r--r--. 1 root root 20480 10월 17 15:12 home-1512.tar
-rw-r--r--. 1 root root 20480 10월 17 15:13 home-1513.tar
[root@linux-1 backup]# crontab -r
[root@linux-1 backup]# yum remove httpd -y
Dependencies resolved.
======================================================================================================================
Package Architecture Version Repository Size
======================================================================================================================
삭제 중:
httpd x86_64 2.4.37-21.module_el8.2.0+494+1df74eae @AppStream 4.9 M
Removing unused dependencies:
apr x86_64 1.6.3-9.el8 @AppStream 293 k
apr-util x86_64 1.6.1-6.el8 @AppStream 231 k
apr-util-bdb x86_64 1.6.1-6.el8 @AppStream 12 k
apr-util-openssl x86_64 1.6.1-6.el8 @AppStream 20 k
centos-logos-httpd noarch 80.5-2.el8 @BaseOS 1.9 k
httpd-filesystem noarch 2.4.37-21.module_el8.2.0+494+1df74eae @AppStream 400
httpd-tools x86_64 2.4.37-21.module_el8.2.0+494+1df74eae @AppStream 194 k
mod_http2 x86_64 1.11.3-3.module_el8.2.0+486+c01050f0.1 @AppStream 400 k
Transaction Summary
======================================================================================================================
삭제 9 Packages
Freed space: 6.0 M
Is this ok [y/N]: y
트랜잭션 점검 실행 중
트랜잭션 검사가 성공했습니다.
트랜잭션 테스트 실행 중
트랜잭션 테스트가 완료되었습니다.
거래 실행 중
준비 중입니다 : 1/1
스크립틀릿 실행: httpd-2.4.37-21.module_el8.2.0+494+1df74eae.x86_64 1/1
스크립틀릿 실행: httpd-2.4.37-21.module_el8.2.0+494+1df74eae.x86_64 1/9
삭제 중 : httpd-2.4.37-21.module_el8.2.0+494+1df74eae.x86_64 1/9
스크립틀릿 실행: httpd-2.4.37-21.module_el8.2.0+494+1df74eae.x86_64 1/9
삭제 중 : httpd-filesystem-2.4.37-21.module_el8.2.0+494+1df74eae.noarch 2/9
스크립틀릿 실행: httpd-filesystem-2.4.37-21.module_el8.2.0+494+1df74eae.noarch 2/9
삭제 중 : centos-logos-httpd-80.5-2.el8.noarch 3/9
삭제 중 : httpd-tools-2.4.37-21.module_el8.2.0+494+1df74eae.x86_64 4/9
삭제 중 : apr-util-1.6.1-6.el8.x86_64 5/9
스크립틀릿 실행: apr-util-1.6.1-6.el8.x86_64 5/9
삭제 중 : apr-1.6.3-9.el8.x86_64 6/9
스크립틀릿 실행: apr-1.6.3-9.el8.x86_64 6/9
삭제 중 : apr-util-bdb-1.6.1-6.el8.x86_64 7/9
삭제 중 : apr-util-openssl-1.6.1-6.el8.x86_64 8/9
삭제 중 : mod_http2-1.11.3-3.module_el8.2.0+486+c01050f0.1.x86_64 9/9
스크립틀릿 실행: mod_http2-1.11.3-3.module_el8.2.0+486+c01050f0.1.x86_64 9/9
확인 중 : apr-1.6.3-9.el8.x86_64 1/9
확인 중 : apr-util-1.6.1-6.el8.x86_64 2/9
확인 중 : apr-util-bdb-1.6.1-6.el8.x86_64 3/9
확인 중 : apr-util-openssl-1.6.1-6.el8.x86_64 4/9
확인 중 : centos-logos-httpd-80.5-2.el8.noarch 5/9
확인 중 : httpd-2.4.37-21.module_el8.2.0+494+1df74eae.x86_64 6/9
확인 중 : httpd-filesystem-2.4.37-21.module_el8.2.0+494+1df74eae.noarch 7/9
확인 중 : httpd-tools-2.4.37-21.module_el8.2.0+494+1df74eae.x86_64 8/9
확인 중 : mod_http2-1.11.3-3.module_el8.2.0+486+c01050f0.1.x86_64 9/9
Installed products updated.
제거됨:
apr-1.6.3-9.el8.x86_64
apr-util-1.6.1-6.el8.x86_64
apr-util-bdb-1.6.1-6.el8.x86_64
apr-util-openssl-1.6.1-6.el8.x86_64
centos-logos-httpd-80.5-2.el8.noarch
httpd-2.4.37-21.module_el8.2.0+494+1df74eae.x86_64
httpd-filesystem-2.4.37-21.module_el8.2.0+494+1df74eae.noarch
httpd-tools-2.4.37-21.module_el8.2.0+494+1df74eae.x86_64
mod_http2-1.11.3-3.module_el8.2.0+486+c01050f0.1.x86_64
완료되었습니다!
Linux1>
[root@linux-1 ~]# yum -y install httpd
[root@linux-1 ~]# grep apache /etc/passwd
apache:x:48:48:Apache:/usr/share/httpd:/sbin/nologin
[root@linux-1 ~]# grep apache /etc/passwd /etc/group
/etc/passwd:apache:x:48:48:Apache:/usr/share/httpd:/sbin/nologin
/etc/group:apache:x:48:
[root@linux-1 backup]# cd /var/www
[root@linux-1 www]# ll
합계 0
drwxr-xr-x. 2 root root 6 9월 16 00:46 cgi-bin
drwxr-xr-x. 2 root root 6 9월 16 00:46 html
[root@linux-1 www]# mkdir -pv kbs mbc sbs
mkdir: created directory 'kbs'
mkdir: created directory 'mbc'
mkdir: created directory 'sbs'
[root@linux-1 www]# ll
합계 0
drwxr-xr-x. 2 root root 6 9월 16 00:46 cgi-bin
drwxr-xr-x. 2 root root 6 9월 16 00:46 html
drwxr-xr-x. 2 root root 6 10월 17 15:26 kbs
drwxr-xr-x. 2 root root 6 10월 17 15:26 mbc
drwxr-xr-x. 2 root root 6 10월 17 15:26 sbs
[root@linux-1 www]# ls -lZ
합계 0
drwxr-xr-x. 2 root root system_u:object_r:httpd_sys_script_exec_t:s0 6 9월 16 00:46 cgi-bin
drwxr-xr-x. 2 root root system_u:object_r:httpd_sys_content_t:s0 6 9월 16 00:46 html
drwxr-xr-x. 2 root root unconfined_u:object_r:httpd_sys_content_t:s0 6 10월 17 15:26 kbs
drwxr-xr-x. 2 root root unconfined_u:object_r:httpd_sys_content_t:s0 6 10월 17 15:26 mbc
drwxr-xr-x. 2 root root unconfined_u:object_r:httpd_sys_content_t:s0 6 10월 17 15:26 sbs
[root@linux-1 www]# vim kbs/index.html
[root@linux-1 www]# echo "Hello! MBC!" > mbc/index.html
[root@linux-1 www]# echo "Hello! SBS!" > sbs/index.html
[root@linux-1 www]# tree /var/www
/var/www
├── cgi-bin
├── html
├── kbs
│ └── index.html
├── mbc
│ └── index.html
└── sbs
└── index.html
5 directories, 3 files
[root@linux-1 www]# cd /usr/share/doc/
[root@linux-1 doc]# pwd
/usr/share/doc
[root@linux-1 doc]# cd httpd
httpd/ httpd-tools/
[root@linux-1 doc]# cd httpd/
[root@linux-1 httpd]# ll
합계 384
-rw-r--r--. 1 root root 13496 4월 16 2015 ABOUT_APACHE
-rw-r--r--. 1 root root 262903 10월 18 2018 CHANGES
-rw-r--r--. 1 root root 25478 2월 21 2018 LICENSE
-rw-r--r--. 1 root root 720 2월 21 2018 NOTICE
-rw-r--r--. 1 root root 4642 1월 24 2014 README
-rw-r--r--. 1 root root 8183 3월 1 2007 VERSIONING
-rw-r--r--. 1 root root 2926 9월 16 00:42 httpd-autoindex.conf
-rw-r--r--. 1 root root 1781 9월 16 00:42 httpd-dav.conf
-rw-r--r--. 1 root root 2942 9월 16 00:42 httpd-default.conf
-rw-r--r--. 1 root root 1119 9월 16 00:42 httpd-info.conf
-rw-r--r--. 1 root root 5078 9월 16 00:42 httpd-languages.conf
-rw-r--r--. 1 root root 1391 9월 16 00:42 httpd-manual.conf
-rw-r--r--. 1 root root 4443 9월 16 00:42 httpd-mpm.conf
-rw-r--r--. 1 root root 2216 9월 16 00:42 httpd-multilang-errordoc.conf
-rw-r--r--. 1 root root 1477 9월 16 00:42 httpd-vhosts.conf
-rw-r--r--. 1 root root 11094 9월 16 00:39 instance.conf
-rw-r--r--. 1 root root 3161 9월 16 00:42 proxy-html.conf
[root@linux-1 httpd]# ll httpd-vhosts.conf
-rw-r--r--. 1 root root 1477 9월 16 00:42 httpd-vhosts.conf
[root@linux-1 httpd]# pwd
/usr/share/doc/httpd
[root@linux-1 httpd]# cp httpd-vhosts.conf /etc/httpd/conf.d/vhosts.conf
[root@linux-1 httpd]# cd /etc/httpd/conf.d/
[root@linux-1 conf.d]# ll
합계 20
-rw-r--r--. 1 root root 400 9월 16 00:46 README
-rw-r--r--. 1 root root 2926 9월 16 00:42 autoindex.conf
-rw-r--r--. 1 root root 1252 9월 16 00:39 userdir.conf
-rw-r--r--. 1 root root 1477 10월 17 15:54 vhosts.conf
-rw-r--r--. 1 root root 738 9월 16 00:39 welcome.conf
[root@linux-1 conf.d]# pwd
/etc/httpd/conf.d
[root@linux-1 conf.d]# vim vhosts.conf
23 <VirtualHost *:80>
24 ServerAdmin root@kbs2020.com
25 DocumentRoot "/var/www/kbs"
26 ServerName linux-1.kbs2020.com
27 ServerAlias www.kbs2020.com
28 # ErrorLog "/var/log/httpd/dummy-host.example.com-error_log"
29 # CustomLog "/var/log/httpd/dummy-host.example.com-access_log" common
30 </VirtualHost>
31
32 <VirtualHost *:80>
33 ServerAdmin root@mbc2020.com
34 DocumentRoot "/var/www/mbc"
35 ServerName linux-1.mbc2020.com
36 ServerAlias www.mbc2020.com
37 # ErrorLog "/var/log/httpd/dummy-host.example.com-error_log"
38 # CustomLog "/var/log/httpd/dummy-host.example.com-access_log" common
39 </VirtualHost>
40
41 <VirtualHost *:80>
42 ServerAdmin root@sbs2020.com
43 DocumentRoot "/var/www/sbs"
44 ServerName linux-1.sbs2020.com
45 ServerAlias www.sbs2020.com
46 # ErrorLog "/var/log/httpd/dummy-host.example.com-error_log"
47 # CustomLog "/var/log/httpd/dummy-host.example.com-access_log" common
48 </VirtualHost>
49
50 <Directory "/var/www/kbs">
51 Require all granted
52 </Directory>
53
54 <Directory "/var/www/mbc">
55 Require all granted
56 </Directory>
57
58 <Directory "/var/www/sbs">
59 Require all granted
60 </Directory>
[root@linux-1 conf.d]# cd /etc/httpd/conf
[root@linux-1 conf]# pwd
/etc/httpd/conf
[root@linux-1 conf]# vim httpd.conf
[root@linux-1 conf]# systemctl start httpd
[root@linux-1 conf]# systemctl restart httpd
[root@linux-1 conf]# systemctl enable httpd
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
[root@linux-1 conf]# firewall-cmd --permanent --add-service=http
success
[root@linux-1 conf]# firewall-cmd --reload
success
[root@linux-1 conf]#
Linux2>
[root@linux-2 ~]# vim /etc/hosts
4 172.25.3.11 www.example.com
5 172.25.3.11 www.kbs2020.com www.mbc2020.com www.sbs2020.com
Linux1>
[root@linux-1 conf]# yum list installed rsync*
설치된 패키지
rsync.x86_64 3.1.3-7.el8 @anaconda
[root@linux-1 conf]# yum list available rsync*
마지막 메타 데이터 만료 확인 : 0:42:05 전에 2020년 10월 17일 (토) 오후 04시 07분 05초.
사용 가능한 패키지
rsync-daemon.noarch 3.1.3-7.el8 BaseOS
[root@linux-1 conf]# yum -y install rsync-daemon.noarch
[root@linux-1 conf]# systemctl status rsyncd
● rsyncd.service - fast remote file copy program daemon
Loaded: loaded (/usr/lib/systemd/system/rsyncd.service; disabled; vendor preset: disabled)
Active: inactive (dead)
[root@linux-1 conf]# systemctl enable --now rsyncd
Created symlink /etc/systemd/system/multi-user.target.wants/rsyncd.service → /usr/lib/systemd/system/rsyncd.service.
[root@linux-1 conf]# firewall-cmd --permanent --add-service=rsyncd
success
[root@linux-1 conf]# firewall-cmd --reload
success
[root@linux-1 conf]# firewall-cmd --list-all
public (active)
target: default
icmp-block-inversion: no
interfaces: ens33
sources:
services: cockpit dhcpv6-client http rsyncd ssh
ports:
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules:
[root@linux-1 conf]# mkdir -pv /project1 /project2
mkdir: created directory '/project1'
mkdir: created directory '/project2'
[root@linux-1 conf]# cd /project1
[root@linux-1 project1]# rsync -avh /project1/* /project2
sending incremental file list
src1.txt
data1/
sent 129 bytes received 39 bytes 336.00 bytes/sec
total size is 0 speedup is 0.00
[[root@linux-1 project1]# ll /project1
합계 0
drwxr-xr-x. 2 root root 6 10월 17 16:56 data1
-rw-r--r--. 1 root root 0 10월 17 16:56 src1.txt
[root@linux-1 project1]# ll /project2
합계 0
drwxr-xr-x. 2 root root 6 10월 17 16:56 data1
-rw-r--r--. 1 root root 0 10월 17 16:56 src1.txt
[root@linux-1 project1]# touch src2.txt
[root@linux-1 project1]# mkdir data2
[root@linux-1 project1]# rsync -avh /project1/* /project2
sending incremental file list
src2.txt
data2/
sent 171 bytes received 40 bytes 422.00 bytes/sec
total size is 0 speedup is 0.00
[root@linux-1 project1]# echo "aaa" > src1.txt
[root@linux-1 project1]# touch data1/abc.txt
[root@linux-1 project1]# rsync -avh /project1/* /project2
sending incremental file list
src1.txt
data1/
data1/abc.txt
sent 250 bytes received 63 bytes 626.00 bytes/sec
total size is 4 speedup is 0.01
[root@linux-1 project1]# rsync -avh /project1/* /project3
sending incremental file list
created directory /project3
src1.txt
src2.txt
data1/
data1/abc.txt
data2/
sent 292 bytes received 117 bytes 818.00 bytes/sec
total size is 4 speedup is 0.01
[root@linux-1 project1]# ll /project3
합계 4
drwxr-xr-x. 2 root root 21 10월 17 17:01 data1
drwxr-xr-x. 2 root root 6 10월 17 16:59 data2
-rw-r--r--. 1 root root 4 10월 17 17:01 src1.txt
-rw-r--r--. 1 root root 0 10월 17 16:59 src2.txt
[root@linux-1 project1]# rsync -avh /project1/* root@172.25.3.12:/project1
sending incremental file list
created directory /project1
src1.txt
src2.txt
data1/
data1/abc.txt
data2/
sent 296 bytes received 121 bytes 278.00 bytes/sec
total size is 4 speedup is 0.01
[root@linux-1 project1]# echo bbb > src2.txt
[root@linux-1 project1]# rsync -avh /project1/* root@172.25.3.12:/project1
sending incremental file list
src2.txt
sent 204 bytes received 37 bytes 160.67 bytes/sec
total size is 8 speedup is 0.03
[root@linux-1 bin]# vim sync.sh
#!/bin/bash
rsync -avh /project1/* root@172.25.3.12:/project1
# rsync -avh /project1/* root@172.25.3.13:/project1
[root@linux-1 bin]# chmod a+x sync.sh
[root@linux-1 bin]# ll
합계 7
-rwxr-xr-x. 1 root root 115 10월 17 17:23 sync.sh
[root@linux-1 bin]# crontab -e
* * * * * /root/bin/sync.sh
no crontab for root - using an empty one
crontab: installing new crontab
[root@linux-1 bin]# systemctl restart crond
[root@linux-1 bin]# cd /project1
[root@linux-1 project1]# ll
합계 8
drwxr-xr-x. 2 root root 21 10월 17 17:01 data1
drwxr-xr-x. 2 root root 6 10월 17 16:59 data2
-rw-r--r--. 1 root root 4 10월 17 17:01 src1.txt
-rw-r--r--. 1 root root 4 10월 17 17:14 src2.txt
[root@linux-1 project1]# touch newf1.txt
[root@linux-1 project1]# cat >> src1.txt
Linux2>
[root@linux-2 ~]# yum -y install rsync-daemon.noarch
[root@linux-2 ~]# systemctl enable --now rsyncd
Created symlink /etc/systemd/system/multi-user.target.wants/rsyncd.service → /usr/lib/systemd/system/rsyncd.service.
[root@linux-2 ~]# firewall-cmd --permanent --add-service=rsyncd
success
[root@linux-2 ~]# firewall-cmd --reload
success
[root@linux-2 ~]# firewall-cmd --list-all
public (active)
target: default
icmp-block-inversion: no
interfaces: ens33
sources:
services: cockpit dhcpv6-client rsyncd ssh
ports:
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules:
[root@linux-2 ~]# cd /project1/
[root@linux-2 project1]# ll
합계 8
drwxr-xr-x. 2 root root 21 10월 17 17:01 data1
drwxr-xr-x. 2 root root 6 10월 17 16:59 data2
-rw-r--r--. 1 root root 4 10월 17 17:01 src1.txt
-rw-r--r--. 1 root root 4 10월 17 17:14 src2.txt
[root@linux-2 project1]# cat src2.txt
bbb
[root@linux-2 project1]# ll
합계 8
drwxr-xr-x. 2 root root 21 10월 17 17:01 data1
drwxr-xr-x. 2 root root 6 10월 17 16:59 data2
-rw-r--r--. 1 root root 0 10월 17 17:28 newf1.txt
-rw-r--r--. 1 root root 16 10월 17 17:29 src1.txt
-rw-r--r--. 1 root root 4 10월 17 17:14 src2.txt
[root@linux-2 project1]# cat src1.txt
aaa
hhh
nnn
fff
[root@linux-2 project1]#
Linux1>
[root@linux-1 project1]# touch fff
[root@linux-1 project1]# scp fff root@172.25.3.12:/project1
fff 100% 0 0.0KB/s 00:00
[root@linux-1 project1]#
Linux2>
[root@linux-2 project1]# ll
합계 8
drwxr-xr-x. 2 root root 21 10월 17 17:01 data1
drwxr-xr-x. 2 root root 6 10월 17 16:59 data2
-rw-r--r--. 1 root root 0 10월 17 17:31 fff
-rw-r--r--. 1 root root 0 10월 17 17:28 newf1.txt
-rw-r--r--. 1 root root 16 10월 17 17:29 src1.txt
-rw-r--r--. 1 root root 4 10월 17 17:14 src2.txt
[root@linux-2 project1]#
Linux1>
[root@linux-1 project1]# yum -y install lsyncd
마지막 메타 데이터 만료 확인 : 1:27:09 전에 2020년 10월 17일 (토) 오후 04시 07분 05초.
No match for argument: lsyncd
오류: 경기를 찾을 수 없습니다.: lsyncd
[root@linux-1 project1]# yum -y install epel-release
[root@linux-1 project1]# yum repolist
repo id repo name
AppStream CentOS-8 - AppStream
BaseOS CentOS-8 - Base
epel Extra Packages for Enterprise Linux 8 - x86_64
epel-modular Extra Packages for Enterprise Linux Modular 8 - x86_64
extras CentOS-8 - Extras
[root@linux-1 project1]# yum -y install lsyncd
[root@linux-1 project1]# systemctl enable --now lsyncd
Created symlink /etc/systemd/system/multi-user.target.wants/lsyncd.service → /usr/lib/systemd/system/lsyncd.service.
[root@linux-1 project1]# cd /usr/share/doc/lsyncd/examples/
[root@linux-1 examples]# cp lrsync.lua /etc/lsyncd.conf
cp: overwrite '/etc/lsyncd.conf'? y
[root@linux-1 project1]# vim /etc/lsyncd.conf
11 sync{
12 default.rsync,
13 source="/project1/",
14 target="172.25.3.12:/project1/",
15 }
[root@linux-1 project1]# systemctl status lsyncd
● lsyncd.service - Live Syncing (Mirror) Daemon
Loaded: loaded (/usr/lib/systemd/system/lsyncd.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Sat 2020-10-17 17:59:53 KST; 4s ago
Process: 12311 ExecStart=/usr/bin/lsyncd -nodaemon $LSYNCD_OPTIONS (code=exited, status=255)
Main PID: 12311 (code=exited, status=255)
10월 17 17:59:53 linux-1.example.com systemd[1]: Started Live Syncing (Mirror) Daemon.
10월 17 17:59:53 linux-1.example.com lsyncd[12311]: Error: failure getting absolute path of [/project1/*]
10월 17 17:59:53 linux-1.example.com lsyncd[12311]: Error: Cannot access source directory: /project1/*
10월 17 17:59:53 linux-1.example.com systemd[1]: lsyncd.service: Main process exited, code=exited, status=255/n/a
10월 17 17:59:53 linux-1.example.com systemd[1]: lsyncd.service: Failed with result 'exit-code'.
[root@linux-1 project1]# systemctl restart lsyncd
[root@linux-1 project1]# systemctl status lsyncd
● lsyncd.service - Live Syncing (Mirror) Daemon
Loaded: loaded (/usr/lib/systemd/system/lsyncd.service; enabled; vendor preset: disabled)
Active: active (running) since Sat 2020-10-17 18:06:54 KST; 10s ago
Main PID: 12592 (lsyncd)
Tasks: 1 (limit: 11155)
Memory: 892.0K
CGroup: /system.slice/lsyncd.service
└─12592 /usr/bin/lsyncd -nodaemon /etc/lsyncd.conf
10월 17 18:06:54 linux-1.example.com systemd[1]: Started Live Syncing (Mirror) Daemon.
[root@linux-1 project1]# crontab -r
[root@linux-1 project1]# touch src4.txt
Linux2>
[root@linux-2 project1]# vim /etc/rsyncd.conf
[project]
path = /project1
comment = data dir.
uid = root
gid = root
use chroot = yes
read only = no
list = true
hosts allow = 172.25.3.11
max connections = 5
[root@linux-2 project1]# ll
합계 8
drwxr-xr-x. 2 root root 21 10월 17 17:01 data1
drwxr-xr-x. 2 root root 6 10월 17 16:59 data2
-rw-r--r--. 1 root root 0 10월 17 17:31 fff
-rw-r--r--. 1 root root 0 10월 17 17:28 newf1.txt
-rw-r--r--. 1 root root 0 10월 17 18:07 src.txt
-rw-r--r--. 1 root root 16 10월 17 17:29 src1.txt
-rw-r--r--. 1 root root 19 10월 17 18:07 src2.txt
-rw-r--r--. 1 root root 0 10월 17 18:08 src4.txt
[root@linux-2 project1]#
'CentOS > Study' 카테고리의 다른 글
[Linux]Another app is currently holding the yum lock; waiting for it to exit... (0) | 2022.02.09 |
---|---|
[Linux]Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist (0) | 2022.02.05 |
[리눅스]01. 22 교육 정리 (0) | 2022.01.23 |
[리눅스]01. 15 교육 정리 (0) | 2022.01.16 |
[리눅스]01. 08 교육 정리 (0) | 2022.01.08 |