linux64命令,每天一个Linux命令(64)shutdown命令

shutdown以一种安全的方式关闭系统。

(1)用法:

用法:  shutdown [参数] [时间]

(2)功能:

功能:  系统关机命令,shutdown指令可以关闭所有程序,并依用户的需要,进行重新开机或关机的动作,所有登陆用户都可以看到关机信息提示。

原理:  shutdown通过通知init进程,要求它改换运行级别来实现。运行级别0用来关闭系统,运行级别6用来重启系统,运行级别1用来使系统进入执行系统管理任务状态,如果没有给出 -h 或 -r 标志时,这是 shutdown 命令的默认工作状态。

(3)选项参数:

1) -h          将系统关机

2) -r         shutdown之后重新启动

3) -k        只是送出信息给所有用户,但不会实际关机

4) -f         重启时跳过磁盘检测

5) -F          重启时强制磁盘检测。

6) -c          取消运行中的 shutdown 进程。不可能为此选项指定 time 参数,但你可以在命令行输入一条解释消息来向所有用户说明。

(一般的shutdown指令可以用按“+”号来进行中断)

(4)实例:

1)在特定的时间执行关机命令:

shutdown -h now //立即关机

shutdown -h 12:00 //在12:00关机

2)指定5分钟后关机,同时送出警告信息给登入用户

[email protected]:/home/sunjimeng# shutdown +5 "This System will be shutdown in 5 minute!"

来自[email protected]的广播信息

(/dev/pts/6) 于 10:38 ...

The system is going down for maintenance in 5 minutes! //系统提醒

This System will be shutdown in 5 minute!          //用户自定义提醒

3)取消关机命令

shutdown -c

4)在特定时间执行关机重启命令,并取消

[[email protected] ~]$ su root            //必须是root用户

密码:

[[email protected] sunmeng]# shutdown -r +3 "3分钟后关机重启"

Shutdown scheduled for 三 2016-06-29 19:47:26 PDT, use ‘shutdown -c‘ to cancel.

[[email protected] sunmeng]#

Broadcast message from root[email protected] (Wed 2016-06-29 19:44:26 PDT):

3分钟后关机重启

The system is going down for reboot at Wed 2016-06-29 19:47:26 PDT!

[[email protected] sunmeng]# shutdown -c

Broadcast message from [email protected] (Wed 2016-06-29 19:44:50 PDT):

The system shutdown has been cancelled at Wed 2016-06-29 19:45:50 PDT!

5)shutdown -k并不会真正关机,仅仅是给各登录的用户发送提醒

[[email protected] sunmeng]# shutdown -k "Warning:Maybe the system will be shutdown."

Failed to parse time specification: Warning:Maybe the system will be shutdown.

[[email protected] sunmeng]# shutdown -k 5 "Warning:Maybe the system will be shutdown."

Shutdown scheduled for 三 2016-06-29 19:53:56 PDT, use ‘shutdown -c‘ to cancel.

[[email protected] sunmeng]#

Broadcast message from [email protected] (Wed 2016-06-29 19:48:56 PDT):

Warning:Maybe the system will be shutdown.

The system is going down for power-off at Wed 2016-06-29 19:53:56 PDT!

6)快速或慢速重启(Unbuntu有-f或-F参数,CentOS没有)

shutdown -f [time] //快速重启,忽略磁盘检查

shutdown -F [time] //强制磁盘检查

(5)其他:

1)永久更改系统时间:

//date命令只能暂时更改系统时间,关机重启后时间又会回到之前,所以需要将时间写入bios

[[email protected] sunmeng]# date -s "2016-06-30 11:05:10"

2016年 06月 30日 星期四 11:04:30 PDT

[[email protected] sunmeng]# clock -w

2)显示机器的处理器架构:

[[email protected] sunmeng]# arch

x86_64

3)其他关机命令:

init 0 //关机

init 6 //关机重启

reboot //关机重启

4)clock与date命令:

//只有超级用户才能设置硬件时钟。

[[email protected] ~]$ su root

密码:

[[email protected] sunmeng]# clock --set --date="05/04/2013 14:30:01"        //设置硬件时间为2013年

[[email protected] sunmeng]# clock

2013年05月04日 星期六 14时30分12秒 -0.388214 秒

[[email protected] sunmeng]# date                             //此时硬件时间为2013,系统时间为2016

2016年 06月 29日 星期三 20:20:36 PDT

[[email protected] sunmeng]# clock -s                           //根据硬件时间设置系统时间

[[email protected] sunmeng]# date

2013年 05月 04日 星期六 14:31:04 PDT

[[email protected] sunmeng]# clock

2013年05月04日 星期六 14时31分09秒 -0.101952 秒                    //系统时间和硬件时间都为2013年

[[email protected] sunmeng]# date -s "2016-06-30 11:22:10"             //设置系统时间为2016年

2016年 06月 30日 星期四 11:22:10 PDT

[[email protected] sunmeng]# clock                            //系统时间为2016年,硬件时间为2013

2013年05月04日 星期六 14时32分13秒 -0.559223 秒

[[email protected] sunmeng]# clock -w                           //根据系统时间设置硬件时间

[[email protected] sunmeng]# date

2016年 06月 30日 星期四 11:22:51 PDT

[[email protected] sunmeng]# clock

2016年06月30日 星期四 11时22分56秒 -0.968643 秒

5)显示本机shell的信息,也可以更改shell

[[email protected] ~]$ chsh -l

/bin/sh

/bin/bash

/sbin/nologin

/usr/bin/sh

/usr/bin/bash

/usr/sbin/nologin

/bin/tcsh

/bin/csh

[[email protected] ~]$ chsh -v

chsh,来自 util-linux 2.23.2

每天一个Linux命令的最后一篇,以后还会详细介绍Linux系统的其他相关知识。

时间: 06-30

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值