cat ~/.bash_history
退出登录后才会保存,或直接用history -w写入
历史命令默认保存1000条,可修改
/etc/profile中的HISTORY=2000
alias 名字=‘命令‘ # 临时配置,重启就无,永久需改配置文件
例如
alias ccc=‘ls /etc/sysconfig/network-scripts/‘
unalias ls # 取消别名(永久,再用别名需重新配)
\ls # 临时一次
which ls查看绝对路径
用绝对路径
常规用法
# 用法
man 命令
# 具体方式
man 手册名 # 例如man ls
可搜索 /-h # 用n N快速定位
1. 按章节查找,常用的是1(命令用法)5(文本规范)8(系统管理命令)
/usr/bin/passwd # 命令,修改用户密码 man 1 passwd
/etc/passwd # 保存用户信息的文件 man 5 passwd
/etc/exports # man exports man 5 exports
2. 按关键字检索(适合记不住手册的全名时使用)
man -k "_selinux" # 手册名或手册描述中包含关键字_selinux
(从whatis数据库中找 # makewhatis)
3. 在所有章节中查询
man -a passwd # 检索所有passwd
man -f passwd
常规用法
1. 简单命令
--help
2. 示例
ls --help
用法:ls [选项]...[文件]...
ls常用选项
-a # all,查看目录下的所有文件,包括隐藏文件
-l # 长列表显示
-h # human,以人性化方式显示出来
-d # 只列出目录名,不列出其他内容
-t # 按修改顺序排序
-r # 逆序排序
-i # 显示文件的inode号(检索号)
查看主机名
hostname
修改主机名
vi /etc/hostname # 编辑文件永久修改主机名(需重启)
hostnamectl set-hostname 新名字 # 用命令修改
ntp:网络事件协议
ntpdate -u # 手动同步
ntpdate 0.cn.pool.ntp.org # 自动同步
systemctl enable ntpd # 开机自启
# 查看时间
date
#以自己的格式显示
date "+%Y-%m-%d %H:%M:%S"
# 设置系统时间
date -s "2022-11-12 11:12:13 CTS"
# 查看硬件时间
hwclock
# 将系统时间写入硬件时间
hwclock -w
# 将硬件时间写入系统时间
hwclock -s
# 做实验需要改时间
timedatectl set-ntp no
重启
shutdown -r 10 # 10分钟后重启
shutdown -r 0 # 立即重启
shutdown -r now # 立即重启
init 6 # 立即重启
reboot # 立即重启
关机
shutdown -h 10 # 10分钟后关机
shutdown -h 0 # 立即关机
shutdown -h now # 立即关机
poweroff # 立即关机
halt # 立即关机(需要自己断电关电源)
init 0 # 立即关机
原文:https://www.cnblogs.com/caojiaxin/p/14004510.html