반응형
우분투 24.04에서 전원 버튼을 비활성화하는 방법
우분투 24.04에서 전원 버튼을 눌러도 시스템이 종료되지 않도록 하려면, systemd-logind 설정을 바꿔서 전원 버튼 입력을 무시(ignore) 하도록 하면 됩니다.
재부팅 원인
journalctl -u systemd-logind
Jul 31 16:42:57 serv-1 systemd-logind[1186]: Power key pressed.
Jul 31 16:42:57 serv-1 systemd-logind[1186]: Powering Off...
Jul 31 16:42:57 serv-1 systemd-logind[1186]: System is powering down.
- 특정 시간대 필터링 (예: 2025-07-31)
journalctl -u systemd-logind --since "2025-07-31" --until "2025-07-31 23:59"
- 로그를 파일로 저장
journalctl -u systemd-logind --since "2025-07-31" > systemd-logind-20250731.log
전원 버튼 무시 설정(옵션)
logind.conf 파일 확인
$ cat /etc/systemd/logind.conf | egrep -v '^#|^$'
[Login]
더보기
---
cat /etc/systemd/logind.conf
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it under the
# terms of the GNU Lesser General Public License as published by the Free
# Software Foundation; either version 2.1 of the License, or (at your option)
# any later version.
#
# Entries in this file show the compile time defaults. Local configuration
# should be created by either modifying this file (or a copy of it placed in
# /etc/ if the original file is shipped in /usr/), or by creating "drop-ins" in
# the /etc/systemd/logind.conf.d/ directory. The latter is generally
# recommended. Defaults can be restored by simply deleting the main
# configuration file and all drop-ins located in /etc/.
#
# Use 'systemd-analyze cat-config systemd/logind.conf' to display the full config.
#
# See logind.conf(5) for details.
[Login]
#NAutoVTs=6
#ReserveVT=6
#KillUserProcesses=no
#KillOnlyUsers=
#KillExcludeUsers=root
#InhibitDelayMaxSec=5
#UserStopDelaySec=10
#HandlePowerKey=poweroff
#HandlePowerKeyLongPress=ignore
#HandleRebootKey=reboot
#HandleRebootKeyLongPress=poweroff
#HandleSuspendKey=suspend
#HandleSuspendKeyLongPress=hibernate
#HandleHibernateKey=hibernate
#HandleHibernateKeyLongPress=ignore
#HandleLidSwitch=suspend
#HandleLidSwitchExternalPower=suspend
#HandleLidSwitchDocked=ignore
#PowerKeyIgnoreInhibited=no
#SuspendKeyIgnoreInhibited=no
#HibernateKeyIgnoreInhibited=no
#LidSwitchIgnoreInhibited=yes
#RebootKeyIgnoreInhibited=no
#HoldoffTimeoutSec=30s
#IdleAction=ignore
#IdleActionSec=30min
#RuntimeDirectorySize=10%
#RuntimeDirectoryInodesMax=
#RemoveIPC=yes
#InhibitorsMax=8192
#SessionsMax=8192
#StopIdleSessionSec=infinity
---
728x90
logind.conf 파일 수정
sudo vim /etc/systemd/logind.conf
아래 항목을 찾아서 주석을 제거하고 ignore로 변경합니다.
[Login]
HandlePowerKey=ignore
옵션 의미
- poweroff (기본값) → 버튼 누르면 종료
- reboot → 버튼 누르면 재부팅
- halt → 버튼 누르면
- halt ignore → 버튼 눌러도 무시
systemd-logind 재시작
sudo systemctl restart systemd-logind
설정 적용 확인
loginctl show-logind | grep HandlePowerKey
HandlePowerKey=ignore
전원 버튼 동작을 무시하게 설정하는 명령어
# 백업 먼저 수행
sudo cp /etc/systemd/logind.conf /etc/systemd/logind.conf.bak.$(date +%F_%T)
# HandlePowerKey 항목이 있으면 수정, 없으면 추가
if grep -q '^#\?\s*HandlePowerKey=' /etc/systemd/logind.conf; then
sudo sed -i 's/^#\?\s*\(HandlePowerKey=\).*/\1ignore/' /etc/systemd/logind.conf
else
echo 'HandlePowerKey=ignore' | sudo tee -a /etc/systemd/logind.conf
fi
# systemd-logind 재시작
sudo systemctl restart systemd-logind
하드웨어에서 전원 끄는 방법
systemd 설정에서 전원 버튼 무시해도 전원 버튼 길게 누르기는 OS 무시하기 때문에 긴급 종료 가능합니다.
참고URL
- 변군이글루 블로그 : CentOS 7에서 전원 버튼을 비활성화하는 방법
728x90
반응형
'리눅스' 카테고리의 다른 글
w 명령어 (0) | 2025.08.01 |
---|---|
우분투 22.04에서 Terraform을 설치하는 방법 (3) | 2025.07.28 |
AVX란? (2) | 2025.07.18 |
PostgreSQL 데이터 초기화 (0) | 2025.07.18 |
도커 컨테이너로 Kafka, ZooKeeper 그리고 Kafdrop을 구성하는 방법 (1) | 2025.07.16 |