#7z 파일 압축 해제
7z x 파일명.7z
#특정 폴더에 압축 해제
7z x 파일명.7z -o/경로/디렉토리
#압축 해제 시 기존 파일 덮어쓰기 없이 진행
7z x 파일명.7z -o/경로/디렉토리 -aos
#암호가 걸린 7z 파일 압축 해제방법
7z x 파일명.7z -p비밀번호
# 압축된 파일 내부 목록 확인
7z l 파일명.7z
에러발생시 팩키지 설치 필요
Last metadata expiration check: 3:26:19 ago on Mon Feb 24 17:53:46 2025. No match for argument: p7zip No match for argument: p7zip-plugins Error: Unable to find a match: p7zip p7zip-plugins
#기본 7z 압축 방법
#7z a 압축파일명.7z 파일명
7z a archive.7z myfile.txt
#여러 개의 파일을 압축
#7z a archive.7z 파일1 파일2 디렉토리
7z a mydata.7z file1.txt file2.txt folder1/
#특정 확장자의 파일만 압축
7z a archive.7z *.txt
#암호 설정 압축
#7z a -p비밀번호 archive.7z 파일명
7z a -p1234 secret.7z confidential.txt
Rocky Linux 환경에서는 Centos 에서 지원하는 rdate 를 더이상 지원하지 않는다
Rokcy Lunux 에서 시간을 변경하는 방법으로 timedatectl 명령을 사용하여 시간을 변경할수 있다
timedatectl 명령을 통해 현재 서버의 날짜와 시간을 변경하는 방법에 대해 알아보겠습니다.
timedatectl 설명
현재시간을 확인하고 임으로 날짜 및 변경하는 방법은 아래 작성한 내용과 같다.
단 임으로 시간 병경후 NTP 동기화 설정시 바로 현재 시간으로 동기화 되지 않는 이유는
NTP 가 시간이 일정 간격으로 서서히 조정되도록 설계 되어 있어 바로 현재 시간이 적용 되지 않는다고 한다.
바로 현재 시간으로 동기화를 하기 위해서는 chrony 나 ntpd(Rocky Linux 에서는 지원하지 않음) 를 이용해서 현재 시간으로 업데이트 할수 있다 .
timedatectl 기능
#현재 시간 확인 하기
timedatectl
#시간대 설정방법 (ex: 서울):
timedatectl set-timezone Asia/Seoul
#직접 날짜와 시간 설정 하기
#timedatectl set-time 'YYYY-MM-DD HH:MM:SS'
timedatectl set-time '2024-11-10 15:30:00'
#NTP(Network Time Protocol) 동기화 활성화
timedatectl set-ntp true
#timedatectl set-ntp false
chrony 사용법
설치 및 서비스 시작 방법
#설치
dnf install chrony
#서비스 시작
systemctl enable --now chronyd
#서버시간 즉시 시간 동기화
chronyc -a makestep
시간 변경 방법
ntp 동기화 설정이 되어있다면 임으로 시간 변경을 할수 없다 .
Failed to set time: Automatic time synchronization is enabled 발생
timedatectl set-ntp false 를 통해 ntp 동기화 설정을 꺼두고 시간 변경이 완료 된후 현재 시간으로
시간으로 동기화 하고 싶다면 timedatectl set-ntp true 이후 chronyc 서비스를 활성화 시키면 된다.
[root@rocky9.4:/root]$ date Tue Nov 12 13:43:48 KST 2024 [root@rocky9.4:/root]$ timedatectl set-time '2023-11-10 15:30:00' Failed to set time: Automatic time synchronization is enabled [root@rocky9.4:/root]$ timedatectl set-ntp false [root@rocky9.4:/root]$ timedatectl set-time '2023-11-10 15:30:00' [root@rocky9.4:/root]$ date Fri Nov 10 15:30:01 KST 2023 [root@rocky9.4:/root]$ timedatectl set-ntp true [root@rocky9.4:/root]$ date Fri Nov 10 15:30:06 KST 2023 [root@rocky9.4:/root]$ chronyc -a makestep 200 OK [root@rocky9.4:/root]$ date Fri Nov 10 15:30:10 KST 2023 [root@rocky9.4:/root]$ systemctl enable --now chronyd [root@rocky9.4:/root]$ date Tue Nov 12 13:44:20 KST 2024 [root@rocky9.4:/root]$
#방화벽 중지
systemctl stop firewalld.service
#방화벽 영구 비활성화
systemctl disable firewalld.service
#방화벽 상태 확인
status firewalld
#방화벽 활성화
#systemctl start firewalld.service
curl은 Linux, Unix, Windows 등 다양한 운영 체제에서 사용 가능한 명령줄 도구로, URL을 통해 데이터를 전송하거나 다운로드하는 데 사용됩니다. HTTP, HTTPS, FTP, FTPS, SCP, SFTP, LDAP, POP3, IMAP, SMTP 등 다양한 프로토콜을 지원 한다.
Crul 주요 기능
웹 요청 및 응답 처리: 웹 서버에 요청을 보내고 응답 테스트를 진행 할때 사용 한다.
파일 다운로드 및 업로드: curl을 사용해 원격 서버에서 파일을 다운로드하거나, 서버로 파일을 Upload 시킬수 있다.
부팅시 Failed to load SELinux policy, freezing. 에러 발생
/etc/selinux/config 파일을 수정이후 부팅이 실패 할 경우
[root@centos7:/root]$ cat /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - SELinux is fully disabled.
SELINUX=enforcing
# SELINUXTYPE= type of policy in use. Possible values are:
# targeted - Only targeted network daemons are protected.
# strict - Full SELinux protection.
SELINUXTYPE=targeted
[root@centos7:/root]$
부팅 화면에서 키보드 e 를 누르고
selinux=0 추가 후 재부팅
Ctrl + x 를 누르면 다시 부팅이 된다.
SELinux 란?
SELinux(보안 강화 리눅스)는 리눅스 운영 체제의 보안 기능 중 하나로, 프로세스, 파일 및 네트워크에 대한 접근을 제어하는 매커니즘입니다. SELinux는 NSA(미국 국가 안보국)와 레드햇이 공동으로 개발한 프로젝트로, 리눅스 커널에 포함되어 있습니다.
/etc/selinux/config 파라미터 설명
enforcing 모드: 모든 SELinux 정책이 적용되고 보안 위반이 감지되면 해당 작업이 차단됩니다.
NFS(Network File System)는 여러 컴퓨터 간에 파일을 공유하기 위한 분산 파일 시스템 프로토콜입니다. NFS는 클라이언트-서버 모델을 기반으로 하며, 클라이언트는 네트워크를 통해 NFS 서버의 파일 시스템에 액세스할 수 있습니다. 이를 통해 여러 사용자가 동일한 파일이나 디렉터리를 공유하고, 파일 시스템 자원을 효율적으로 활용할 수 있습니다.
NFS 동작 원리
서버 설정: 먼저 파일을 공유할 서버에서 NFS를 설정해야 합니다. 서버의 파일 시스템 중 NFS로 공유하고자 하는 디렉터리를 선택하고, 이 디렉터리를 /etc/exports와 같은 설정 파일에 등록합니다. 이 설정 파일은 클라이언트에게 공유 디렉터리의 경로와 액세스 권한을 제공합니다.
클라이언트 마운트: NFS 클라이언트에서는 NFS 서버의 공유 디렉터리를 마운트하여 사용할 수 있습니다. 클라이언트에서는 NFS 마운트 포인트를 생성하고, 이를 통해 서버의 공유된 디렉터리에 액세스할 수 있습니다.
NFS 동작 원리
파일 공유: NFS는 여러 사용자가 동일한 파일이나 디렉터리를 공유할 수 있도록 합니다. 이를 통해 여러 사용자가 동일한 파일에 접근하여 작업할 수 있습니다.
중앙 관리: NFS를 사용하면 파일이 중앙 서버에 저장되므로 관리 및 유지 보수가 간단해집니다. 파일의 한 복사본을 유지하므로 데이터 일관성도 쉽게 유지할 수 있습니다.
데이터 백업: NFS를 사용하여 클라이언트에서 중앙 서버로 데이터를 백업할 수 있습니다. 이를 통해 중앙화된 백업 시스템을 유지하고, 데이터를 보호할 수 있습니다.
클라우드 스토리지: 클라우드 환경에서도 NFS는 파일 공유 및 저장에 널리 사용됩니다. 클라우드에서 NFS를 사용하면 여러 가상 머신 간에 데이터를 공유하고, 파일 시스템을 유연하게 확장할 수 있습니다.
NFS 서버 설치
centos 7.9 환경에서 NFS 설치 하는 방법에 대해 알아보겠습습니다.
nfs 패키지 설치
#설치 유무 확인
rpm -qa | grep nfs-utils
#nfs 팩키지 설치
yum install nfs-utils
--- Logical volume --- LV Path /dev/centos/swap LV Name swap VG Name centos LV UUID cwMNqw-gJSs-7nDO-GrRU-bgxE-FLB5-7acfhK LV Write Access read/write LV Creation host, time localhost, 2023-03-09 07:40:48 +0900 LV Status available # open 2 LV Size 8.00 GiB Current LE 2048 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:1
--- Logical volume --- LV Path /dev/centos/root LV Name root VG Name centos LV UUID kRPPw7-Ffr2-Bf20-CsE9-UDkt-aCdO-Y4DvFo LV Write Access read/write LV Creation host, time localhost, 2023-03-09 07:40:48 +0900 LV Status available # open 1 LV Size <6.00 GiB Current LE 1535 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:0
디스크 추가
fdisk -l 을 통해 추가한 disk 정보를 확인 합니다.
용량 증설을 위해 hdd 를 20G 추가 했습니다.
추가한 디스크에 대해 파티션을 생성 합니다.
fdisk /dev/sdb
[root@mysvr:/root]$ fdisk /dev/sdb Welcome to fdisk (util-linux 2.23.2).
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 Building a new DOS disklabel with disk identifier 0x8135267e.
Command (m for help): n Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): p Partition number (1-4, default 1): 1 First sector (2048-41943039, default 2048): =>엔터 Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039): =>엔터 Using default value 41943039 Partition 1 of type Linux and of size 20 GiB is set
Command (m for help): t Selected partition 1 Hex code (type L to list all codes): 8e Changed type of partition 'Linux' to 'Linux LVM'
Command (m for help): w The partition table has been altered!
Calling ioctl() to re-read partition table. Syncing disks.
파티셔닝한 디스크 /dev/sdb1 를 Physical Volume 생성 한다.
pvscan 이나 pvdisplay 명령을 통해 pysical volume 정보를 확인 한다.
pvcreate /dev/sdb1
pvscan
pvdisplay
vgextend 명령을 통해 centos 볼륨 그룹에 새로 추가한 pysical volume 를 확장 한다.
vgextend centos /dev/sdb1
lvextend 명령을 통해 부족했던 lvm 을 확장 합니다.
lvextend /dev/mapper/centos-root -l +100%FREE
pvscan 명령을 통해 centos 으로 pv 가 추가 되었는지 확인 한다.
xfs_growfs 명령을 통해 논리 볼륨을 resizing 한다.
ext4 포멧일 경울 resize2fs /dev/mapper/centos-root 수행 합니다.
xfs type 에 대해 resize2fs 명령을 수행 하면 아래 처럼 에러가 발생함.
[root@mysvr:/root]$ resize2fs /dev/mapper/centos-root resize2fs 1.42.9 (28-Dec-2013) resize2fs: Bad magic number in super-block while trying to open /dev/mapper/centos-root Couldn't find valid filesystem superblock. [root@mysvr:/root]$ blkid /dev/mapper/centos-root /dev/mapper/centos-root: UUID="f4704f6c-5120-4c0f-b46b-7a0c31f390e5" TYPE="xfs"