当前时区为 UTC + 8 小时



发表新帖 回复这个主题  [ 4 篇帖子 ] 
作者 内容
1 楼 
 文章标题 : ubuntu14.04关机应优先使用哪个命令 init shutdown poweroff halt
帖子发表于 : 2015-12-12 22:00 

注册: 2015-08-24 22:17
帖子: 22
系统: ubuntu14.04
送出感谢: 8
接收感谢: 0 次
ubuntu14.04开机到桌面后,如果在gnome-terminal字符界面下关机,应优先使用哪个命令init 0 shutdown -h now、powerof、halt 。再问个问题,poweroff是reboot的软连接,为何一个是关机 一个是重启?


页首
 用户资料  
 
2 楼 
 文章标题 : Re: ubuntu14.04关机应优先使用哪个命令 init shutdown poweroff halt
帖子发表于 : 2015-12-13 12:38 

注册: 2015-04-04 23:20
帖子: 108
系统: linux & windows
送出感谢: 4
接收感谢: 6
正常情况下,还是建议使用shutdown吧,它不仅可以定时,还会在关机做更多的准备工作。

2、(个人推测)虽然执行的是同一个程序,但是程序在实际运行过程中可以根据不同的程序名称(当作参数)执行不同的操作。


页首
 用户资料  
 
3 楼 
 文章标题 : Re: ubuntu14.04关机应优先使用哪个命令 init shutdown poweroff halt
帖子发表于 : 2015-12-13 19:06 

注册: 2009-08-04 16:33
帖子: 16886
送出感谢: 21
接收感谢: 1826
引用:
init shutdown poweroff halt

1. http://upstart.ubuntu.com/
Upstart is an event-based replacement for the /sbin/init daemon
Ubuntu 14.04 預設使用 Upstart 開機初始化
Upstart 被設計來取代 /sbin/init
意思是 在 Ubuntu 14.04 應該不需考慮 init
1-1. http://manpages.ubuntu.com/manpages/tru ... down.8.htm
shutdown - bring the system down
This is performed by emitting the runlevel(7) event, which includes the new runlevel in the RUNLEVEL environment variable as well as the previous runlevel (obtained from the environment or from /var/run/utmp) in the PREVLEVEL variable

2. http://manpages.ubuntu.com/manpages/tru ... oot.8.html
reboot, halt, poweroff 都是 Upstart 套件提供的指令
2-1. When called with --force or when in runlevel 0 or 6, this tool invokes the reboot(2) system call itself (with REBOOTCOMMAND argument passed) and directly reboots the system. Otherwise this simply invokes the shutdown(8) tool with the appropriate arguments without passing REBOOTCOMMAND argument.
意思是 如果沒有加 --force 參數 或 在 runlevel 0 or 6 執行
它們預設都是用來啟動 shutdown 指令

3. 建議 直接啟用 shutdown 就好
http://manpages.ubuntu.com/manpages/tru ... own.8.html
shutdown - bring the system down


页首
 用户资料  
 
4 楼 
 文章标题 : Re: ubuntu14.04关机应优先使用哪个命令 init shutdown poweroff halt
帖子发表于 : 2016-01-30 14:48 

注册: 2011-01-02 12:31
帖子: 171
送出感谢: 17
接收感谢: 5
Ubuntu 15.04 开始使用 systemd 接管,使用 systemctl 来控制关机也是不错选择!

例如:systemctl poweroff

Using Systemd to Power Off / Reboot / Suspend GNOME

Not everyone bothers with manuals, so I am re-printing the documentation of some nice to use commands.

Command Description
halt Shut down and halt the system.
This is mostly equivalent to start halt.target –irreversible, but also prints a wall message to all users. If combined with –force, shutdown of all running services is skipped, however all processes are killed and all file systems are unmounted or mounted read-only, immediately followed by the system halt.

If –force is specified twice, the operation is immediately executed without terminating any processes or unmounting any file systems. This may result in data loss.

poweroff Shut down and power-off the system.
This is mostly equivalent to start poweroff.target –irreversible, but also prints a wall message to all users. If combined with –force, shutdown of all running services is skipped, however all processes are killed and all file systems are unmounted or mounted read-only, immediately followed by the powering off.

If –force is specified twice, the operation is immediately executed without terminating any processes or unmounting any file systems. This may result in data loss.

reboot Shut down and reboot the system.
This is mostly equivalent to start reboot.target –irreversible, but also prints a wall message to all users. If combined with –force, shutdown of all running services is skipped, however all processes are killed and all file systems are unmounted or mounted read-only, immediately followed by the reboot.

If –force is specified twice, the operation is immediately executed without terminating any processes or unmounting any file systems. This may result in data loss.

suspend Suspend the system.
This will trigger activation of the special suspend.target target.

hibernate Hibernate the system.
This will trigger activation of the special hibernate.target target

hybrid-sleep Hibernate and suspend the system.
This will trigger activation of the special hybrid-sleep.target target.


页首
 用户资料  
 
显示帖子 :  排序  
发表新帖 回复这个主题  [ 4 篇帖子 ] 

当前时区为 UTC + 8 小时


在线用户

正在浏览此版面的用户:没有注册用户 和 0 位游客


不能 在这个版面发表主题
不能 在这个版面回复主题
不能 在这个版面编辑帖子
不能 在这个版面删除帖子
不能 在这个版面提交附件

前往 :  
本站点为公益性站点,用于推广开源自由软件,由 DiaHosting VPSBudgetVM VPS 提供服务。
我们认为:软件应可免费取得,软件工具在各种语言环境下皆可使用,且不会有任何功能上的差异;
人们应有定制和修改软件的自由,且方式不受限制,只要他们自认为合适。

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
简体中文语系由 王笑宇 翻译