linux命令行入门(二) 《The Linux Command Line》

第六章6-使用命令

6.1 什么是命令?
        可执行程序、shell自身命令、shell函数、命令别名‘共4种类型

6.2 识别命令
        使用 type 命令可以区分 4种类型

6.3 type(显示命令的类型)
        [seven@localhost ~]$ type command
        command is a shell builtin
        [seven@localhost ~]$ type cd
        cd is a shell builtin
        [seven@localhost ~]$ type ls
        ls is aliased to `ls --color=auto`    
        [seven@localhost ~]$ type cp
        cp is hashed (/bin/cp) 
 
6.4 which-显示一个可执行程序的位置
        shell 内部命令无效,只对可执行程序有效
        [seven@localhost ~]$ which cp
        /bin/cp
        [seven@localhost ~]$ which ls
        alias ls='ls --color=auto'
            /bin/ls
          
        [seven@localhost ~]$ which cd
        /usr/bin/which: no cd in (/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/seven/bin)

6.5 得到命令文档
        文档有时候可以帮助我们使用命令

6.6 help(得到shell内部命令的帮助文档)
        [seven@localhost ~]$ help cp
        bash: help: no help topics match `cp'.  Try `help help' or `man -k cp' or `info cp'.
        [seven@localhost ~]$ help cd
        巴拉巴拉。。。

6.7 --help -显示用法信息
        用于许多可执行程序
        [seven@localhost ~]$ help cd --help
        cd: cd [-L|-P] [dir]
            Change the shell working directory.
            
6.8 man-(显示程序手册页)
        可执行程序的正式使用手册
        [seven@localhost ~]$ man program
        Cannot open the message catalog "man" for locale "zh_CN.UTF-8"
        (NLSPATH="/usr/share/locale/%l/LC_MESSAGES/%N")

        No manual entry for program
        [seven@localhost ~]$ man ls

        [seven@localhost ~]$ man section search_term
        Cannot open the message catalog "man" for locale "zh_CN.UTF-8"
        (NLSPATH="/usr/share/locale/%l/LC_MESSAGES/%N")

        No manual entry for section
        No manual entry for search_term
        [seven@localhost ~]$ man 5 passwd

6.9 apropos-(显示恰当的命令)
        基于某个关键字的匹配项,搜索参考手册显示结果
        字段从左到右依次是 手册页名字、章节、描述
        [seven@localhost ~]$ apropos floppy
        fd                   (4)  - floppy disk device
        fdformat             (8)  - Low-level formats a floppy disk
        floppy               (8)  - format floppy disks
        mbadblocks           (1)  - tests a floppy disk, and marks the bad blocks in the FAT
        mformat              (1)  - add an MSDOS filesystem to a low-level formatted floppy disk

6.10    whatis-(显示非常简洁的命令说明)
        显示匹配关键字的手册页的名字和一行命令说明
        [seven@localhost ~]$ whatis ls
        ls                   (1)  - list directory contents
        ls                   (1p)  - list directory contents
        [seven@localhost ~]$ whatis cp
        cp                   (1)  - copy files and directories
        cp                   (1p)  - copy files

6.11    info-(显示程序Info条目)
        手册页的替代品,info页是超链接的形式类似网页

6.12    README 和其他程序文档
        位于/usr/share/doc 的文档文件

6.13    用别名alias创建命令
        多个命令用; 分开
        [seven@localhost ~]$ cd /usr;ls;cd -
        bin  games    lib    libexec  sam   share  tmp
        etc  include  lib64  local    sbin  src
        /home/seven
        
        [seven@localhost ~]$ type test
        test is a shell builtin
        [seven@localhost ~]$ type foo
        bash: type: foo: not found
        [seven@localhost ~]$ alias foo='cd /usr;ls;cd -'
        [seven@localhost ~]$ foo
        bin  games    lib    libexec  sam   share  tmp
        etc  include  lib64  local    sbin  src
        /home/seven

        [seven@localhost ~]$ unalias foo

        [seven@localhost ~]$ type ls
        ls is aliased to `ls --color=auto'
        [seven@localhost ~]$ unalias ls
        [seven@localhost ~]$ type ls
        ls is hashed (/bin/ls)
        [seven@localhost ~]$ ls
        passwd    picturess  公共的  模板  视频  图片  文档  下载  音乐  桌面
        [seven@localhost ~]$ alias ls='ls --color=auto'

        [seven@localhost ~]$ alias
        alias l.='ls -d .* --color=auto'
        alias ll='ls -l --color=auto'
        alias ls='ls --color=auto'
        alias vi=

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值