linux命令之date,hault,shutdown,reboot,init,poweroff

date

1.说明:Display the current time in the given FORMAT, or set the system date该命令用于以一定格式显示当前系统时间以及设置系统时间

2.用法:date [OPTION]... [+FORMAT]  date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]

date "+%Y-%m-%d %H:%M:%S"(格式化输出时间)

export TZ='Asia/Shanghai'(改变时区变量TZ的值)

3.常用选项说明:

  -s  set time described by STRING  eg:date -s "19910715 23:30:00"(设置时间)

4.常用FORMAT说明

  %a   locale's abbreviated weekday name (e.g., Sun)

  %A   locale's full weekday name (e.g., Sunday)

  %b   locale's abbreviated month name (e.g., Jan)

  %B   locale's full month name (e.g., January)

  %c   locale's date and time (e.g., Thu Mar 3 23:05:25 2005)

  %d   day of month (e.g., 01)

  %D   date; same as %m/%d/%y

  %H   hour (00..23)  00-23小时

  %I   hour (01..12)  01-12小时

  %j   day of year (001..366)  一年的第几天

  %m   month (01..12)

  %M   minute (00..59)

  %p   locale's equivalent of either AM or PM; blank if not known

  %S   second (00..60)

  %t   a tab  一个tab键

  %T   time;same as %H:%M:%S

  %Y year

  %Z  查看时区

hault,power-off,reboot

   这三个命令分别用于停止,关机,重启系统,使用简单

shutdown

  同上面的命令但可以指定时间进行关机如shutdown now立刻关机shutdown -r "hh:mm"该时间点重启

  几个选项

  -H, --halt
  Halt the machine.

  -P, --poweroff
  Power-off the machine (the default).

  -r, --reboot
  Reboot the machine.

init

  systemd is a system and service manager for Linux operating systems

  init命令是Linux下的进程初始化工具,init进程是所有Linux进程的父进程,它的进程号为1。init命令是Linux操作系统中不可缺少的程序之一,init进程是Linux内核引导运行的,是系统中的第一个进程

-b:不执行相关脚本而直接进入单用户模式;
-s:切换到单用户模式。

    查看系统进程命令:ps -ef | head
    查看init的配置文件:more /etc/inittab

    /etcsystem.conf/init
    查看系统当前运行的级别:runlevel

使用方法:init []选项] runlevel

    runlevel命令用于打印当前Linux系统的运行等级

    

    

  0:安全关机

  1:管理模式:单用户模式,安装所有的文件系统,留一少部分重要的内核进程在运行,可在管理员管理系统时使用。

  2:多用户模式运行,产生所有多用户环境终端进程和演示。

  3:多用户网络模式,安装和共享运程资源。(命令行界面)

  4:交替的多用户环境配置,不经常使用。

  5:图形化,停止Linux系统并转到硬监视器。

  6:重新启动,停止Linux系统并启动到由/sbin/inittab中的init默认项定义的状态。

  

  

猜你喜欢

转载自www.cnblogs.com/holdononedream/p/10857455.html