与关机相关的几个命令

来源:互联网 发布:origin软件绘图 编辑:程序博客网 时间:2024/05/29 07:32

一、用init命令实现相关功能

  linux有7个开机选项,用init命令可以选择其中的一个开机选项,这7个开机选项的意思见inittab文件的注释

 [root@yang-centos ~]# init 0   #马上关机

[root@yang-centos ~]# init 3    #以命令行方式重新启动

[root@yang-centos ~]# init 5    #以窗口(X window)方式重新启动

[root@yang-centos ~]# init 6    #以默认方式重新启动,默认方式在inittab文件中定义


二、以shutdown命令实现相关功能

[root@yang-centos ~]# shutdown -P now    #马上关机

[root@yang-centos ~]# shutdown -r now    #马上重新启动

[root@yang-centos ~]# shutdown -h 《时间值》    #在某个时间关机,如果时间值为0,则马上关机


三、reboot、halt、poweroff命令

[root@yang-centos ~]#reboot    #马上重新启动

[root@yang-centos ~]# halt    #马上关机

[root@yang-centos ~]# poweroff   #马上关机


#-------inittab 文件内容------------------------


# inittab is only used by upstart for the default runlevel.
#
# ADDING OTHER CONFIGURATION HERE WILL HAVE NO EFFECT ON YOUR SYSTEM.
#
# System initialization is started by /etc/init/rcS.conf
#
# Individual runlevels are started by /etc/init/rc.conf
#
# Ctrl-Alt-Delete is handled by /etc/init/control-alt-delete.conf
#
# Terminal gettys are handled by /etc/init/tty.conf and /etc/init/serial.conf,
# with configuration in /etc/sysconfig/init.
#
# For information on how to write upstart event handlers, or how
# upstart works, see init(5), init(8), and initctl(8).
#
# Default runlevel. The runlevels used are:
#   0 - halt (Do NOT set initdefault to this)
#   1 - Single user mode
#   2 - Multiuser, without NFS (The same as 3, if you do not have networking)
#   3 - Full multiuser mode
#   4 - unused
#   5 - X11
#   6 - reboot (Do NOT set initdefault to this)

#
id:5:initdefault:








原创粉丝点击