Linux运维 day 07

一、shell基础命令

shell命令
shell解释器
操作系统(系统端口,内核)
计算机硬件

shell命令语法:
命令+选项+参数
  ls -l /boot
  命令是必须的,选项参数是可有可无的,如果不加上选项参数,系统会按照默认的选项参数运行命令
~:当前用户的家目录
#:当前用户数超级管理员用户
$: 普通用户
useradd +用户名:添加用户
passwd +用户名:交互式设置用户密码
echo “123” | passwd +用户名 --stdin:非交互式设置密码
cd +文件路径:切换到目标文件夹下
[root@localhost ~]# cd /boot/
[root@localhost boot]#

pwd:查看当前所在文件夹
[root@localhost boot]# pwd
/boot

ls :查看目标文件下的子文件夹
[root@localhost boot]# ls /etc/sysconfig/network-scripts/ifcfg-ens33
/etc/sysconfig/network-scripts/ifcfg-ens33

date:查看时间
date +%”:修改时间格式  
date -s:修改系统时间
[root@localhost ~]# date
20210622星期二 15:34:29 CST
[root@localhost ~]# date "+%Y-%m-%d %H:%M:%S"
2021-06-22 15:35:08
#设置时区
timedatectl list-timezones (查看时区列表)
timedatectl set-timezones “Asia/Shanghai”
cat +文件路径:查看目标文件下的内容
hwclock -w:将系统时间同步给硬件时间
ntpdate ntp1.aliyun.com:将系统时间与时间服务器同步
uname -a:查看系统信息相关的所有内容
uname -r:查看当前系统内核版本
uname -m:查看cpu架构
cat /etc/redhat.release:查看系统版本
#重启
shoutdown -r
init 0
reboot
shoutdown -r 10 (十分钟后重启)
shoutdown -r 11:30(11:30重启)
#关机
shoutdown -h
init6
poweroff
#取消
shoutdown -c
#退出
exit
Ctrl+D

二、bash解释器交互式环境特性

1.Tab:自动补全命令
2.快捷键:
       ^c 终止前台运行的程序
       ^d 退出 等价exit
       ^l 清屏
       ^a 光标移到命令行的最前端
       ^e 光标移到命令行的后端
       ^r 搜索历史命令,利用关键词
       Alt+. 引用上一个命令的最后一个参数,等价于!$
3.history:查看历史命令
   history -c:清空历史命令
   /.bash_history:历史命令保存文件
4.历史命令默认保存1000条,可以修改/etc/profile中的HISTSIZE=2000
5、查找历史命令并运行
(1)光标上下键
(2)^r //搜索历史命令(输入一段某条命令的关键字:必须是连续的)
(3)!220 //执行历史命令中第220条命令
(4)!字符串 //搜索历史命令中最近一个以xxxx字符开头的命令,例如!ser
(5)!$ //引用上一个命令的最后一个参数
  [root@xxx home]# ls /root /home
  [root@xxx home]# cd !$
   cd /home

  [root@xxx home]# ls /root /home
  [root@xxx home]# touch !$/file1
   touch /home/file1
   别名
   别名
   # alias //查看系统当前的别名
   ll='ls -l --color=tty'
   # alias egon='ls /etc/sysconfig/network-scripts/' //建立别名
   # unalias egon
   
  [root@xxx ~]# grep root /etc/passwd // 默认有颜色
  [root@xxx ~]# alias grep
   alias grep='grep --color=auto'

 

posted @ 2021-06-25 12:34  c-j-z  阅读(117)  评论(0)    收藏  举报