Examples of commands I'm referring to are
cd. Also, how are these built? Do you have an example?
It's usually plain
C. The commands
pwd come from the
GNU Coreutils package in (most?) Linux distributions (and maybe some other systems). You can find the code on their homepage.
coreutils specifically, you build them with the usual steps: after unpacking the source, issue:
./configure --prefix=/some/path # type ./configure --help to get the available options make make install # could require root access depending on the path you used
Be carefull - installing base utilities like those over your distribution's copy of them is a bad idea. Use whatever package manager your system comes with for that. You can install to a different prefix though (installing somewhere into your home directory is a good idea if you want to experiment).
Note that although there is a
cd executable, the
cd you'll be using in most circumstances isn't a separate executable. It has to be a shell build-in (otherwise it could not change the shell's current directory - this has to be done by the process itself), so it is written in the same language as the shell (which is often
You can find many more of these online.
Just to add a bit more to Mat's answer, although Unix implements these as standalone programs, many commands are also implemented within
bash (to save it having to spawn a new process) see the
bash man page for more details, or have a look at the shell-builtin tag.
bash is also written in C
It may be worth noting that these commands do not have to be written in C - indeed, several mini linux distribution use
lua implementations of these and others.