Commands in Linux can be broadly divided into two categories, internal commands and external commands
Internal command: Also known as Shell Inline command;
External command: stored in a file, used to go to the file to find, these files are defined in the $path
[Email protected] ~]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
The type command can view the command type to distinguish between internal and external commands
Cases
[[Email protected] ~]# type cd
CD is a shell builtin
[[Email protected] ~]# type ls
LS is aliased to ' LS--color=auto '
[Email protected] ~]# type Ifconfig
Ifconfig Is/usr/sbin/ifconfig
As you can see, the CD is the shell inline command, the LS command is the alias of the LS--color=auto, and the Ifconfig command is the external command in the file/usr/sbin/ifconfig.
Differences between internal commands and external commands for viewing help
Internal command:
Use the Help COMMAND
[[email protected] ~]# Help CD
CD:CD [-l|[ -P [-e]] [dir]
Change the shell working directory.
......
You can also use the Man command to view bash Help documentation
The Enable command can disable internal commands;
Enable-n Internal command: Disable internal commands (restart invalidation)
: Enable-n CD
Enable internal command: de-disable
: Enable CD
External command:
External commands the method of viewing help is relative to the internal command or more
①command--help or Command-h
Different commands exist some practical long options--help or short option-H differences
Example: [[email protected] ~]# ifconfig--help
Usage:
Ifconfig [-A] [-v] [-S] <interface> [[<af>] <address>]
[Add <address>[/<prefixlen>]]
......
② Use man manual to view Help, Man command
Example: [[email protected] ~]# man ifconfig
IFCONFIG (8) Linux System Administrator ' s Manual IFCONFIG (8)
NAME
Ifconfig-configure a network interface
......
③ using the Info command to view the information page
Example: [[email protected] ~]# Info ifconfig
File: *manpages*, Node:ifconfig, Up: (dir)
IFCONFIG (8) Linux System Administrator ' s Manual IFCONFIG (8)
NAME
Ifconfig-configure a network interface
......
④ using the program's own Help documentation
In some programs some readme INSTALL changelog file, you can view the contents of the file to help use.
Official document or release of the ⑤ program
Using external commands is temporarily in memory and can be used to view external commands in memory using the hash command
Hash command: View external commands executed in memory,
Hash:hash [-LR] [-P pathname] [-DT] [name ...]
Remember or display program locations.
Options:
-R: Clear in-memory commands
-d command: Deleting command commands in memory
Sometimes we often use some very long commands, in order to facilitate the use of aliases we can use to rename the command, create aliases can use the alias command, directly execute the alias command to view the current file system alias list,
Command aliases alias name command
Example: Alias cp= ' Cp-i '
The LS command is an alias already seen above;
command also has a case with the same name, so there is a priority in executing the command
Aliases > Internal commands > External commands in Memory > external commands
If you want to use a lower-priority command, you can use the full path or \command to implement it.
This article is from the "Minimonster" blog, make sure to keep this source http://groot.blog.51cto.com/11448219/1829045
Internal commands and external commands in Linux