第六章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 passwd6.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 disk6.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 files6.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=
linux命令行入门(二) 《The Linux Command Line》
最新推荐文章于 2021-11-30 15:23:20 发布