What is linux command to reboot

How do I shut down or reboot from a terminal?

Appendix: If your keyboard is «locked up», so you can’t enter a command like «reboot» which would run from «su» anyway, use the keyboard: hold down Alt + PrintScreen/SysRq , buttons and type «REISUB». It doesn’t have to be capital letters. It will restart your computer gently. http://blog.kember.net/articles/reisub-the-gentle-linux-restart/

@NicolasRaoul nopes, for me i see this without sudo . Failed to set wall message, ignoring: Interactive authentication required. Failed to reboot system via logind: Interactive authentication required. Failed to open /dev/initctl: Permission denied Failed to talk to init daemon.

Open your terminal with CTRL + ALT + T and do these following commands

& one more command for restart:

Another way as one of the user mentioned.

You can get more info on the shutdown command by using one of the following:

Can anyone explain why sudo halt might not perform shutdown in some cases, whereas sudo halt -p does?

Hate passwords ( sudo ) and love one-liners?

For Ubuntu 15.04 and later

This is due to Ubuntu’s shift in using systemd instead of Upstart

systemctl poweroff systemctl reboot systemctl suspend systemctl hibernate systemctl hybrid-sleep 

Since hibernate is normally disabled by default in Ubuntu systems, you can enable this by checking this answer.

For Ubuntu 14.10 or earlier

/usr/bin/dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Stop 
/usr/bin/dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Restart 

Other commands you may like:

/usr/bin/dbus-send --system --print-reply --dest="org.freedesktop.UPower" /org/freedesktop/UPower org.freedesktop.UPower.Suspend 

Hibernate: (if enabled on your system)

/usr/bin/dbus-send --system --print-reply --dest="org.freedesktop.UPower" /org/freedesktop/UPower org.freedesktop.UPower.Hibernate 

On 16.04 no need of sudo

sudo shutdown -h (time) (message) 

This will shutdown your computer and halt it. That is what the -h is for. Then, in the time area you can choose the shutdown delay (in minutes) and if you want you can send a broadcast message in the message area (like goodbye, or I’m shutting the thing down :P).

Читайте также:  Линукс минт пароль при входе

To restart the computer, type

sudo shutdown -r (time) (message) 

Now, instead of shutting it down and halting it, you will restart your computer once it’s shutdown. 🙂

Источник

What is the Linux Reboot Command?

What is the Linux Reboot Command?

Rebooting is the go-to option that many of us rely on whenever things begin to act weirdly on a computer. Or, it could be the practical approach when new software is installed on the system and it demands a reboot.

Linux offers the reboot command to restart or reboot a system, even over a remote connection. The command is easy to remember as the name itself is literally the function.

All the ways to reboot in Linux

Well, be it shutting down your system forcefully or cleanly and safely rebooting your system, Linux has got you covered in all these situations. It has various commands in its arsenal to cater all your rebooting needs.

Let us look at the various options of commands available with Linux.

All the commands stated above can carry out different actions like shutting down a server, rebooting a system, or halting a system. These commands function in a similar way with some minor differences.

For the purpose of this page though, we’ll be using the reboot command only.

The Linux reboot command

reboot command fits best for your local computer as well as for the remote systems.

General syntax:

Note: Make sure you use ‘ sudo ‘ when using the reboot command. Just using the reboot command alone may not work for most users.

Options available with the reboot command

You can customize the reboot command using the following options to better suit your need to reboot your system.

Options Description
-p power off the machine
—halt halt the machine
-f force for immediate reboot
–wtmp-only only writes wtmp shutdown entry, does noit actually shutdown, or reboot the system

The -p option when used with the reboot command, will power off the machine. This option works in the same way with other commands shutdown , halt and poweroff .

Читайте также:  Linux on android 2020

The -f option forces the system for an immediate reboot. Although this is a forced reboot, it results in the clean shutdown.

The –wtmp-only option allows you to make an entry to the boot log file without actually shutting down or rebooting your system.

All these options can be used with poweroff , halt and shutdown commands as well.

Using reboot command on your system

To start using the reboot command, take a look at the following example to understand the implementation better.

After issuing the sudo reboot command, all the users will be informed that the system is being rebooted. All the processes that are currently running on your system will be notified that the system is going down.

After the reboot command is issued, no further user-logins will be allowed by the system.

You can also use the following command to reboot your system.

Just typing this line on your terminal will immediately reboot your system.

Using reboot command on a remote Linux system

You can reboot a remote Linux system just as easily with the reboot command. Just connect to the remote system over ssh from the terminal on your local system.

General syntax:

ssh root@[remote_server_ip] /sbin/reboot

The command can be understood in pieces. Here I have used the ssh utility to log in as a root user into the remote server. In the same command, I have specified to reboot the server using the /sbin/reboot command.

Let us understand this syntax with an example.

I have logged in as root user on the server_ip as specified in the command.

gaurav@ubuntu:~$ ssh root@142.93.217.188 The authenticity of host '142.93.217.188 (142.93.217.188)' can't be established. ECDSA key fingerprint is SHA256:cXEkWjt7WHy11QRMhAa8mDmjAgE2SCKkp+xpaWAKLak. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '142.93.217.188' (ECDSA) to the list of known hosts. root@142.93.217.188's password: Linux debian-s-1vcpu-1gb-blr1-01 4.9.0-13-amd64 #1 SMP Debian 4.9.228-1 (2020-07-05) x86_64 The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. root@debian-s-1vcpu-1gb-blr1-01:~#

After logging in remotely, use the reboot command below to restart the remote system.

root@debian-s-1vcpu-1gb-blr1-01:~# suod reboot Connection to 142.93.217.188 closed by remote host. Connection to 142.93.217.188 closed. gaurav@ubuntu:~$

Customizing your reboot

If you’re a system admin, you can even drop a message (with the —message option) along with the reboot command to let all users on the system know why it’s being rebooted.

sudo systemctl --message="Quarterly software maintenance drill" reboot

Here, we have used the systemctl command to start the reboot command-line utility. You can also use the service command instead of systemctl .

Читайте также:  Linux find all users in group

Sample output:

System is rebooting (Quarterly software maintenance drill)

You can see the similar output in the boot logs.

Checking reboot logs

The system reboot log is stored in /var/log/wtmp file on your Linux machine. But instead of scrolling through that file, you can simply use the last reboo t command to quickly check your reboot log.

Sample output:

reboot system boot 4.15.0-112-gener Tue Sep 29 16:30 still running reboot system boot 4.15.0-112-gener Tue Sep 29 13:21 - 16:30 (03:09) reboot system boot 4.15.0-112-gener Tue Sep 29 12:07 - 13:21 (01:13) reboot system boot 4.15.0-112-gener Tue Sep 29 08:51 - 12:06 (03:15) reboot system boot 4.15.0-112-gener Mon Sep 28 20:22 - 21:00 (00:37) reboot system boot 4.15.0-112-gener Mon Sep 28 16:27 - 16:45 (00:17) reboot system boot 4.15.0-112-gener Mon Sep 28 11:22 - 14:16 (02:54) reboot system boot 4.15.0-112-gener Sun Sep 27 23:04 - 00:22 (01:18) reboot system boot 4.15.0-112-gener Sun Sep 27 11:25 - 12:29 (01:03) reboot system boot 4.15.0-112-gener Sat Sep 26 09:52 - 12:15 (02:23) reboot system boot 4.15.0-112-gener Fri Sep 25 11:12 - 12:15 (1+01:03) reboot system boot 4.15.0-112-gener Thu Sep 24 11:13 - 17:19 (06:06)

Conclusion

Now we have a clear idea about how the Linux reboot command functions. We can safely say that most of the options that apply to the reboot command also work with the shutdown , halt and poweroff command. We can now easily use the reboot command to swiftly reboot your Linux system.

Источник

Оцените статью
Adblock
detector