免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 6576 | 回复: 9
打印 上一主题 下一主题

linux下怎么查看有那些内部命令 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-10-19 21:50 |只看该作者 |倒序浏览
请问下大家在linux下面那么多内部命令,请问用什么命令能够看到有那些命令是内部的命令?
比如pwd cd等就是内部命令

论坛徽章:
0
2 [报告]
发表于 2008-10-19 22:29 |只看该作者
别管它是内部还是外部命令,好用就行

论坛徽章:
1
处女座
日期:2014-12-23 17:59:27
3 [报告]
发表于 2008-10-19 22:51 |只看该作者
type  faint 还有长度限制。

论坛徽章:
4
白银圣斗士
日期:2015-11-24 10:40:40技术图书徽章
日期:2015-11-26 13:47:47平安夜徽章
日期:2015-12-26 00:06:30技术图书徽章
日期:2016-07-19 13:54:03
4 [报告]
发表于 2008-10-19 22:56 |只看该作者
还真没考虑过这个问题...知道的来解释下

论坛徽章:
0
5 [报告]
发表于 2008-10-20 06:05 |只看该作者
我這邊有rh-based跟mandriva的系統

man builtins

  1. BASH_BUILTINS(1)                                              BASH_BUILTINS(1)

  2. NAME
  3.        bash,  :,  ., [, alias, bg, bind, break, builtin, cd, command, compgen, complete, continue, declare, dirs, disown, echo, enable, eval,
  4.        exec, exit, export, fc, fg, getopts, hash, help, history, jobs, kill, let, local, logout, popd, printf, pushd,  pwd,  read,  readonly,
  5.        return, set, shift, shopt, source, suspend, test, times, trap, type, typeset, ulimit, umask, unalias, unset, wait - bash built-in com-
  6.        mands, see bash(1)
复制代码

论坛徽章:
34
亥猪
日期:2015-03-20 13:55:11戌狗
日期:2015-03-20 13:57:01酉鸡
日期:2015-03-20 14:03:56未羊
日期:2015-03-20 14:18:30子鼠
日期:2015-03-20 14:20:14丑牛
日期:2015-03-20 14:20:31辰龙
日期:2015-03-20 14:35:34巳蛇
日期:2015-03-20 14:35:56操作系统版块每日发帖之星
日期:2015-11-06 06:20:00操作系统版块每日发帖之星
日期:2015-11-08 06:20:00操作系统版块每日发帖之星
日期:2015-11-19 06:20:00黄金圣斗士
日期:2015-11-24 10:43:13
6 [报告]
发表于 2008-10-20 10:32 |只看该作者
/bin和/sbin里面的似乎都是内部命令,/usr里面是外部。

论坛徽章:
0
7 [报告]
发表于 2008-10-20 10:48 |只看该作者
原帖由 vermouth 於 2008-10-20 10:32 發表
/bin和/sbin裡面的似乎都是內部命令,/usr裡面是外部。


我想不是這樣的吧 ,所謂的內部命令是寫在bash原始碼裡面的(這邊假設談的是bash),你要修改這些內部命令除非透過修改bash的原始碼。

而外部命令才是bash之外自己額外安裝的,比方通常在/bin, /usr/bin, /sbin, /usr/sbin.....等。

例如:type是個內建命令。
  1. # type type
  2. type is a shell builtin

  3. # echo $PATH
  4. /sbin:/usr/sbin:/usr/local/sbin:/root/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/games:/opt/kde3/bin:/usr/lib/jvm/jre/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin

  5. # which type
  6. which: no type in (/sbin:/usr/sbin:/usr/local/sbin:/root/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/games:/opt/kde3/bin:/usr/lib/jvm/jre/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin)
复制代码


上面很容易發現,type是個內建命令。
我這邊用的是opensuse。

论坛徽章:
0
8 [报告]
发表于 2008-10-20 11:08 |只看该作者
1, cd是内部命令, 我想你应该清楚的. 那么你键入"man cd"后所进入的帮助的前几行就是所有的built-in命令, 其实你man任何一个built-in命令进入的都是同一个man.
2, 那么,命令一共有几类呢? 一共是5类, 即:
alias, keyword, function, built-in,$PATH
3, 当你键入一个命令时, 搜索到该命令的顺序也是按照上面的罗列顺序来搜索的.
4, 请记住, 命令和shell是密不可分的, 谈命令机制肯定离不开shell.

alias command
Setting: ~/.bashrc,/etc/bashrc
Shell keyword (such as if,while,until,case,for)
Function:
Example:function pwd { echo "my function pwd"; }
Shell built-in command
Run command enable to see
help command for help
PATH variable
Setting: /etc/profile, /etc/profile.d/*.sh(POSIX)
~/.bash_profile(Bash)
Load order: 1, /etc/profile (invoke /etc/profile.d/*.sh)
~/.bash_profile (invoke ~/.bashrc, then
~/.bashrc invoke /etc/bashrc)
(Note: su, su-, bash –login, bash --norc)
Include: Shell script, Binary execute file

论坛徽章:
0
9 [报告]
发表于 2008-10-20 12:36 |只看该作者
内部,外部,是dos下的概念吧。

linux的内部是指shell本身的命令,其他程序的命令就算是外部吧。

论坛徽章:
0
10 [报告]
发表于 2008-10-20 13:50 |只看该作者
几乎除了ls cd等,大部分是"
外部命令"
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP