Where to find sources of UNIX commands???


 
Thread Tools Search this Thread
Top Forums Programming Where to find sources of UNIX commands???
# 1  
Old 12-19-2011
Where to find sources of UNIX commands???

Dear friends,
I believe that all unix commands are programs which are written in c language, please correct me if I am wrong. Now suppose that I want to see the c source of common commands like echo, ls, mkdir etc, where I can I find the source, linux is open source I believe, so the source for indivisual commands should be available.

Thanks
# 2  
Old 12-19-2011
Linux, to be pedantic, is just a kernel. You can find the source for that @ The Linux Kernel Archives. However, that does not include all of the bits that make a linux distribution a usable operating system. The source for the shells, toolchain, and the usual userland suspects (cat, head, cp, mv, etc ...) are located elsewhere. Most of those peripheral yet crucial tools are developed by the gnu project; for example, GNU Coreutils @ Coreutils - GNU core utilities.

If GNU/Linux source is not required, if instead you're interested in UNIX in general, you will find that browsing and studying *BSD source is a lot simpler. A BSD project develops its kernel, C library, and standard utilities as part of one consolidated development effort (with the notable exception that they depend on the GNU C compiler toolchain), while the linux kernel, the GNU C library, and the standard utilities which form the core of a linux distro are each developed by different people.

For a *BSD system, all of the source is available in one central repository, while the original sources for a GNU/Linux distro are many and scattered. If you're using linux and your distribution's package manager does not make source available, you will need to track down the sources of its source independently.

A bonus for beginners is that the BSD sources are simpler than their GNU equivalents. While a BSD project's code only needs to support their own operating system, GNU tools, not being part of a larger system, endeavour to support many operating systems. Further, GNU projects tend to be more cavalier about extending the POSIX standard. In conjunction, these lead to GNU code being more complicated and difficult to understand than its BSD equivalents.

A typical example (I did not cherry-pick an aberration), the "simple" head(1) utility, which by default reads the first ten lines of input and exits:

OpenBSD head.c: ~100 lines: src/usr.bin/head/head.c - annotate - 1.15
GNU head.c: ~1000 lines: coreutils.git - GNU coreutils

Whatever you choose to study, enjoy. Not many disciplines provide such unfettered access to the work of accomplished practitioners.

Regards,
Alister

P.S. If any of the preceding message seems anti-Linux or BSD-fanboi-ish, it is nothing of the sort. Please re-read it through a neutral lens. I have no agenda. Anyone familiar with both codebases will know that these statements are accurate, objective facts. And, anyone familiar with me knows that it took astounding effort on my part to not mention GNU's 2-space indent style Smilie.
These 2 Users Gave Thanks to alister For This Post:
# 3  
Old 01-05-2012
You can find many sources in internet like - Linux / UNIX source Command Examples , source - Linux Command - Unix Command . Where you can find the Unix commands.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find commands help

hi gurus, I need a example. I am looking for a source code. where I got the keyword "altria_fetch" and also the keyword is present in the file ".pc" files. and it is present in the directory /fast folder. Inside fast there are lot of sub directories present on it. I am not sure how to reach... (8 Replies)
Discussion started by: ramkumar15
8 Replies

2. Shell Programming and Scripting

Help me to find a solution using UNIX commands

I have the below requirement. below is the content of the input file and my expected result Input file: a.txt <?xml version="1.0" encoding="UTF-8"?> <Employee> <Name>XXXX</Name> <ID>1233</ID> </Employee> <?xml version="1.0" encoding="UTF-8"?> <Employee> <Name>YYYY</Name> <ID>1345</ID>... (2 Replies)
Discussion started by: kmanivan82
2 Replies

3. UNIX for Dummies Questions & Answers

Beginner UNIX question. tail and find commands

hey guys, i'm in a unix course.. and while this is a homework question - i did put alittle effort into it. just wanted to ask before trial and error drives me nuts. question 13 has us saving the last 30 characters of a file into another file and question 14 has us saving the list of all the... (1 Reply)
Discussion started by: labelthief
1 Replies

4. UNIX for Dummies Questions & Answers

Need to modify a delimited file using UNIX commands. Please find description

i have a '|' delimited file having 4 fields. now i want to sort the data by combination of first three fields without changing order of 4th field. input file looks like this: 3245|G|kop|45 1329|A|uty|76 9878|K|wer|12 3245|G|kop|15 1329|A|uty|56 9878|K|wer|2 3245|G|kop|105... (4 Replies)
Discussion started by: ankurgoyal2408
4 Replies

5. UNIX for Advanced & Expert Users

I need help to find some unix commands

Hey everyone, I need some help for some unix commands. - List all processes in the file "ProcessUser.txt" sorted by the users and in the file "ProcessName.txt" sorted by the name of the process. - How much time does the command "ls -alR /" need and compared to that, how much time is... (2 Replies)
Discussion started by: ZOCKER3000
2 Replies

6. Shell Programming and Scripting

find filenames like unix commands

Hi, I need to write a small script to search in some specific directories to check if any file is present with a unix command name... Means if the directory contains any files like cat, vi, grep, find etc i need to list those files into a file. Please help Thanks, D (6 Replies)
Discussion started by: deepakgang
6 Replies

7. UNIX for Dummies Questions & Answers

Unix Find commands

thank you for the help (1 Reply)
Discussion started by: scooter17
1 Replies

8. UNIX Desktop Questions & Answers

where i can find list of UNIX commands for daily operations ?

Hi There, Can anyone help, where i can find list of UNIX commands just for regulat day ro day operations Thanx MGR (1 Reply)
Discussion started by: mgoutham
1 Replies

9. UNIX for Dummies Questions & Answers

unix sources

hello, i'm looking for the sources of the old, original unices (v3 preferred). could someone point a link? (2 Replies)
Discussion started by: fdarkangel
2 Replies

10. UNIX for Dummies Questions & Answers

Where do I find what commands I can use?

I am new to this unix thing. I have a macintosh with os X and want to learn how to use the unix terminal. What do I need to get started? Does anyone know some good command lines to get started with? Can I use the terminal to check email and get on the internet etc.....?:( (3 Replies)
Discussion started by: JCWorkman
3 Replies
Login or Register to Ask a Question