When we operate the Linux v/server, there is a need to restart the system, or shut down the system. Some users are directly to the VPS hosting business panel operation, which is more troublesome, and some panels are not easy to use easy to cause the panel card dead. So the best way is to use SSH command operation, Lao Jiang here to share 2 commands, reboot and shutdown can be used as a reboot vps/shutdown restart operation.
First, reboot
How to use: Enter the reboot command directly under the SSH root permission user to see the system is going down for reboot now prompt, restart VPS.
Reboot's work is almost the same as halt? But is it triggering a host reboot? And halt is shutting down. 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 it is difficult to follow the complete command parameters, Lao Jiang follows is practical, so we can share our common.
A-Turn off the system and power off
Shutdown-h now #立即关闭系统和电源
Shutdown-h +10 "Ten minute after shutdown" #10分钟之后关闭系统和电源
B-Restart your computer with shutdown
Shutdown-r now
The current restart of the computer immediately, and the above reboot is the same effect.
shutdown-r now restarts
shutdown-r +10 10 minutes after restart
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.
[email protected] ~] #whereis reboot #查找reboot的位置
Reboot:/sbin/reboot/usr/share/man/man8/reboot.8.gz
[[Email protected] ~] #su user #切换到user
[email protected] root]$ reboot #执行重启测试
Reboot:need to be root #提示需要root
[Email protected] root]$ exit #退回到root用户
Exit
[[email protected] ~]# ll/sbin/reboot #查看默认/sbin/reboot Details
-rwxr-xr-x. 1 root root 13932 Jul 2011/sbin/reboot #注意看前三个为rwx
[Email protected] ~]# chmod u+s/sbin/reboot #增加suid权限
[[email protected] ~]# ll/sbin/reboot #重新查看修改后的/sbin/reboot More information
-rwsr-xr-x. 1 root root 13932 Jul 2011/sbin/reboot #这时候已经变更为rws
[email protected] ~]# su user #重新切换到user用户
[email protected] root]$ reboot #执行reboot指令
broadcast message from [email protected] #重启成功
(/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 be shut down and restarted. The more secure way is to use the sudo command. First install sudo:
#pacman-S sudo
Then, under the root user, add the following to the end of the/etc/sudoers file with the Visudo command. Replace the user with your username, hostname your host name.
User hostname=nopasswd:/sbin/shutdown-h now
User hostname=nopasswd:/sbin/reboot
or merge it into a single line representing
User hostname=nopasswd:/sbin/shutdown-h now,/sbin/reboot
Now your user can shut down with the sudo shutdown-h current command, and the reboot command restarts.
Method Three: Xfce
In Xfce, if you want users to use HAL to shut down, you need to install sudo. Then add the following to/etc/sudoers with the visudo-f command
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 as your hostname (you can get it with the hostname command).
This activates the "shutdown" and "restart" options for the user you have defined.
Linux reboot and shutdown shutdown command detailed