Linux reboot and shutdown reboot/shutdown command detailed

Source: Internet
Author: User
Tags ssh vps

We will certainly need to reboot the system when we operate the Linux vps/server, or shut down the system and other operations. Some users are directly to the VPS host business panel operation, which makes it more troublesome, and some panels are not easy to use easily lead to the panel card dead. So the best way is through the SSH command operation, the old Chiang here to share 2 commands, reboot and shutdown can be used as a reboot vps/shutdown restart operation.

First, reboot

Usage: Directly under the SSH root permission user, enter the reboot command to see the system is going down for reboot now prompts to reboot the VPS.

Reboot's work process is almost the same as Halt's? But does it trigger a host reboot? And halt is shutdown. Its parameters are not much different from the halt.

Second, shutdown

This command can be used to reboot or to shut down the operation. If the complete command parameters are still more difficult, the old Chiang is to follow the practical, so share what we often can.

A-Shut down the system and power off

Shutdown-h now #立即关闭系统和电源
Shutdown-h +10 "minute after shutdown" #10分钟之后关闭系统和电源

B-Restart the computer with shutdown

Shutdown-r now

Now restart the computer immediately, and the above reboot is the same effect.

can also use the Shutdown command to achieve automatic timing shutdown function, summed up as follows:

Shutdown-r now shutdown and reboot
Shutdown-h now does not reboot after shutdown
Shutdown-r +10 10 minutes after reboot
Shutdown-r 10:00 10 o'clock restart
Shutdown-h +10 10 minutes after shutdown
Shutdown-h 10:00 10 o'clock shutdown

The following is the process of testing.

The code is as follows Copy Code
Root@localhost ~] #whereis reboot #查找reboot的位置
Reboot:/sbin/reboot/usr/share/man/man8/reboot.8.gz
[root@localhost ~] #su user #切换到user
[User@localhost root]$ reboot #执行重启测试
Reboot:need to IS root #提示需要root
[User@localhost root]$ Exit #退回到root用户
Exit
[Root@localhost ~]# ll/sbin/reboot #查看默认/sbin/reboot Details
-rwxr-xr-x. 1 root root 13932 June 2011/sbin/reboot #注意看前三个为rwx
[Root@localhost ~]# chmod u+s/sbin/reboot #增加suid权限
[Root@localhost ~]# ll/sbin/reboot #重新查看修改后的/sbin/reboot Detailed information
-rwsr-xr-x. 1 root root 13932 June 2011/sbin/reboot #这时候已经变更为rws
[root@localhost ~]# su user #重新切换到user用户
[User@localhost root]$ reboot #执行reboot指令
Broadcast message from Root@localhost.localdomain #重启成功
(/dev/pts/0) at 21:28 ...
The system is going down for reboot now!


another way to use sudo!

This is considered a security threat because all users, including root, can shut down and reboot. A more secure approach is to use the sudo command. First install sudo:

#pacman-S sudo

Then, under root user, add the following to the end of the/etc/sudoers file with the Visudo command. Replace the user with your username, hostname for your host name.

User hostname=nopasswd:/sbin/shutdown-h now
User hostname=nopasswd:/sbin/reboot

or merged into one line to represent


User hostname=nopasswd:/sbin/shutdown-h now,/sbin/reboot
Now your users can use the sudo shutdown-h command to shut down and the reboot command to reboot.

Method Three: Xfce

Under Xfce, if you want users to use the HAL shutdown, you need to install sudo. Then use the visudo-f command to add the following content to the/etc/sudoers
For all users:

%users Hostname=nopasswd:/usr/lib/xfce4/xfsm-shutdown-helper

For a single User:

User Hostname=nopasswd:/usr/lib/xfce4/xfsm-shutdown-helper
Replace the user with your username, hostname for your hostname (you can get it with the hostname command).
This allows you to define the user's "shutdown" and "reboot" options to activate.

The above reboot and shutdown commands are commonly used, there are other not commonly used in Chiang Kai-shek did not collate, later if necessary to use to supplement.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.