0
点赞
收藏
分享

微信扫一扫

关于Linux内部命令管理(type、enable、help)

jjt二向箔 2024-10-30 阅读 11
Linux运维

使用type确认一个命令是Linux内部命令还是外部命令

[root@sre01 ~]# type cd
cd is a shell builtin

[root@sre01 ~]# type ls
ls is aliased to `ls --color=auto'

[root@sre01 ~]# type sudo
sudo is /usr/bin/sudo

使用-t参数,返回简写

[root@sre01 ~]# type -t ls
alias
[root@sre01 ~]# type -t sudo
file
[root@sre01 ~]# type -t ls
alias

有一些命令既有内部命令也有外部命令,使用-a列出所有。在命令执行时,shell 先判断是否是内部命令,如果是,则执行内部命令,如果不是,则去特定目录下寻找外部命令。

[root@sre01 ~]# type -a echo
echo is a shell builtin
echo is /usr/bin/echo

enable查看所有内部命令

  • enable cmd #启用 cmd 命令
  • enable -n cmd #禁用内部 cmd 命令
  • enable -n #查看所有禁用的内部命令

[root@sre01 ~]# 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
[root@sre01 ~]# 


help 查看内部命令的帮助

[root@sre01 ~]# help pwd
pwd: pwd [-LP]
    Print the name of the current working directory.
    
    Options:
      -L	print the value of $PWD if it names the current working
    	directory
      -P	print the physical directory, without any symbolic links
    
    By default, `pwd' behaves as if `-L' were specified.
    
    Exit Status:
    Returns 0 unless an invalid option is given or the current directory
    cannot be read.
[root@sre01 ~]# help fg
fg: fg [job_spec]
    Move job to the foreground.
    
    Place the job identified by JOB_SPEC in the foreground, making it the
    current job.  If JOB_SPEC is not present, the shell's notion of the
    current job is used.
    
    Exit Status:
    Status of command placed in foreground, or failure if an error occurs.



举报

相关推荐

0 条评论