linux的帮助命令(man帮助和内部命令和外部命令)、别名和常用快捷键

man 获得帮助信息

  1. 基本语法
    man [命令或配置文件] (功能描述:获得帮助信息)

  2. 显示说明

信息功能
NAME命令的名称和单行描述
SYNOPSIS怎样使用命令
DESCRIPTION命令功能的深入讨论
EXAMPLES怎样使用命令的例子
SEE ALSO相关主题(通常是手册页)
?查找向前查找,如 ?and ,将会搜索含有“and”的行
/查找向后查找,如 /and ,将会向后搜索“and”的行
N或者n查找上一个和下一个
q退出
  1. man章节

    1.用户命令
    2.系统调用
    3.C库调用
    4.设备文件及特殊文件
    5.配置文件格式
    6.游戏
    7.杂项
    8.管理类命令
    9.linux内核api

    帮助文档放在:/usr/share/man中

  2. 查看man帮助在那些man章节号
    whatis 命令
    使用:

[root@hadoop100 ~]# whatis date
date                 (1)  - print or set the system date and time
date                 (1p)  - write the date and time
[root@hadoop100 ~]# whatis cd
cd                   (1p)  - change the working directory
cd [builtins]        (1)  - bash built-in commands, see bash(1)
cd-drive             (1)  - manual page for cd-drive
cd-info              (1)  - manual page for cd-info
cd-paranoia 9.8 (Paranoia release III via libcdio) [cd-paranoia] (1)  - an audio CD reading utility which includes extra data verification features
cd-read              (1)  - manual page for cd-read version 0.81
[root@hadoop100 ~]# man 1 date //man 章节号 命令
[root@hadoop100 ~]# whatis password
password-auth-ac [system-auth-ac] (5)  - Common configuration files for PAMified services written by authconfig(8)
[root@hadoop100 ~]# man 5 password //查看password文件的格式

which 命令
:查看路径,都有情况下显示按PATH显示,找到后不搜索
which -a 命令
:所有路径下的全显示

[root@hadoop100 ~]# which -a ls
alias ls='ls --color=auto'
	/bin/ls

where is 命令
显示路径和man帮助的文档路径

  1. 案例
    (1)查看ls命令的帮助信息
[root@hadoop101 ~]# man ls

help获得shell内置命令的帮助信息

  1. 基本语法
    help 命令 (功能描述:获得shell内置命令的帮助信息)

  2. help 列出所有内部命令的用法
    加上*的是禁用的

[root@hadoop100 ~]# help
GNU bash, version 4.1.2(1)-release (x86_64-redhat-linux-gnu)
These shell commands are defined internally.  Type `help' to see this list.
Type `help name' to find out more about the function `name'.
Use `info bash' to find out more about the shell in general.
Use `man -k' or `info' to find out more about commands not in this list.

A star (*) next to a name means that the command is disabled.

 job_spec [&]                                                                                   history [-c] [-d offset] [n] or history -anrw [filename] or history -ps arg [arg...]
 (( expression ))                                                                               if COMMANDS; then COMMANDS; [ elif COMMANDS; then COMMANDS; ]... [ else COMMANDS; ] fi
 . filename [arguments]                                                                         jobs [-lnprs] [jobspec ...] or jobs -x command [args]
 :                                                                                              kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]
 [ arg... ]                                                                                     let arg [arg ...]
 [[ expression ]]                                                                               local [option] name[=value] ...
 alias [-p] [name[=value] ... ]                                                                 logout [n]
 bg [job_spec ...]                                                                              mapfile [-n count] [-O origin] [-s count] [-t] [-u fd] [-C callback] [-c quantum] [array]
 bind [-lpvsPVS] [-m keymap] [-f filename] [-q name] [-u name] [-r keyseq] [-x keyseq:shell-c>  popd [-n] [+N | -N]
 break [n]                                                                                      printf [-v var] format [arguments]
 builtin [shell-builtin [arg ...]]                                                              pushd [-n] [+N | -N | dir]
 caller [expr]                                                                                  pwd [-LP]
 case WORD in [PATTERN [| PATTERN]...) COMMANDS ;;]... esac                                     read [-ers] [-a array] [-d delim] [-i text] [-n nchars] [-N nchars] [-p prompt] [-t timeout>
 cd [-L|-P] [dir]                                                                               readarray [-n count] [-O origin] [-s count] [-t] [-u fd] [-C callback] [-c quantum] [array]>
 command [-pVv] command [arg ...]                                                               readonly [-af] [name[=value] ...] or readonly -p
 compgen [-abcdefgjksuv] [-o option]  [-A action] [-G globpat] [-W wordlist]  [-F function] [>  return [n]
 complete [-abcdefgjksuv] [-pr] [-DE] [-o option] [-A action] [-G globpat] [-W wordlist]  [-F>  select NAME [in WORDS ... ;] do COMMANDS; done
 compopt [-o|+o option] [-DE] [name ...]                                                        set [--abefhkmnptuvxBCHP] [-o option-name] [arg ...]
 continue [n]                                                                                   shift [n]
 coproc [NAME] command [redirections]                                                           shopt [-pqsu] [-o] [optname ...]
 declare [-aAfFilrtux] [-p] [name[=value] ...]                                                  source filename [arguments]
 dirs [-clpv] [+N] [-N]                                                                         suspend [-f]
 disown [-h] [-ar] [jobspec ...]                                                                test [expr]
 echo [-neE] [arg ...]                                                                          time [-p] pipeline
 enable [-a] [-dnps] [-f filename] [name ...]                                                   times
 eval [arg ...]                                                                                 trap [-lp] [[arg] signal_spec ...]
 exec [-cl] [-a name] [command [arguments ...]] [redirection ...]                               true
 exit [n]                                                                                       type [-afptP] name [name ...]
 export [-fn] [name[=value] ...] or export -p                                                   typeset [-aAfFilrtux] [-p] name[=value] ...
 false                                                                                          ulimit [-SHacdefilmnpqrstuvx] [limit]
 fc [-e ename] [-lnr] [first] [last] or fc -s [pat=rep] [command]                               umask [-p] [-S] [mode]
 fg [job_spec]                                                                                  unalias [-a] name [name ...]
 for NAME [in WORDS ... ] ; do COMMANDS; done                                                   unset [-f] [-v] [name ...]
 for (( exp1; exp2; exp3 )); do COMMANDS; done                                                  until COMMANDS; do COMMANDS; done
 function name { COMMANDS ; } or name () { COMMANDS ; }                                         variables - Names and meanings of some shell variables
 getopts optstring name [arg]                                                                   wait [id]
 hash [-lr] [-p pathname] [-dt] [name ...]                                                      while COMMANDS; do COMMANDS; done
 help [-dms] [pattern ...]                                 

禁用命令:
enable -n 命令 :禁用命令
enable 可以进行查看,禁用后不显示
enable 命令:启用内部命令

[root@hadoop100 ~]# enable
enable .
enable :
enable [
enable alias
enable bg
enable bind
enable break
enable builtin
enable caller
enable cd
enable command
enable compgen
enable complete
enable compopt
enable continue
enable declare
enable dirs
enable disown
enable echo
enable enable
enable eval
enable exec
enable exit
enable export
enable false
enable fc
enable fg
enable getopts
enable hash
enable help
enable history
enable jobs
enable kill
enable let
enable local
enable logout
enable mapfile
enable popd
enable printf
enable pushd
enable pwd
enable read
enable readarray
enable readonly
enable return
enable set
enable shift
enable shopt
enable source
enable suspend
enable test
enable times
enable trap
enable true
enable type
enable typeset
enable ulimit
enable umask
enable unalias
enable unset
enable wait

  1. 案例
    (1)查看cd命令的帮助信息
[root@hadoop101 ~]# help cd

获得外部命令的帮助信息

  1. 基本语法
    命令 --help/h :列出命令的帮助
  2. 实例
[root@hadoop100 ~]# date --help

判断内部命令和外部命令

type命令

[root@hadoop100 ~]# type date 
date is hashed (/bin/date) //有存储位置的命令为外部命令
[root@hadoop100 ~]# type cd
cd is a shell builtin //内部命令嵌入在linux的shell中

别名

alias:查看所有别名列表

[root@hadoop100 ~]# alias
alias cp='cp -i'
alias l.='ls -d .* --color=auto'
alias ll='ls -l --color=auto'
alias ls='ls --color=auto'
alias mv='mv -i'
alias rm='rm -i'
alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'

优先级:别名>内部命令>外部命令
which --skip-alias 命令:只显示一条路径,不显示别名信息

[root@hadoop100 ~]# which --skip-alias ls
/bin/ls
[root@hadoop100 ~]# which ls
alias ls='ls --color=auto'
	/bin/ls

路径,如:/bin/ls:不想使用别名,执行原始命令,仅使用于外部命令

[root@hadoop100 ~]# which ls
alias ls='ls --color=auto'
	/bin/ls
[root@hadoop100 ~]# /bin/ls
anaconda-ks.cfg      install.log.syslog  模板  文档  桌面
forlearnsmartd.conf  learndir		 视频  下载
install.log	     公共的		 图片  音乐

‘命令’ 或者 \命令 或者"命令" command 命令
:执行原始命令

unalias 别名:删除别名

在.bashrc 写上alias 别名="命令"即可,但不会立即生效,使用:./source + 文件,读取文件放到内存中使其生效。
/etc/bashrc:放在此文件中,别名对所有用户都生效,但一般不这样做;

常用快捷键

常用快捷键功能
ctrl + c停止进程
ctrl+l清屏;彻底清屏是:reset
ctrl + q退出
善于用tab键补全(更重要的是可以防止敲错)
上下键查找执行过的命令
ctrl +altlinux和Windows之间切换
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值