Envoyez la commande d'arrêt via le bouton d'alimentation
Attention
Cet article a été publié il y a plus d'un an, il peut y avoir des développements été.
S'il vous plaît prendre en compte.
Aujourd'hui, nous voyons comment éteindre physiquement un ordinateur avec Debian sans lancer le “éteindre” ligne de commande ou interaction GUI. L'activation de cette fonction peut être utile si nous opérons sur un serveur sans tête (un serveur domestique par exemple) auquel aucun périphérique n'est connecté. Sans avoir à se connecter via SSH ou à ouvrir l'interface de gestion du serveur, appuyez simplement sur le bouton d'alimentation pour envoyer la commande d'arrêt.
Le fichier de configuration de ces comportements est /etc/systemd/logind.conf
. C'est un fichier système et doit être modifié avec les privilèges root. À l'intérieur, nous trouvons ce contenu:
# 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 by creating "drop-ins" in
# the logind.conf.d/ subdirectory. The latter is generally recommended.
# Defaults can be restored by simply deleting this file and all drop-ins.
#
# 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
j'ai décommenté la ligne HandlePowerKey=poweroff
activer la fonction que nous recherchons. Une fois le fichier enregistré, il ne sera pas nécessaire de redémarrer les services. Nous pouvons l'essayer directement en appuyant sur le bouton d'alimentation.
0 commentaires