[linuxadmin@localhost ~]$ vi hello_old.c
#include <stdio.h>
int main() {
printf("Hello\n");
return 0;
}
[linuxadmin@localhost ~]$ vi hello_new.c
#include <stdio.h>
int main() {
printf("Hello, World!\n");
return 0;
}

패치 파일로 만든다.
[linuxadmin@localhost ~]$ diff -u hello_old.c hello_new.c > myprogram.patch

[linuxadmin@localhost ~]$ sudo dnf -y install gcc
패치 명령어 사용을 위해 패키지 설치
[linuxadmin@localhost ~]$ sudo dnf -y install patch
[linuxadmin@localhost ~]$ patch -p0 < myprogram.patch
- -p0 : 패치 파일 내 파일 경로를 그대로 사용하라는 의미.
- myprogram.patch 내용을 읽어서 패치에 적혀있는 파일 이름을 앞부분을 잘라내지 않고 그대로 현재 위치에서 적용하라는 의미.

'Journey to Security > 리눅스' 카테고리의 다른 글
| 압축/아카이브 관련 명령어 (0) | 2026.03.24 |
|---|---|
| 사용자/그룹/로그인 관련 명령어 (0) | 2026.03.19 |
| 리눅스 기본 명령어 모음 (0) | 2026.03.17 |
| Rocky Linux 서버 IP 설정 (nmtui) (0) | 2026.03.17 |
| 리눅스 스토리지 계층 구조의 이해: 디스크, 파티션, 파일 시스템 (0) | 2026.02.21 |