Shell commands are written in what language?

The programs are ordinary executable written in any language (mostly C).

The shell takes a command entered which is just a string. It then looks for certain sequences of characters which have special meaning to the shell such as environmental variables which are $ followed by a word or redirects which are > followed by a path. After this substitution has been preformed it has a string which is split on spaces to generate a name of an executable and parameters. The shell will then search for the executable in the list of directory's in the environmental variable PATH. The shell then uses system calls to create a process from the executable with the parameters.

For example to execute the command ls $HOME the shell would first recognize that $HOME is an environmental variable and substitute it for its value in this case /home/user leaving the command ls /home/user. It then splits the command to on the space to get the executable name ls and parameter /home/user. The shell finds the first executable that matches ls usually /bin/ls. It then uses ether the spawn()/ posix_spawn() or fork() and exec() system calls to create the new process.


Most of the basic utilities in linux are written in C .This u can verify in busybox source code which supports most of basic linux command utility which are written in C. So command like ls,cd ...etc are in c

How shell will interpret check in below link

in an operating system there is a special program called the shell. The shell accepts human readable commands and translates them into something the kernel can read and process.

http://www.math.iitb.ac.in/resources/manuals/Unix_Unleashed/Vol_1/ch08.htm


These programs are mainly written in the C programming language as is the linux kernel.