mohangraj
mohangraj

Reputation: 11044

Builtin Commands in Unix

In Unix or Unix like systems, The command is in the type of "shell builtin". The commands like cd, echo are shell builtin. Is there any way to list all the shell builtin commands or Is there any command available to list all the builtin command of the shell ?

Upvotes: 2

Views: 288

Answers (4)

Alvaro Gutierrez Perez
Alvaro Gutierrez Perez

Reputation: 3877

just type help on the shell, and a list will appear

Upvotes: 0

Walter A
Walter A

Reputation: 20002

TAB shows the available commands, from PATH and builtins.
Reset your PATH and enter [TAB] twice and answer y

$ PATH=
$ [TAB][TAB]
Display all 123 possibilities? (y or n)
-                         compgen                   fg                        _ooexp_                   spwd
:                         complete                  fi                        path                      startx
!                         compopt                   for                       _pkcon                    _strip
.                         _compreply_               function                  __pkconcomp               suspend
..                        continue                  _gdb_                     _pkcon_search             test
...                       coproc                    getopts                   popd                      then
[                         __dbus_send               hash                      ppwd                      time
[[                        declare                   help                      printf                    times
]]                        dir                       history                   pushd                     trap
{                         dirs                      if                        pwd                       true
}                         disown                    in                        rd                        type
+                         do                        jobs                      read                      typeset
alias                     done                      kill                      readarray                 ulimit
beep                      echo                      l                         readonly                  umask
bg                        elif                      la                        rehash                    unalias
bind                      else                      let                       remount                   unmount
break                     enable                    ll                        return                    unset
builtin                   esac                      local                     _scout                    until
caller                    eval                      logout                    _scpm                     wait
case                      exec                      ls                        select                    while
cd                        exit                      ls-l                      set                       _yast2
_cd_                      _exp_                     _man_                     shift                     you
cd..                      export                    mapfile                   shopt                     _zypper
command                   false                     md                        skipthis
command_not_found_handle  fc                        o                         source

Upvotes: 0

It depends upon the shell. So read the documentation of your particular shell.

For bash, see here.

For zsh, see here.

For fish, see this.

For tcsh(which I don't recommend, STFW for csh considered harmful), see here.

For the POSIX shell specification, read that. If you want to code somehow "portable" shell scripts, you should restrict yourself to that specification.

Some rescue shells have many builtins, to be useful on a severely corrupted or broken system which e.g. has no more any /bin/mv or /bin/cp executables. For example sash.

Some shells are able to load plugins (somehow possibly defining new builtins), or to define functions.

Some shells have a restricted form, which removes some builtins (notably cd). For restricted bash see here.

Upvotes: 1

fab
fab

Reputation: 1859

Look up the man page for your shell. There should be a section "SHELL BUILTIN COMMANDS"

$ man bash

Upvotes: 1

Related Questions