Linux: poweroff command to poweroff linux/Unix machine

To ‘poweroff’ the liux /Unix machine ,you can use  poweroff command as a root . There are many options used with poweroff command. With the help of these options we can halt,reboot and poweroff the linux machine.

 

==>If you want to Force immediate halt/power-off/reboot the linux / Unix machine ,you can use  ‘-f’ or ,’ –force ‘ option with ‘poweroff’ command.

[root@localhost ~]# poweroff -f

Powering off.

==>If you want to Only write wtmp shutdown entry in /var/log/wtmp, do not actually halt, power-off, reboot the linux machine, you acn use ‘-w ‘or ‘ –wtmp-only’ option with poweroff command.

[root@localhost ~]# poweroff -w
[root@localhost ~]#

==>If you don’t write wtmp record in /var/log/wtmp ,you can use ‘ -d’ or ‘–no-wtmp ‘ option with poweroff command.

[root@localhost ~]# poweroff –no-wtmp

==>If you don’t send wall message before halt/power-off/reboot,you can use poweroff command witn ‘–no-wall  ‘ option.

root@localhost ~]# poweroff –no-wall ” please save your work system reboot now”

All command line options  used with the ‘ poweroff ‘ command are shown below

______________________________________________________________________________

Options                                                  Description

_______________________________________________________________________________

–halt                                         Halt the machine
-p    –poweroff                        Switch off the machine
–reboot                                     Reboot the machine
-f –force                                    Force immediate halt/power-off/reboot
-w –wtmp-only                          Don’t halt/power-off/reboot, just write wtmp record
-d –no-wtmp                             Don’t write wtmp record
–no-wall                                    Don’t send wall message before halt/power-off/reboot

_______________________________________________________________________________

Linux: halt command to halt the linux server

To halt the liux /Unix machine ,you can use  halt command as a root . There are many options used with halt command. With the help of these options we can halt,reboot and poweroff the linux machine.

==>If you want to poweroff the linux / Unix machine with halt command ,you acn use ‘-p ‘ or ‘–poweroff’ option.

[root@localhost ~]# halt –poweroff

==>If you want to Force immediate halt/power-off/reboot the linux / Unix machine ,you can use  ‘-f’ or ,’ –force ‘ option with ‘halt’ command.

[root@localhost ~]# halt -f

Halting.

==>If you want to Only write wtmp shutdown entry in /var/log/wtmp, do not actually halt, power-off, reboot the linux machine, you acn use ‘-w ‘or ‘ –wtmp-only’ option with halt command.

[root@localhost ~]# halt -w
[root@localhost ~]#

==>If you don’t write wtmp record in /var/log/wtmp ,you can use ‘ -d’ or ‘–no-wtmp ‘ option with halt command.

[root@localhost ~]# halt –no-wtmp

==>If you don’t send wall message before halt/power-off/reboot,you can use halt command witn ‘–no-wall  ‘ option.

root@localhost ~]# halt –no-wall ” please save your work system reboot now”

All command line options  used with the ‘ halt ‘ command are shown below

______________________________________________________________________________

Options                                                  Description

_______________________________________________________________________________

–halt                                         Halt the machine
-p    –poweroff                        Switch off the machine
–reboot                                     Reboot the machine
-f –force                                    Force immediate halt/power-off/reboot
-w –wtmp-only                          Don’t halt/power-off/reboot, just write wtmp record
-d –no-wtmp                             Don’t write wtmp record
–no-wall                                    Don’t send wall message before halt/power-off/reboot

_______________________________________________________________________________

reboot: command to reboot a Linux/Unix machine

To restart liux /Unix machine ,you can use reboot command as a root . There are many options used with reboot command. With the help of these options we can halt,reboot and poweroff the linux machine.

==>If you want to halt the linux /Unix machine , you can use ‘–halt’ option with reboot command .

[root@localhost ~]# reboot –halt

==>If you want to poweroff the linux / Unix machine with reboot command ,you acn use ‘-p ‘ or ‘–poweroff’ option.

[root@localhost ~]# reboot –poweroff

==>If you want to Force immediate halt/power-off/reboot the linux / Unix machine ,you can use  ‘-f’ or ,’ –force ‘ option with reboot command.

[root@localhost ~]# reboot -f

Rebooting.

==>If you want to Only write wtmp shutdown entry in /var/log/wtmp, do not actually halt, power-off, reboot the linux machine, you acn use ‘-w ‘or ‘ –wtmp-only’ option with reboot command.

[root@localhost ~]# reboot -w
[root@localhost ~]#

==>If you don’t write wtmp record in /var/log/wtmp ,you can use ‘ -d’ or ‘–no-wtmp ‘ option with reboot command.

[root@localhost ~]# reboot –no-wtmp

==>If you don’t send wall message before halt/power-off/reboot,you can use reboot command witn ‘–no-wall  ‘ option.

root@localhost ~]# reboot –no-wall ” please save your work system reboot now”

All command line options  used with the ‘ reboot ‘ command are shown below

______________________________________________________________________________

Options                                                  Description

_______________________________________________________________________________

–halt                                         Halt the machine
-p    –poweroff                        Switch off the machine
–reboot                                     Reboot the machine
-f –force                                    Force immediate halt/power-off/reboot
-w –wtmp-only                          Don’t halt/power-off/reboot, just write wtmp record
-d –no-wtmp                             Don’t write wtmp record
–no-wall                                    Don’t send wall message before halt/power-off/reboot

_______________________________________________________________________________

shutdown: command to shutdown a Linux/ Unix machine

The shutdown command used to root privilege to perform the shutdown a linux / Unix machine, it supports a time argument. This is generally used for scheduled maintenance and give more time for users to react on the warning when a system shutdown has been scheduled .

There are many options used with shutdown command. With the help of these options we are halt,reboot and poweroff the linux machine.

==>If you want to shutdowna linux machine  immediatly

[root@localhost ~]# shutdown -h now

Note: The now keyword is an alias for + 0

==> To Halt the linux machine with ‘shutdown’ command ,you can use ‘ shutdown ‘ command with ‘ -H’ or ‘ –halt ‘ option.

[root@localhost ~]#  shutdown -H
Shutdown scheduled for Tue 2018-01-09 12:11:13 IST, use ‘shutdown -c’ to cancel.
[root@localhost ~]#
Broadcast message from root@localhost.localadmin (Tue 2018-01-09 12:10:13 IST):

The system is going down for system halt at Tue 2018-01-09 12:11:13 IST!

[root@localhost ~]#

==>If you want to poweroff a Linux / Unix machine with a specific time , you can use ‘shutdown ‘ command with ‘ -P ‘ or ‘ –poweroff ‘ option.

[root@localhost ~]# shutdown -P +10 ” The system is shutdown after 10 minute due to hardware replace “
Shutdown scheduled for Thu 2018-01-04 12:27:43 IST, use ‘shutdown -c’ to cancel.
[root@localhost ~]#
Broadcast message from root@localhost.localadmin (Thu 2018-01-04 12:17:43 IST):

The system is shutdown after 10 minute due to hardware replace
The system is going down for power-off at Thu 2018-01-04 12:27:43 IST!

[root@localhost ~]# 

==>If you want to reboot a linux machine with ‘ shutdown’ command , you can use ‘ shutdown ‘ command with ‘-r ‘ or ‘ –reboot ‘ option.

[root@localhost ~]# shutdown -r
Shutdown scheduled for Tue 2018-01-09 12:45:34 IST, use ‘shutdown -c’ to cancel.
[root@localhost ~]#
Broadcast message from root@localhost.localadmin (Tue 2018-01-09 12:44:34 IST):

The system is going down for reboot at Tue 2018-01-09 12:45:34 IST!

[root@localhost ~]# 

==>If you don’t want to halt/power-off/reboot the linux machine only send warning  message to logged in users , you can use ‘ k’ option with shutdown command .

[root@localhost ~]# shutdown -k +10 ” please save your work system shutdown after 10 minute”
Shutdown scheduled for Tue 2018-01-09 13:09:00 IST, use ‘shutdown -c’ to cancel.
[root@localhost ~]#
Broadcast message from root@localhost.localadmin (Tue 2018-01-09 12:59:00 IST):

please save your work system shutdown after 10 minute
The system is going down for power-off at Tue 2018-01-09 13:09:00 IST!

[root@localhost ~]# 

==>If you don’t send wall message before halt/power-off/reboot, you can use shutdown command with ‘ –no-wall ‘ option

[root@localhost ~]# shutdown –no-wall +10 “shutdown your system after 10 minutes.”
Shutdown scheduled for Tue 2018-01-09 14:29:02 IST, use ‘shutdown -c’ to cancel.
[root@localhost ~]#

==>If you want to cancel Linux / Unix pending shutdown  , you can use ‘ shutdown ‘ command with ‘ -c ‘ option .

[root@localhost ~]# shutdown -c

Broadcast message from root@localhost.localadmin (Tue 2018-01-09 14:19:37 IST):

The system shutdown has been cancelled at Tue 2018-01-09 14:20:37 IST!

[root@localhost ~]#

All command line options  used with the ‘ shutdown ‘ command are shown below

______________________________________________________________________________

Options                                                  Description

_______________________________________________________________________________
-H –halt                                       Halt the machine
-P –poweroff                              Power-off the machine
-r –reboot                                   Reboot the machine
-h                                                Equivalent to –poweroff, overridden by –halt
-k                                                Don’t halt/power-off/reboot, just send warnings
–no-wall                                     Don’t send wall message before halt/power-off/reboot
-c                                                Cancel a pending shutdown

________________________________________________________________________________

How to shutdown/poweroff a Linux / Unix machine via command line

To shutdown the Linux machine you can use  the  shutdown, halt, Poweroff  and reboot command as a root. There are many way to shudown a Linux / Unix machine via command line shown bellow.

To poweroff a linux machine with ‘ reboot ‘ command ,you can use ‘ reboot ‘ command ‘ -P’ or ‘ –poweroff’ option .

[root@localhost ~]# reboot -P

To poweroff a linux machine with ‘ halt ‘command ,you can use ‘ halt ‘ command ‘ -P’ or ‘ –poweroff’ option .

[root@localhost ~]# halt -P

To shutdowna linux machine  immediatly

[root@localhost ~]# shutdown -h now

OR

[root@localhost ~]# poweroff

OR

[root@localhost ~]# shutdown
Shutdown scheduled for Thu 2018-01-04 13:17:12 IST, use ‘shutdown -c’ to cancel.
[root@localhost ~]#
Broadcast message from root@localhost.localadmin (Thu 2018-01-04 13:16:12 IST):

The system is going down for power-off at Thu 2018-01-04 13:17:12 IST![root@localhost ~]#

If you want to shutdown a Linux / Unix machine with a specific time , you can use ‘shutdown ‘ command with ‘ -P ‘ or ‘ –poweroff ‘ option.

Syntax:  shutdown [OPTIONS] [TIME in 24 Howr format] [Wall Message]

[root@localhost ~]# shutdown -P +10 ” The system is shutdown after 10 minute due to hardware replace “
Shutdown scheduled for Thu 2018-01-04 12:27:43 IST, use ‘shutdown -c’ to cancel.
[root@localhost ~]#
Broadcast message from root@localhost.localadmin (Thu 2018-01-04 12:17:43 IST):

The system is shutdown after 10 minute due to hardware replace
The system is going down for power-off at Thu 2018-01-04 12:27:43 IST!

[root@localhost ~]# 

OR

[root@localhost ~]# shutdown -h +10 ” The system is shutdown after 10 minute due to hardware replace “
Shutdown scheduled for Thu 2018-01-04 12:42:23 IST, use ‘shutdown -c’ to cancel.
[root@localhost ~]#
Broadcast message from root@localhost.localadmin (Thu 2018-01-04 12:32:23 IST):

The system is shutdown after 10 minute due to hardware replace
The system is going down for power-off at Thu 2018-01-04 12:42:23 IST!

[root@localhost ~]# 

How to fix an error “At least xMB more space needed on the /boot filesystem. “

Transaction check error:
installing package kernel-3.10.0-693.11.1.el7.x86_64 needs 232KB on the /boot filesystem

Error Summary
————-
Disk Requirements:
At least 1MB more space needed on the /boot filesystem

When this error has been coming we first check the free space in /boot partition

[root@localhost ~]# df -kh
Filesystem            Size           Used            Avail              Use%                 Mounted on
/dev/sda3               18G           7.2G             11G                  41%                            /
devtmpfs               348M         0                   348M               0%                             /dev   
tmpfs                      363M         0                  363M                0%                             /dev/shm
tmpfs                      363M        15M              348M                5%                             /run
tmpfs                      363M         0                   363M                0%                             /sys/fs/cgroup
/dev/sda1               297M         267M            31M                 90%                            /boot
tmpfs                      73M           12K              73M                   1%                             /run/user/42
tmpfs                       73M          0                    73M                  0%                             /run/user/0

/boot partition is 90 % full. Now you check installed kernel 

[root@localhost ~]# rpm -qa | grep kernel

kernel-devel-3.10.0-514.6.1.el7.x86_64
kernel-3.10.0-693.5.2.el7.x86_64
kernel-devel-3.10.0-514.16.1.el7.x86_64
kernel-tools-3.10.0-693.5.2.el7.x86_64
kernel-headers-3.10.0-693.5.2.el7.x86_64
kernel-devel-3.10.0-514.2.2.el7.x86_64
kernel-3.10.0-514.10.2.el7.x86_64
kernel-tools-libs-3.10.0-693.5.2.el7.x86_64
kernel-3.10.0-514.2.2.el7.x86_64
kernel-3.10.0-514.16.1.el7.x86_64
abrt-addon-kerneloops-2.1.11-48.el7.centos.x86_64
kernel-devel-3.10.0-693.5.2.el7.x86_64
kernel-devel-3.10.0-514.10.2.el7.x86_64
[root@localhost ~]#

Display current kernel running on the machine use the following command

[root@localhost ~]# uname -r
3.10.0-693.5.2.el7.x86_64

So remove the 2 oldest kernel

[root@localhost ~]# rpm -e kernel-3.10.0-514.2.2.el7.x86_64

[root@localhost ~]# rpm -e kernel-3.10.0-514.16.1.el7.x86_64

Check the free space in /boot partition

[root@localhost ~]# df -kh
Filesystem            Size           Used            Avail              Use%                 Mounted on
/dev/sda3               18G           7.2G             11G                  41%                            /
devtmpfs               348M         0                   348M               0%                             /dev   
tmpfs                      363M         0                  363M                0%                             /dev/shm
tmpfs                      363M        15M              348M                5%                             /run
tmpfs                      363M         0                   363M                0%                             /sys/fs/cgroup
/dev/sda1               297M         164M            133M                56%                            /boot
tmpfs                      73M           12K              73M                   1%                             /run/user/42
tmpfs                       73M          0                    73M                  0%                             /run/user/0

As you can see freed space more  from required amount of space. So now you can update kernel freely with “yum -y update kernel “command.