一、基本命令--ls
作用:查看当前目录下有哪些文件(list)
l
第一个字符文件类型种:
d:目录文件
I:链接文件
b:块设备文件
c:字符设备文件
p:管道文件
-:普通文件
ls -d 查看目录(不查看里面的内容)
ls -lS以文件的大小排序
ls -l和ll这个两个命令是等价的
[pc@thq ~]$ type ll
ll 是 `ls -l --color=auto' 的别名
二、别名的使用
alias 别名=''或者alias 别名=“”
设置当前用户永久有效
[pc@thq ~]$ vim /home/pc/.bashrc 在末尾添加
alias vimenss33="vim /etc/sysconfig/network-scripts/ifcfg-ens33"
删除别名
unalias 别名
设置全局使用
pc@thq ~]$ vim /etc/bashrc
在末尾添加
alias vimenss33="vim /etc/sysconfig/network-scripts/ifcfg-ens33"
三、基本命令之---cd
作用:切换目录
cd -切换前的目录
四、历史命令之history
快速查找
1.光标上下键
2.ctrl+r
3.!数字 执行历史中的某条命令
五、常用快捷键
都是Ctrl+某个字母
^C 停止运行命令
^D退出命令
^L清屏命令
!$引用上个命令的最后一个参数
系統时间管理
查看硬件的系统时间
root@thq pc]# hwclock
修改时间
date --help
用法:date [选项]... [+格式]
或:date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]
Display the current time in the given FORMAT, or set the system date.必选参数对长短选项同时适用。
-d, --date=STRING display time described by STRING, not 'now'
--debug annotate the parsed date,
and warn about questionable usage to stderr
-f, --file=DATEFILE like --date; once for each line of DATEFILE
-I[FMT], --iso-8601[=FMT] output date/time in ISO 8601 format.
FMT='date' for date only (the default),
'hours', 'minutes', 'seconds', or 'ns'
for date and time to the indicated precision.
Example: 2006-08-14T02:34:56-06:00
-R, --rfc-email output date and time in RFC 5322 format.
Example: Mon, 14 Aug 2006 02:34:56 -0600
--rfc-3339=FMT output date/time in RFC 3339 format.
FMT='date', 'seconds', or 'ns'
for date and time to the indicated precision.
Example: 2006-08-14 02:34:56-06:00
-r, --reference=FILE display the last modification time of FILE
-s, --set=STRING set time described by STRING
-u, --utc, --universal print or set Coordinated Universal Time (UTC)
--help 显示此帮助信息并退出
--version 显示版本信息并退出给定的格式FORMAT 控制着输出,解释序列如下:
%% 一个文字的 %
%a 当前locale 的星期名缩写(例如: 日,代表星期日)
%A 当前locale 的星期名全称 (如:星期日)
%b 当前locale 的月名缩写 (如:一,代表一月)
%B 当前locale 的月名全称 (如:一月)
%c 当前locale 的日期和时间 (如:2005年3月3日 星期四 23:05:25)
%C 世纪;比如 %Y,通常为省略当前年份的后两位数字(例如:20)
%d 按月计的日期(例如:01)
%D 按月计的日期;等于%m/%d/%y
%e 按月计的日期,添加空格,等于%_d
%F 完整日期格式,等价于 %Y-%m-%d
%g ISO-8601 格式年份的最后两位 (参见%G)
%G ISO-8601 格式年份 (参见%V),一般只和 %V 结合使用
%h 等于%b
%H 小时(00-23)
%I 小时(00-12)
%j 按年计的日期(001-366)
%k hour, space padded ( 0..23); same as %_H
%l hour, space padded ( 1..12); same as %_I
%m month (01..12)
%M minute (00..59)
%n a newline
%N nanoseconds (000000000..999999999)
%p locale's equivalent of either AM or PM; blank if not known
%P like %p, but lower case
%q quarter of year (1..4)
%r locale's 12-hour clock time (e.g., 11:11:04 PM)
%R 24-hour hour and minute; same as %H:%M
%s seconds since 1970-01-01 00:00:00 UTC
%S 秒(00-60)
%t 输出制表符 Tab
%T 时间,等于%H:%M:%S
%u 星期,1 代表星期一
%U 一年中的第几周,以周日为每星期第一天(00-53)
%V ISO-8601 格式规范下的一年中第几周,以周一为每星期第一天(01-53)
%w 一星期中的第几日(0-6),0 代表周一
%W 一年中的第几周,以周一为每星期第一天(00-53)
%x 当前locale 下的日期描述 (如:12/31/99)
%X 当前locale 下的时间描述 (如:23:13:48)
%y 年份最后两位数位 (00-99)
%Y 年份
%z +hhmm 数字时区(例如,-0400)
%:z +hh:mm 数字时区(例如,-04:00)
%::z +hh:mm:ss 数字时区(例如,-04:00:00)
%:::z 数字时区带有必要的精度 (例如,-04,+05:30)
%Z 按字母表排序的时区缩写 (例如,EDT)默认情况下,日期的数字区域以0 填充。
The following optional flags may follow '%':- (hyphen) do not pad the field
_ (underscore) pad with spaces
0 (zero) pad with zeros
^ use upper case if possible
# use opposite case if possible在任何标记之后还允许一个可选的域宽度指定,它是一个十进制数字。
作为一个可选的修饰声明,它可以是E,在可能的情况下使用本地环境关联的
表示方式;或者是O,在可能的情况下使用本地环境关联的数字符号。Examples:
Convert seconds since the epoch (1970-01-01 UTC) to a date
$ date --date='@2147483647'Show the time on the west coast of the US (use tzselect(1) to find TZ)
$ TZ='America/Los_Angeles' dateShow the local time for 9AM next Friday on the west coast of the US
$ date --date='TZ="America/Los_Angeles" 09:00 next Fri'GNU coreutils 在线帮助:<https://www.gnu.org/software/coreutils/>
请向 <http://translationproject.org/team/zh_CN.html> 报告 date 的翻译错误
完整文档请见:<https://www.gnu.org/software/coreutils/date>
或者在本地使用:info '(coreutils) date invocation'
[root@thq pc]# date "+%Y-%m-%d %H:%M:%S"
2019-11-09 08:44:30
[root@thq pc]# date -d "+1 months" +%F
2019-12-09
[root@thq pc]# date -d "+1 months"
2019年 12月 09日 星期一 08:48:23 CST
TIME测试一个命令运行的时间
帮助命令
man
开机命令及7个启动级别
shutdown -h 时间
shutdown -r 重启
设置为字符界面
[root@thq pc]# systemctl set-default multi-user.target
设置为图形界面
[root@thq pc]# systemctl set-default graphical.target
当前系统运行的级别
[root@thq pc]# runlevel
N 5
[root@thq pc]# systemctl get-default
graphical.target
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
查看命令
cat
more 不支持上翻页
less支持上下翻页
head
tail
xfs文件系统的备份和恢复
fdisk /dev/
n
p
+G