linux基本命令
useradd balaba
passwd balaba
密码
!$ 取上一条命令的最后一个参数
^c 终止
^d 退出/删除光标后面的字符
^l 清屏
^a 光标移动到行首
^e 光标移动到行尾
^r 搜索历史命令
历史命令 history (能查到以前的命令记录+当前登录后使用的命令记录)
history -c 清空历史命令
cat ~/.bash_history 查看历史命令保存文件(不受-c影响)(不能查到当前登录后使用的命令记录)
!55 使用历史命令(55为第55条历史命令)
默认保存1000条,可以修改/etc/profile中的HISTSIZE=2000
^r 搜索历史命令
别名
alias 查看别名
which ll 查看指定命令别名/所在路径,(ll为想要查看的命令)
alias sb='cat /etc/sysconfig/network-scripts/ifcfg-ens33' 定义别名,临时生效
unalias 取消别名
查看系统版本信息
cat /etc/redhat-release
uname -a
uname -r (只看内核版本)
更改主机名
vim /etc/hostname (method1)
hostnamectl set-hostname web01 (method2)
更改开机启动级别
systemctl set-default multi-user.target (更改开机启动级别为3)
查看系统时间
date (CST东八区,UTC世界标准时间,CST比UTC早8小时)
date "+%Y-%m-%d %H:%M:%S" (定义显示格式)
date -s "2011-11-11 11:11:11"
查看硬件时间
hwclock
hwclock -w 将系统时间写入硬件
hwclock -s 将硬件时间写入操作系统
查看内存
free
free -m 以兆为单位
查看cpu,进程,内存
top
NTP同步时间
ntpdate ntp1.aliyun.com
timedatectl set-ntp false (关闭NTP)
若遇到域名ping不通,关闭NetworkManager
systemctl stop NetworkManager
systemctl diasble NetworkManager
systemctl restart network 重启网络服务
关机
init 0
poweroff
shutdown -h 10 (10分钟后关机)
shutdown -c (取消定时关机任务)
shutdown -h 0
shutdown -h now
halt (关操作系统,不断电。需要手动断电)
重启
reboot
init 6
shutdown -r 10/0/now
ps aux | wc -l 统计进程数
df -h 查看文件系统(硬盘对应的挂载点)
ip addr (或者ifconfig,需要按net-tools包) 查看ip
vim /etc/sysconfig/network-scripts/ifcfg-ens32 配置网卡
du -sh 统计文件(目录)大小
更改环境变量
vim /etc/profile 开机后启动shell,在当前shell加载各种文件
PATH=$PATH:/test 添加PATH
export PATH 让其他进程开启的子shell继承PATH变量

浙公网安备 33010602011771号