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

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

问题描述

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

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

据我所知,ls forks &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 fork 和 execs 是为了运行任何未内置的命令,它可以运行的命令之一是 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天全站免登陆