简体   繁体   English

linux命令的内部工作

[英]Internal working of linux command

If I want to know the internal working of any linux command then from where I will get the information about that? 如果我想知道任何linux命令的内部工作,那么我将从哪里获得有关它的信息? Actually I want to know the internal working of aplay command. 其实我想知道aplay命令的内部工作。 By executing aplay command what processes occurs in the linux kernel ? 通过执行aplay命令,Linux内核中会发生什么进程?

Command in the Linux are at the user level. Linux中的命令是用户级别的。 So when we execute the command from the user level it will interact with the kernel layer. 因此,当我们从用户级执行命令时,它将与内核层交互。 This interaction is done via the system calls. 此交互通过系统调用完成。

To get what system call is executing internally you can use the user space utility "strace". 要获取内部执行的系统调用,可以使用用户空间实用程序“strace”。 strace will give the system trace. strace将给出系统跟踪。 Following command you can use: 以下命令可以使用:

$script

$strace <command> <argument>

$exit

script utility create a file, named "typescript" in current working directory which contains the output of strace. 脚本实用程序在当前工作目录中创建一个名为“typescript”的文件,其中包含strace的输出。

Now from the strace you will get the what all system call your command is executing. 现在,从strace中,您将获得所有系统调用您的命令正在执行的操作。 Now you need the kernel source to track actually what are internal processing is going on in the kernel. 现在,您需要内核源来实际跟踪内核中正在进行的内部处理。

You also can use the systemtap and kgdb linux utilities. 您还可以使用systemtap和kgdb linux实用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM