LFCS 필수 명령·서비스 단계별 실전
systemd directive, Git, 서비스·성능·디스크 진단과 SSL 인증서를 영어 문제부터 검증까지 연습
실제 시험문항이 아니다. custom systemd service의 기본 동작은 Rocky Linux 10.2에서 확인했으며, 나머지는 폐기 가능한 실습 환경에서 수행한다.
작성·검증 상태: AI가 영문 task·힌트·풀이의 구조화를 보조했다. 실제 검증 범위는 위 문장과 문제별 검증 절차를 따른다.
이 문서로 연습하는 법
각 문제는 처음에는 English와 한국어만 읽고 시도한다. 3분 안에 시작 명령이 떠오르지 않으면 연결표를 보고, 그래도 막히면 접힌 답안을 연다. 답안을 본 문제는 끝난 것이 아니라 값과 조건을 바꿔 다시 풀어야 한다.
| 모르는 것 | 시험 중 찾는 곳 |
|---|---|
| systemd directive 이름 | man systemd.directives, man systemd.service, man systemd.unit |
| unit의 실제 구성 | systemctl cat NAME, systemctl show NAME |
| 명령 option | COMMAND --help, man COMMAND |
| 실패 원인 | systemctl status, journalctl -u, 서비스별 문법 검사 |
명령 전체를 외우기보다 요구사항 → 도구 연결은 기억하고 정확한 option은 매뉴얼에서 확인한다.
문제 1 — 조건이 섞인 custom service
English
Create exam-worker.service that runs /usr/bin/sleep 600 as user nobody. Start it after network-online.target. If it exits unexpectedly, restart it after 5 seconds. Start it now and automatically at normal multi-user boot.
한국어
nobody로 명령을 실행하고, network-online 뒤에 시작하며, 비정상 종료 시 5초 후 재시작한다. 지금 실행하고 일반 다중 사용자 부팅에서도 자동 시작한다.
directive 분류
| 요구 | directive | section |
|---|---|---|
| 설명·순서 | Description=, After= | [Unit] |
| 실행 사용자·명령 | User=, ExecStart= | [Service] |
| 실패 재시작·대기 | Restart=, RestartSec= | [Service] |
| enable 대상 | WantedBy= | [Install] |
After=는 순서만 지정한다. network-online.target도 함께 끌어와야 한다는 요구가 있을 때만 Wants=를 추가한다.
풀이 예시
[Unit]
Description=Exam worker
After=network-online.target
[Service]
Type=simple
User=nobody
ExecStart=/usr/bin/sleep 600
Restart=on-failure
RestartSec=5s
[Install]
WantedBy=multi-user.target
systemd-analyze verify /etc/systemd/system/exam-worker.service
systemctl daemon-reload
systemctl enable --now exam-worker.service
systemctl is-enabled exam-worker.service
systemctl is-active exam-worker.service
systemctl show exam-worker.service -p User -p MainPID -p RestartUSec
journalctl -u exam-worker.service -n 10 --no-pager
대소문자는 정확해야 한다. type, Execstart가 아니라 Type, ExecStart다. enable은 다음 부팅 등록이고 enable --now가 등록과 현재 시작을 함께 수행한다.
문제 2 — Git에서 특정 파일만 기록
English
In /srv/config-repo, commit only service.conf on a new branch named feature/timeout. Do not include notes.tmp. Merge the branch into main and show the recent graph.
한국어
새 branch에서 service.conf만 commit하고 notes.tmp는 포함하지 않는다. 완료한 branch를 main에 병합한 뒤 최근 이력을 graph로 확인한다.
연결표
상태 확인 → branch 생성 → 특정 파일 stage → staged diff 검증
→ commit → main 복귀 → merge → history 확인
풀이 예시
cd /srv/config-repo
git status
git switch -c feature/timeout
git add service.conf
git diff --cached
git commit -m 'Adjust service timeout'
git switch main
git merge feature/timeout
git status
git log --oneline --graph -5
git add .는 제외해야 할 파일까지 포함할 수 있으므로 사용하지 않는다.
문제 3 — 실패한 service와 process 진단
English
Identify why report.service is failing. Do not replace its unit file. Correct only the configuration error, start it, and provide evidence from status and logs.
한국어
unit 파일을 새로 덮어쓰지 말고 report.service가 실패하는 실제 원인을 찾아 해당 설정만 고친다. 정상 실행 상태와 로그를 증거로 남긴다.
가이드
systemctl status report.service --no-pager
systemctl cat report.service
systemctl show report.service -p FragmentPath -p User -p ExecStart
journalctl -u report.service -n 50 --no-pager
문제 원인이 unit 문법, 실행 파일, 권한, 사용자, 환경파일, 포트 충돌 중 어디인지 먼저 분류한다. 설정 파일을 고친 뒤 해당 서비스가 제공하는 문법 검사기가 있으면 먼저 실행하고 restart한다.
진단형 답안 순서
systemctl status report.service --no-pager -l
journalctl -u report.service -b -n 50 --no-pager
systemctl cat report.service
systemctl show report.service \
-p FragmentPath -p DropInPaths -p User -p ExecStart -p EnvironmentFiles
# 로그가 가리킨 대상만 확인한다.
namei -l /문제가/된/경로
ss -lntp
# unit 자체를 수정했다면
systemd-analyze verify /etc/systemd/system/report.service
systemctl daemon-reload
# 애플리케이션 설정을 수정했다면 해당 문법 검사 후
systemctl restart report.service
systemctl is-active report.service
journalctl -u report.service -b -n 20 --no-pager
정답은 하나의 고정 명령이 아니라 첫 오류 메시지와 실제 상태가 일치하는 원인 하나를 최소 수정하는 것이다. daemon-reload는 unit을 바꿨을 때만 필요하며 애플리케이션 설정만 고쳤다면 보통 필요 없다.
문제 4 — 디스크 공간 원인 구분
English
/var is reported full. Without deleting data, determine whether block space, inode exhaustion, a large directory, or a deleted-but-open file is responsible.
한국어
데이터를 삭제하지 않고 /var 문제를 block 용량, inode 고갈, 큰 디렉터리, 삭제됐지만 열린 파일 중 하나로 분류한다.
진단 순서
findmnt /var
df -hT /var
df -i /var
du -xhd1 /var | sort -h
lsof -a +L1 /var
df와 du 차이가 크면 삭제됐지만 process가 계속 열고 있는 파일을 의심한다. 문제에서 삭제를 요구하지 않았다면 진단만 하고 임의로 로그를 지우지 않는다.
검증 결과는 다음처럼 판정한다.
| 증거 | 결론 |
|---|---|
df -h만 100% | block 공간 고갈 |
df -i가 100% | 작은 파일이 너무 많아 inode 고갈 |
du의 특정 경로가 큼 | 해당 directory가 주요 사용처 |
df는 큰데 du 합계가 작고 lsof +L1 발견 | 삭제됐지만 process가 열린 file 유지 |
문제 5 — 서비스 제약 조건
English
Determine why an application cannot bind to TCP port 8443 and why its service account cannot write to /srv/app. Preserve SELinux enforcing mode.
한국어
애플리케이션의 8443/tcp bind 실패와 /srv/app 쓰기 실패를 각각 진단한다. SELinux enforcing은 유지하고 증거가 있는 제약만 수정한다.
확인 층
ss -lntp
namei -l /srv/app
getfacl -p /srv/app
getenforce
ls -ldZ /srv/app
ausearch -m AVC -ts recent
포트 점유, Unix permission·ACL, SELinux를 한꺼번에 바꾸지 말고 어느 층에서 거부되는지 증거를 찾는다.
판정과 최소 수정 예시
systemctl show app.service -p User -p Group -p ExecStart
ss -lntp '( sport = :8443 )'
namei -l /srv/app
getfacl -p /srv/app
getenforce
ls -ldZ /srv/app
ausearch -m AVC -ts recent
- 다른 process가
8443을 점유했다면 어떤 서비스인지 확인하고 문제에서 허용한 쪽의 port만 변경한다. - Unix 권한이 원인이면 service user 또는 그 group에 필요한 최소
rwx만 준다. - AVC가 원인이면 경로에는
semanage fcontext와restorecon, 비표준 HTTP port에는semanage port처럼 해당 원인에 맞는 영구 정책을 사용한다.
systemctl restart app.service
systemctl is-active app.service
ss -lntp '( sport = :8443 )'
runuser -u <SERVICE_USER> -- test -w /srv/app
문제 6 — SSL key와 CSR 검증
English
Create a private key and CSR for app.example.test with SAN DNS:app.example.test. Protect the private key with mode 0600 and verify that the CSR contains the requested subject and SAN.
한국어
CN과 SAN이 app.example.test인 private key와 CSR을 만들고, key 권한을 0600으로 제한한 뒤 CSR 내용을 직접 검증한다.
풀이 예시
install -d -m 700 /root/lfcs-cert
openssl req -new -newkey rsa:2048 -nodes \
-keyout /root/lfcs-cert/app.example.test.key \
-out /root/lfcs-cert/app.example.test.csr \
-subj '/CN=app.example.test' \
-addext 'subjectAltName=DNS:app.example.test'
chmod 600 /root/lfcs-cert/app.example.test.key
openssl req -in /root/lfcs-cert/app.example.test.csr -noout -text
stat -c '%a %n' /root/lfcs-cert/app.example.test.key
조건 변형 대비
| 원문 표현이 바뀌면 | 바뀌는 선택 |
|---|---|
| start before another unit | [Unit]의 Before= |
| restart always, not only on failure | [Service]의 Restart=always |
| start at boot but not now | systemctl enable만 사용 |
| start now but not at boot | systemctl start만 사용 |
| add all tracked Git changes | git add -u 또는 명시된 범위 사용, untracked 포함 여부 확인 |
| certificate 자체를 확인 | openssl x509 -in FILE -noout -text |
| CSR을 확인 | openssl req -in FILE -noout -text |
문장의 숫자·사용자·경로·재시작 조건은 바뀔 수 있다. 구조를 외우고 값은 문제에서 그대로 옮긴다.
자가 채점
- systemd section과 directive 대소문자를 정확히 구분한다.
-
enable과start,After와Wants의 차이를 설명한다. - Git에서 요구된 파일만 stage했다.
- 서비스 실패를 status·journal·구성 문법 순으로 좁혔다.
- 디스크 공간 문제에서 block과 inode를 모두 확인했다.
- SSL private key 권한과 CSR SAN을 검증했다.