IT 공부내용 정리/Linux

터미널 명령어 - shutdown 시스템(컴퓨터)을 종료하고 싶을 때

따뜻한 차가움 2025. 3. 14. 15:32

사용 버전 : Linux 우분투(레드햇 계열) 24.04.01 LTS 버전
사용한 시스템 지역/언어 : 대한민국/한글

man shutdown 원문

더보기

SHUTDOWN(8)                        shutdown                        SHUTDOWN(8)

NAME
       shutdown - Halt, power off or reboot the machine

SYNOPSIS

       shutdown [OPTIONS...] [TIME] [WALL...]

DESCRIPTION
       shutdown may be used to halt, power off, or reboot the machine.

       The first argument may be a time string (which is usually "now").
       Optionally, this may be followed by a wall message to be sent to all
       logged-in users before going down.

       The time string may either be in the format "hh:mm" for hour/minutes
       specifying the time to execute the shutdown at, specified in 24h clock
       format. Alternatively it may be in the syntax "+m" referring to the
       specified number of minutes m from now.  "now" is an alias for "+0",
       i.e. for triggering an immediate shutdown. If no time argument is
       specified, "+1" is implied.

       Note that to specify a wall message you must specify a time argument,
       too.

       If the time argument is used, 5 minutes before the system goes down the
       /run/nologin file is created to ensure that further logins shall not be
       allowed.

OPTIONS
       The following options are understood:

       --help
           Print a short help text and exit.

       -H, --halt
           Halt the machine.

       -P, --poweroff
           Power the machine off (the default).

       -r, --reboot
           Reboot the machine.

       -h
           The same as --poweroff, but does not override the action to take if
           it is "halt". E.g.  shutdown --reboot -h means "poweroff", but
           shutdown --halt -h means "halt".

       -k
           Do not halt, power off, or reboot, but just write the wall message.

       --no-wall
           Do not send wall message before halt, power off, or reboot.

       -c
           Cancel a pending shutdown. This may be used to cancel the effect of
           an invocation of shutdown with a time argument that is not "+0" or
           "now".

       --show
           Show a pending shutdown action and time if there is any.

           Added in version 250.

EXIT STATUS
       On success, 0 is returned, a non-zero failure code otherwise.

COMPATIBILITY
       The
        shutdown command in previous init systems (including sysvinit)
       defaulted to single-user mode instead of powering off the machine. To
       change into single-user mode, use systemctl rescue instead.

SEE ALSO
       systemd(1), systemctl(1), halt(8), wall(1)

systemd 255                                                        SHUTDOWN(8)

 

man shutdown 번역기 번역본

더보기

SHUTDOWN(8)         shutdown        SHUTDOWN(8)

이름
shutdown - 머신을 중지, 전원 끄기 또는 재부팅

요약

shutdown [옵션...] [시간] [벽...]

설명
shutdown은 머신을 중지, 전원 끄기 또는 재부팅하는 데 사용할 수 있습니다.

첫 번째 인수는 시간 문자열(일반적으로 "now")일 수 있습니다.
선택적으로, 이 뒤에 모든 로그인한 사용자에게 다운되기 전에 보낼 벽 메시지가 올 수 있습니다.

시간 문자열은 "hh:mm" 형식(시간/분)일 수 있으며, 24시간 시계 형식으로 지정된 종료를 실행할 시간을 지정합니다.
또는 지금부터 지정된 분 수 m을 나타내는 "+m" 구문일 수 있습니다. "now"는 "+0"의 별칭으로,
즉시 종료를 트리거합니다. 시간 인수가 지정되지 않으면 "+1"이 암시됩니다.

벽 메시지를 지정하려면 시간 인수도 지정해야 합니다.

시간 인수를 사용하는 경우 시스템이 다운되기 5분 전에
/run/nologin 파일이 생성되어 추가 로그인이 허용되지 않습니다.

옵션
다음 옵션을 이해합니다.

--help
짧은 도움말 텍스트를 인쇄하고 종료합니다.

-H, --halt
컴퓨터를 중지합니다.

-P, --poweroff
컴퓨터를 끕니다(기본값).

-r, --reboot
컴퓨터를 재부팅합니다.

-h
--poweroff와 동일하지만 "halt"인 경우 수행할 작업을 재정의하지 않습니다.
예를 들어 shutdown --reboot -h는 "poweroff"를 의미하지만
shutdown --halt -h는 "halt"를 의미합니다.

-k
중지, 전원 끄기 또는 재부팅하지 않고 벽 메시지만 작성합니다.

--no-wall
중지, 전원 끄기 또는 재부팅 전에 벽 메시지를 보내지 않습니다.

-c
보류 중인 종료를 취소합니다. 이것은 "+0" 또는 "now"가 아닌 시간 인수로 shutdown을 호출한 효과를 취소하는 데 사용할 수 있습니다.

--show
보류 중인 종료 작업과 시간이 있으면 표시합니다.

버전 250에서 추가되었습니다.

종료 상태
성공 시 0이 반환되고, 그렇지 않으면 0이 아닌 실패 코드가 반환됩니다.

호환성
이전 init 시스템(sysvinit 포함)의
shutdown 명령은
컴퓨터를 끄는 대신 단일 사용자 모드로 기본 설정되었습니다. 단일 사용자 모드로 변경하려면
대신 systemctl rescue를 사용합니다.

또한 참조
systemd(1), systemctl(1), halt(8), wall(1)

systemd 255 SHUTDOWN(8)

 

형태 : shutdown [옵션] [시간] [메세지]

기능 : 리눅스를 [메세지]를 출력 후 설정한 [시간]에 시스템을 종료한다.

 

[옵션]

-k : 실제로 시스템을 종료하지 않고 사용자에게 메세지만 전달한다.

-r : 종료 후 재시작한다.

-h : 종료후 halt 상태로 이동한다.

-f : 빠른 재시작으로 이 과장에서 fsck를 생략할 수도 있다.

-c : 이전에 내린 shutdown 명령을 취소한다.

 

[시간]

hh:mm : hh시 mm분 00초에

+m : m분 뒤

now : 지금

 

[메세지]

접속중인 사용자에게 보낼 메세지

이 기능은 시스템이 꺼지면서 메세지를 발송할 수 없으므로 now 외 [시간] 인자를 기입해야만 작동하게 된다.

 

GUI 환경에서는 시스템 종료를 할 때 어떻게 하는가? 시작버튼을 누르고 전원을 클릭해서 시스템 종료를 클릭하면 된다.

그렇다면 CLI 환경에서는 어떨까? 시작버튼도 없고 전원버튼도 없다. 시스템을 종료하기 위한 별도의 방안이 필요할 것이다.

 

대부분의 경우 컴퓨터 본체의 전원버튼을 눌러도(한번 누르면 시스템 종료, 길게 누르면 power 단절) 꺼지지만 그런 기능이 없을 수도 있고 시스템 자체적으로 종료 명령을 내리는 것이 더 안전하다.

업무파일 만들고 있는데 누군가 갑자기 회사의 배전반을 내리고는 집 가라고 하는 경우와

팀장이 오늘 작업 종료하고 집에 가자고 말하는 경우를 비교하면 작업자가 더 기분좋을 상황은 후자가 더 나을 것이다.

 

추가로 init나 systemctl 기능으로도 컴퓨터를 종료할 수 있는데

runlevel을 조정하면 동일한 기능을 사용할 수 있다.

 

시스템 종료 : sudo init 0 // sudo systemctl isolate poweroff.target // sudo systemctl isolate runlevel0.target

재부팅 : sudo init 6 // sudo systemctl isolate reboot.target // sudo systemctl isolate runlevel6.target