Linux command review

Today, we review some Linux commands and a little bit C programming.
The first command reviewed is STRACE, which is used to trace system calls and signals.

For example, we can use “strace ls foo” to check ls command on file foo under current directory.
Below is the partial result.

The second command introduced is stat, which is to display some file information. Below example displayed some information about file foo.

The third is to create a C program to do the same function like stat does. Below has the details:

In this version, structure variable “buf” is used. Here if we use pointer variable in structure type, we will need to allocate memory first, otherwise we will have “bad address” exception under strace command. Below has the pointer version.

Now, it comes to the result:

In conclusion, Linux system programming is not that complex as it seems. Get more reading and practice, we will have more understanding about Linux OS.

posted @ 2022-08-18 20:28  blogger2020  阅读(8)  评论(0编辑  收藏  举报