I'm trying to understand some kernel level concepts in Linux. I was checking on the difference between shell builtin commands and the other executable commands.
This wonderful answer clearly tells the difference and also specifies the need for shell builtin commands.
Now I know that using type <command-name>, I could check if it is an external or shell builtin command.
So I decided to do some strace'ing on the various commands to understand more of the internals.
I learned this neat little trick to do strace'es on shell builtin commands. I was able to do strace on cd .. as well according to the above answer.
Now when I run type pwd and get the output as, pwd is a shell builtin. So, I expect that I wouldn't be able to run strace on it, since it too is a shell builtin. But when I did an strace on it, I was surprised to see that strace worked without the need to do stty.
I verified strace for echo as well and it worked fine too.
So my understanding is, that strace worked in the case of pwd and echo because the execution of pwd and echo did not change any of the shell's behavior.
Am I correct in my understanding?
echoandpwdare 2 such commands, so you're stracing the standalong counterparts and not the built-ins when you did the above tests.type -a.strace, chances are thatstrace cdwill work withoutstty. Is this understanding correct?straceit. But aliases and functions etc. are built into Bash and cannot be straced, since you'd have tostraceBash itself to watch them.strace. There are no system calls to trace for a builtin since it's doing everything internal to Bash.