命令行
本章同步视频:https://edu.51cto.com/sd/e4874
1.4 命令下达
1.4.1 命令格式
[ ~]# command [-options] parameter1 parameter2 ...
指令 选项 参数(1) 参数(2)
1.4.2 date - print or set the system date and time
date [OPTION]... [+FORMAT]
date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]
[ ~]# date
Tue Feb 25 19:00:53 CST 2020
[ ~]# date +%Y/%m/%d
2020/02/25
[ ~]# date +%H:%M
19:03
1.4.3 cal - display a calendar
cal [options] [[[day] month] year]
1.显示当前月日历
[ ~]# cal
February 2020
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
2.显示某年日历
[ ~]# cal 2020
3.显示某年某月日历
[ ~]# cal 2 2020
[ ~]# cal 25 2 2020
1.4.4 locale - get locale-specific information
locale [-a| -m]
locale [-ck] name...
1.查看系统语言
[ ~]# locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_name="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=
[ ~]# echo $LANG
en_US.UTF-8
2.查看系统语言(RHEL7)
[ ~]# cat /etc/locale.conf
LANG="en_US.UTF-8"
[ ~]# localectl status
System Locale: LANG=en_US.UTF-8
VC Keymap: us
X11 Layout: us
3.查看系统支持的语言
[ ~]# localectl list-locales
4.修改系统语言
[ ~]# localectl set-locale LANG=en_US.utf8
[ ~]# localectl set-locale LANG=zh_CN.utf8
1.4.5 排错
1.命令不存在或者拼写错误
[ ~]# Date
bash: Date: command not found...
Similar command is: ‘date‘
2.参数无效
[ ~]# cal 13 2020
cal: illegal month value: use 1-12
3.选项不存在
[ ~]# cal -l 2020
cal: invalid option -- ‘l‘
Usage:
cal [options] [[[day] month] year]
Options:
-1, --one show only current month (default)
-3, --three show previous, current and next month
-s, --sunday Sunday as first day of week
-m, --monday Monday as first day of week
-j, --julian output Julian dates
-y, --year show whole current year
-V, --version display version information and exit
-h, --help display this help text and exit
1.4.6 热键
1.Ctrl+C:中止前台命令的执行
[ ~]# ^C
2.Tab:自动补全
(1)命令补全
[ ~]#his[tab]
[ ~]#ca[tab][tab]
(2)文件名补全
[ ~]#cd /e[tab]
(3)选项补全
[ ~]#date --[tab][tab]
3.Ctrl+D:结束键盘输入