- 系统时间管理 (Linux date 命令 | 菜鸟教程)
- 查看
[root@test2 opt]# hwclock
Wed 06 Aug 2025 01:06:03 AM CST -0.288080 seconds
[root@test2 opt]# #1查看硬件时间
[root@test2 opt]#
[root@test2 opt]#
[root@test2 opt]#
[root@test2 opt]#
[root@test2 opt]# date
Tue Aug 5 08:54:25 CST 2025
[root@test2 opt]#
[root@test2 opt]# #2查看系统时间
- 修改时间 %占位符吧 主要的是data -s
[root@test2 opt]# #修改时间
[root@test2 opt]# date -s '2025-8-5 17:10'
Tue Aug 5 17:10:00 CST 2025
[root@test2 opt]# data "+%F" 写错了这个
-bash: data: command not found
[root@test2 opt]# date "+%F"
2025-08-05
[root@test2 opt]#
[root@test2 opt]#
[root@test2 opt]#
[root@test2 opt]# #备份系统
[root@test2 opt]#
[root@test2 opt]#
[root@test2 opt]# date "+%Y-%m-%d"
2025-08-05
[root@test2 opt]# date "+%Y-%m-%d" #Y 年的意思 m月份 d日期
2025-08-05
[root@test2 opt]# date "+%Y-%m-%d" #Year 年的意思 month月份 date日期
2025-08-05
[root@test2 opt]# date "+%Y-%m-%d %H:%M:%S" #Year 年的意思 month月份 date日
期 Hours小时 minutes分钟 seconds秒 外国人开发都是类似外语的缩小吧
2025-08-05 17:20:58
[root@test2 opt]#
[root@test2 opt]#
[root@test2 opt]#
[root@test2 opt]# date "+%Y/%m/%d %H:%M:%S" #Year 年的意思 month月份 date日
期 Hours小时 minutes分钟 seconds秒 外国人开发都是类似外语的缩小吧
2025/08/05 17:21:35
[root@test2 opt]# #修改系统时间(很少吧,有网络时间同步)
[root@test2 opt]#
[root@test2 opt]#
[root@test2 opt]#
[root@test2 opt]# #系统备份吧
[root@test2 opt]#
- 检查命令消耗时间 time 使用time 命令测速一个命令运行时间(Linux time命令 | 菜鸟教程)
[root@test2 opt]# time ls
software
real 0m0.002s
user 0m0.001s
sys 0m0.000s
#"real"为实际时间,"user"为用户CPU时间,"sys"为系统CPU时间。
- 开机关机命令
关机
shutdown -h now
shutdown -h 2 2分钟关机
halt
ini 0
重启
shutdown -r now
shutdown -r w
shutdown -r 10:29
reboot 重启
shutdown -c 取消关机
都需要在root用户下操作
- 设置服务器定时开机(可能就是SVN git 代码管理服务器)
- 通电就进行开机(台式电脑)
- 创建文件夹 mkdir 文件名字
- 创建文件 touth 文件名字 mkdir test1 cd test1 touch file1.txt
- 切换用户 su - 用户名字
- 显示当前系统的所有用户信息, who / who am i
- 显示当前系统的日历,date +"%Y-%m-%d %H:%M:%S"
- 显示最近使用的20个历史命令 history 20
- 修改服务器密码 root用户下执行的命令 passwd
- 删除文件夹 rmdir 文件夹名称