"ls"命令在Linux/Unix中如何工作? [英] How does the 'ls' command work in Linux/Unix?

查看:163
本文介绍了"ls"命令在Linux/Unix中如何工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想确切地知道"Is"命令在Linux和Unix中的工作原理.

I would like to know exactly how the "Is" command works in Linux and Unix.

据我所知,ls fork& exec到Linux/Unix shell,然后获取(当前文件树的输出,例如/home/ankit/).我需要更详细的说明,因为我不确定调用fork之后会发生什么.

As far as I know, ls forks & exec to the Linux/Unix shell and then gets the output (of the current file tree. eg./home/ankit/). I need a more detailed explanation, as I am not sure about what happens after calling fork.

任何人都可以详细解释'ls'命令的功能吗?

Could anyone please explain the functionality of the 'ls' command in detail?

推荐答案

ls不分叉. Shell会分叉并执行,以便运行任何未内置的命令,并且它可以运行的命令之一是ls.

ls doesn't fork. The shell forks and execs in order to run any command that isn't built in, and one of the commands it can run is ls.

ls使用opendir()和readdir()逐步浏览目录中的所有文件.如果需要有关它们之一的更多信息,请调用stat().

ls uses opendir() and readdir() to step through all the files in the directory. If it needs more information about one of them it calls stat().

这篇关于"ls"命令在Linux/Unix中如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆