Linux OS (Kernel) Source Code - and Other Linux Software - Linux Commands Training

The Linux OS (kernel) and lots of other Linux software programs are written in source code (a.k.a. code). This is the text version of a program that actually looks a "little bit" human readable.

The source code of a software program is understood and processed into an executable program by

another program called a compiler.

The compiler processes the text of the source code (text file) and "compiles" it so that your computer can understand what to do with it (if the program works!).

The compiled source code becomes an "executable" program file that your system can run. This program file is referred to as a "binary" - and a binary only consists of the binary numbers of 0 and 1 - thousands of them.

Theoretically, it would be possible to actually write programs in binary and skip the step of compiling them. However, humans simply don't think well in 0s and 1s, so writing binary programming would be very time consuming and frustrating indeed.

The purpose of source code is to provide a kind of middle ground. It allows humans to use a programming language, which is relatively easy for them to understand, yet the resulting code can be efficiently translated into the binary version that computers need to run.

Linux Commands Training Tips: Linux source code is "open source". The text of "open source" programs can be easily downloaded, modified and compiled to create binary program files.

Linux OS (Kernel) Source Code Example - Text of Part of the Linux Kernel

To provide an example of source code, a portion of the code of the Linux kernel is shown below.

The lines of text that begin with "/*" or "*", and end with "*/" are comments in the file.

The name of the file, "time.c", is shown at the top. Also notice the copyright and the modification-history information at the top. You can see "Linus Torvalds" at the top and that he holds the copyright and the names of the people that contributed to the modifications of the code are also shown in the comments.

The following is a snippet (a.k.a. excerpt, part, chunk) of the source code for a program called time.c:

/*

* linux/kernel/time.c

*

* Copyright (C) 1991, 1992 Linus Torvalds

*

* This file contains the interface functions for the various

* time related system calls: time, stime, gettimeofday, settimeofday, adjtime

*

*/

/*

* Modification history kernel/time.c

*

* 1995-08-13 Torsten Duwe

* kernel PLL updated to 1994-12-13 specs (rfc-1589)

* 1999-01-16 Ulrich Windl

* Introduced error checking for many cases in adjtimex().

*/

asmlinkage long sys_time(int * tloc)

{

int i;

/* SMP: This is fairly trivial. We grab CURRENT_TIME and

stuff it to user space. No side effects */

i = CURRENT_TIME;

if (tloc) {

if (put_user(i,tloc))

i = -EFAULT;

}

return i;

}

Text Editors - Used To Create, Edit and Save Source Code Text Files

The text of the source code is created in a "text editor", which is a program that is similar to a word processor, and allows you to create and save the text as a "text file".

Most text editors do not provide the formatting capabilities of word processors, such as bold, underline and left and right margins. The most basic text editors allow you to enter text, edit it, copy, paste and save it.

Learn Linux Commands Now with Linux Commands Videos - Click here to Order

Learn How to Use Linux in General - Featuring Ubuntu Linux - NOW - Click Here to Order

Click here to see free sample Linux Commands training videos

What do you need to learn about Linux Commands?

To get more info on Linux commands - and on what YOU need to know, click "Comment" (link further below) and make a Linux commands book suggestion, ask Linux Commands training questions, or post a comment to let us know what you think so far.

Get Updates to this Linux Commands Book Blog. FREE!

Privacy Notice: We will not distribute your email address to anyone. Period!

Thanks for visiting this "Linux Commands Book Blog"!

Clyde Boom, http://www.iLearnLinux.com

The Easy Linux Training Guy ;)

Easy, Self-paced Linux Training - in Plain English!

Filed under 1.120 | Free Linux OS, GNU / Linux Commands, Free Linux by

Permalink Print Comment

Leave a Comment

Lancom Technologies - Easy, self-paced Linux training - in Plain English!
Web Site: www.iLearnLinux.com | Email: ClydeBoom@iLearnLinux.com
150 South Eighth Street, P.O. Box 1438, Lewiston, NY 14092-1438 USA
5468 Dundas Street West, P.O. Box 807, Toronto, Ontario M9B 6E3 Canada
Toll Free: 1-800-718-7318 | Outside North America: +1-905-857-7177
Copyright © 2008 Lancom Technologies. All rights reserved.