zoukankan      html  css  js  c++  java
  • 红帽学习笔记[RHCSA] 第一课[Shell、基础知识]

    关于Shell

    • Shell是什么

    Shell是系统的用户界面,提供了用户与内核进行交互操作的一种接口。它接收用户输入的命令并把它送入内核中执行。

    • bash shell是大多数Linux的缺省shell
    • 交互方式使用shell会显示一个字符
    # root用户是 #
    [root@c2c9702c7e20 /]#
    # 普通用户是 $
    [test@c2c9702c7e20 /]$ 
    
    • 使用shell 需要一个终端:虚拟控制台
    # 如果是图形化界面的
    [CTRL+ALT]+F1 是图形界面
    [CTRL+ALT]F2-F6是5个红帽的虚拟控制台
    #如果是关闭图形化界面
    [CTRL+ALT] F1-F5是5个红帽的虚拟控制台
    

    命令的基础知识

    • 组成
    #命令由三部分组成
    命令:需要运行
    选项:用于调整命令的行为
    参数:通常是命令的目标
    

    在终端中敲命令的快捷键

    	Ctrl+a  : 跳到命令行头部
    ​	Ctrl+e  :跳到命令结尾
    ​	Ctrl+u  :删除到光标前的内容
    ​	Ctrl+k  :删除光标之后的内容
    ​	Ctrl+l : 删除面板上的内容
    ​	Ctrl+r : 查找 history中内容
    

    本次课程涉及的命令

    ls 查看当前目录下的文件以及文件夹的属性。

    ls
    #查看当前文件夹下的n
    [root@localhost /]# ls test
    11.txt  22.txt  33  44
    # ----------------------------
    ls -d test/
    # -d的意义会查看后面这个test目录,如果不加,ls会查看test里面的内容
    [root@localhost /]# ls -d test
    test
    # ----------------------------
    ls -l 等价于 ll
    # -l的意义是长格式查看,会显示权限、所属者、大小等信息
    [root@localhost /]# ls -l test
    total 0
    -rw-r--r--. 1 root root 0 Aug 25 11:21 11.txt
    -rw-r--r--. 1 root root 0 Aug 25 11:22 22.txt
    drwxr-xr-x. 2 root root 6 Aug 25 11:22 33
    drwxr-xr-x. 2 root root 6 Aug 25 11:22 44
    # ----------------------------
    ls -a 
    # -a会显示隐藏文件
    [root@localhost /]# ls -a test
    .  ..  11.txt  22.txt  33  44
    # ----------------------------
    ls -R 
    # 递归显示目录
    [root@localhost /]# ls -R test
    test:
    11.txt  22.txt  33  44
    
    test/33:
    
    test/44:
    

    mkdir创建文件夹

    mkdir -p /test/11/22/33
    # -p参数会根据需要创建父级文件夹。以上,如果不-p的话 由于11文件夹不存在创建会失败
    

    passwd修改密码

    [root@localhost /]# passwd
    Changing password for user root.
    New password: 
    Retype new password: 
    passwd: all authentication tokens updated successfully.
    

    date查看日期

    # 查看当天
    [kane@localhost /]$ date
    Mon Aug 26 15:01:53 CST 2019
    # 查看未来45天
    [kane@localhost /]$ date -d "+45days"
    Thu Oct 10 15:01:59 CST 2019
    

    file扫描内容的开头,显示文件类型。

    [root@localhost /]# file test
    test: directory
    [root@localhost /]# file test/11.txt 
    test/11.txt: ASCII text, with very long lines
    

    head用来显示文件的开头

    默认前10行。可以通过-n 设定显示行数。也可以直接-number

    [root@localhost test]# head 22.txt 
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    [root@localhost test]# head -1 22.txt 
    1
    [root@localhost test]# head -n 2 22.txt 
    1
    2
    

    tail显示文件末尾

    默认显示前10行。其他的与head类似,除了-f

    [root@localhost test]# tail -f 22.txt 
    6
    7
    8
    9
    10
    11
    12
    13
    14
    #除了显示尾10行之外,还会监测22.txt文件的变化并输出到屏幕上。
    

    wc计算文件见行数、字数、字符数

    [root@localhost test]# wc 22.txt 
    15 14 34 22.txt
    #行 字 字符 文件   
    #-l 单独行数 -w单独字数 -c单独字符数
    

    history!历史记录,快速使用历史命令

    [root@localhost test]# history
      225  head 22.txt 
      226  head -1 22.txt 
      227  head -n 2 22.txt 
      228  head --help
      229  tail -f 22.txt 
      230  wc 22.txt 
      231  wc -l
      232  wc -l 22.txt 
      233  wc -w 22.txt 
      234  wc -c 22.txt 
      235  history
    # 使用编号为234的历史命令
    [root@localhost test]# !234
    wc -c 22.txt 
    34 22.txt
    # 使用首字母是wc的最后一个命令
    [root@localhost test]# !wc
    wc -c 22.txt 
    34 22.txt
    # 清除历史记录
    history -c   # 重启后历史记录还在
    # 删除某个编号的历史记录
    history -d 234
    

  • 相关阅读:
    计算机网络基础
    OA项目(MVC项目)
    修改XML的节点内容
    项目实战-电商(网上书城)
    DataTables ajax bootstrap 分页/搜索/排序/常见问题
    DNS服务器解析域名的过程
    bootstrap 模态框
    QuickChm 制作chm文档 chm文档脚本错误,乱码
    poi 读取word文档
    commons -lang(2) RandomStringUtils RandomUtils
  • 原文地址:https://www.cnblogs.com/primadonna/p/11422315.html
Copyright © 2011-2022 走看看