4.1 时间管理
4.1.1 date
时间管理(系统时间)
Linux: rtc(硬件时间,实时时钟)
ntp:网络时间协议,网络时间服务器
硬件时钟:系统硬件自动运行的时间
系统时钟:操作系统开机以后会自动计算出来接下来经过的时间
练习:
使用date单独获取系统当前的年份、月份、日、小时、分钟、秒
[root@Daniel-R480 ~]# date
Mon Jun 28 14:40:18 CST 2021
[root@Daniel-R480 ~]# date +%y
21
[root@Daniel-R480 ~]# date +%m
06
[root@Daniel-R480 ~]# date +%d
28
[root@Daniel-R480 ~]# date +%s
1624862439
[root@Daniel-R480 ~]#
4.1.2 hwclock
显示硬件时钟
hwclock
-w: 设置硬件时钟为系统时钟
-s: 设置系统时钟为硬件时钟
[root@Daniel-SHSH ~]# hwclock
Mon 28 Jun 2021 02:42:43 PM CST -0.885496 seconds
[root@Daniel-SHSH ~]# hwclock -w
[root@Daniel-SHSH ~]# hwclock -s
3、cal
日历
cal: calendar
后面可加年份,月份
cal 6 2021
[root@Daniel-SHSH ~]# cal
June 2021
Su Mo Tu We Th Fr Sa
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30
[root@Daniel-SHSH ~]# cal 3 2021
March 2021
Su Mo Tu We Th Fr Sa
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
[root@Daniel-SHSH ~]#
4.2 命令帮助
4.2.1 内部命令:
help COMMAND
[root@Daniel-SHSH ~]# help cd
cd: cd [-L|[-P [-e]]] [dir]
Change the shell working directory.
Change the current directory to DIR. The default DIR is the value of the
HOME shell variable
4.2.2 外部命令:
COMMAND --help
[root@Daniel-SHSH ~]# ls --help
Usage: ls [OPTION]... [FILE]...
List information about the FILEs (the current directory by default).
Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.
4.2.3 命令手册(几乎所有命令都有):manual
1、man COMMAND
查看用户手册
2、whatis COMMAND
查看命令出现的章节
3、MAN分章节:
(1)用户命令(/bin, /usr/bin, /usr/local/bin)
(2)系统调用
(3)库用户
(4)特殊文件(设备文件)
(5)文件格式(配置文件的语法)
(6)游戏
(7)杂项(Miscellaneous)
(8)管理命令(/sbin, /usr/sbin, /usr/local/sbin,需要管理员权限才能使用)
4、注释符含义
<>:必选
[]:可选
...:可以出现多次
|:多选一
{}:分组
5、MAN的输出内容
NAME:命令名称及功能简要说明
SYNOPSIS:用法说明,包括可用的选项
DESCRIPTION:命令功能的详尽说明,可能包括每一个选项的意义
OPTIONS:说明每一个选项的意义
FILES:此命令相关的配置文件
BUGS:
EXAMPLES:使用示例
SEE ALSO:另外参照
6、一些基本操作
(1) 翻屏
向后翻一屏:SPACE
向前翻一屏:b
向后翻一行:ENTER
向前翻一行:k
(2)查找
/KEYWORD: 向后
n: 下一个
N:前一个
?KEYWORD:向前
q: 退出
(3)在线文档
info COMMAND
(4)文档
/usr/share/doc
首选文档: 一般软件或者项目都有着官方在线说明,
比如apache, hadoop
练习:
1、echo是内部命令还是外部命令?
[root@Daniel-R480 ~]# help echo
echo: echo [-neE] [arg ...]
Write arguments to the standard output.
2、其作用?
Write arguments to the standard output.
3、如何显示“The year is 2013. Today is 26.”为两行?
echo -e "This year is 2013.\nToday is 26."
\转义符
转义,逃逸
练习:
1、printf是内部命令还是外部命令?
[root@Daniel-R480 ~]# help printf
printf: printf [-v var] format [arguments]
Formats and prints ARGUMENTS under control of the FORMAT.
2、其作用?
Formats and prints ARGUMENTS under control of the FORMAT.
3、如何显示“The year is 2013. Today is 26.”为两行?
printf "The year is 2013.\nToday is 26.\n"
评论关闭。