시스템 모니터링 스크립트를 생성하세요
* systeminfo라는 이름의 스크립트를 생성합니다.
* 스크립트는 /usr/local/bin에 위치해야 합니다.
* 이 스크립트는 현재 시스템 프로세스에 대한 정보를 얻는 데 사용됩니다. 다음 프로세스 정보를 순서대로 출력해야 합니다.
프로세스 소유자
프로세스 PID
가상 메모리 사용량
상주(물리적) 메모리 사용량
CPU 사용률
출력 결과는 CPU 사용률 백분율 순으로 정렬되어야 하며, CPU를 가장 많이 사용하는 프로세스가 마지막에 표시되어야 합니다.
[root@node1 ~]# vim /usr/local/bin/systeminfo
#!/bin/bash
ps -xao user,pid,vsz,rss,%cpu --sort=pcpu
Using sort:
#!/bin/bash
ps -xao user,pid,vsz,rss,%cpu | sort -fnk 5
Verify:
[root@node1 ~]# chmod +x /usr/local/bin/systeminfo
[root@node1 ~]# systeminfo
Explanation of ps -xao:
x - Display processes without a controlling terminal, and show the full path of each command
a - Display all processes associated with a terminal, except session leaders
o - User-defined output format
지원되는 파일 시스템에 대해 주기적인 TRIM 작업을 활성화합니다.
Explanation:
Solution:
systemctl enable --now fstrim.timer
systemctl status fstrim.timer
Detailed Explanation:
* fstrim.timer schedules discard of unused blocks.
* This is useful on SSD-backed storage and thin-provisioned environments.
* RHEL 10 storage documentation explicitly documents enabling fstrim.timer. ( Red Hat Documentation )
아카이브 생성
/root/backup.tar.bz2라는 이름의 tar 아카이브를 생성하십시오. 이 아카이브에는 /usr/local의 내용이 포함되어야 합니다. tar 아카이브는 bzip2를 사용하여 압축해야 합니다.
[root@node1 ~]# yum -y install bzip2
[root@node1 ~]# tar -jcvPf /root/backup.tar.bz2 /usr/local
# Verification
[root@node1 ~]# file /root/backup.tar.bz
네트워크 설정 구성
노드1을 다음 네트워크 설정으로 구성하십시오.
호스트 이름: node1.domain250.example.com
IP 주소: 172.25.250.100
서브넷 마스크: 255.255.255.0
게이트웨이: 172.25.250.254
# Connect to servera via console for IP modification, then check using the ip addr command.
# After confirming no issues, SSH to servera for hostname modification. This way, you can copy the hostname to avoid typos.
[root@clear ~] nmcli con show
[root@clear ~] nmcli con mod 'network configuration name' ipv4.method manual ipv4.addresses 172.25.0.25/24 ipv4.gateway 172.25.0.254 ipv4.dns 172.25.0.254
autoconnect yes
[root@clear ~] nmcli con up 'network configuration name'
[root@clear ~] ip a
[root@clear ~] ssh [email protected]
[root@clear ~] hostnamectl set-hostname red.lab0.example.com
# Verification
[root@node1 ~] ip a //Check if the IP is correct
[root@node1 ~] hostname //Check if the hostname is correct
'해리'라는 사용자를 생성하고, 비밀번호 만료일을 30일로 설정하며, 첫 로그인 시 비밀번호를 강제로 변경하도록 합니다.
Explanation:
Solution:
useradd harry
passwd harry
chage -M 30 -d 0 harry
chage -l harry
Detailed Explanation:
* useradd harry creates the local user.
* passwd harry sets the initial password.
* chage -M 30 sets the maximum password age to 30 days.
* chage -d 0 forces the user to change the password at next login.
* chage -l harry verifies the policy.
사용자 계정 구성
사용자 계정 "manalo"를 사용자 ID 3533으로 구성하십시오. 이 사용자의 비밀번호는 "flectrag"이어야 합니다.
[root@node1 ~]# useradd -u 3533 manalo
[root@node1 ~]# echo flectrag | passwd --stdin manalo
ops라는 이름의 그룹을 생성하고, sara라는 사용자를 생성한 다음, sara를 ops라는 보조 그룹에 추가합니다.
Explanation:
Solution:
groupadd ops
useradd sara
usermod -aG ops sara
id sara
Detailed Explanation:
* groupadd creates the group.
* useradd creates the user.
* usermod -aG adds the user to a supplementary group without removing existing memberships.
* id sara confirms the result.