Where to find the code for the terminal commands?
Where to find the code for the terminal commands?
Where to find it depends on the command. There are several locations.
Regarding the two you mention:
GNU coreutils
ls
is part of GNU Coreutils. You can get the source code for all the GNU core utilities (so not just for ls
: wikipedia list of core utilities) on www.gnu.org. From the command line using git (git
needs to be installed):
git clone git://git.sv.gnu.org/coreutils
The source for ls
can also be found online on git.savannah.gnu.org. All the other commands are accessible there too.
- Shell builtins
cd
is a built-in in the shell so is part of bash
. You can find the source code for bash on ftp.gnu.org. That will also be the source code for all builtins.
bash defines the following built-in commands: :, ., [, alias, bg, bind, break, builtin, case, cd, command, compgen, complete, continue, declare, dirs, disown, echo, enable, eval, exec, exit, export, fc, fg, getopts, hash, help, history, if, jobs, kill, let, local, logout, popd, printf, pushd, pwd, read, readonly, return, set, shift, shopt, source, suspend, test, times, trap, type, typeset, ulimit, umask, unalias, unset, until, wait, while.
In what language are those programs written?
C or C++
With that I would like to get into modifying existing programs and writing new ones
You are better off using the existing tools and adding to them: create a script called ls2
and then add functionality to that script to mimic ls
+ your additions. Your additions could be extra letters as parameters that trigger functions. Biggest advantage: you can write it in the language you prefer. Safer since you do not mess with the normal commands if your intention is to code new functionality for your these tools you should join their respective mailing lists.