Saturday, 16 February 2013

Why I love linux system programming?

Happy New Year to all my great readers and may this year bring us a lot of blessings. This is my first blog post for the year 2013 and also writing it a day after my end of semester exams. I am enthusiastic over this one month vacation I have at home , I hope to post a few more articles and see to it that we release a killer app @ Oasiswebsoft ( My software dev company ) before I resume school.

I took a break off application programming in November last year to perfect my skills in linux system programming. The main difference between the two is application programming aims to produce software which provides services to the user (e.g. Anansi Calcpad), whereas systems programming aims to produce software which provides services to the computer hardware (e.g. disk clean up).

Even if you think you're not a programmer, Linux has some features to make your life a bit easier. Any time you have a repetitive task that involves entering Linux commands or changing the contents of a file, you should think about automating it with a program in linux.I installed an old version of Ubuntu 11.10 ( It’s a linux distribution and a stable build ) and started playing around with the terminal ; doing some basic stuff like echoing the name of the terminal , writing simple addition programs , sleep , pwd and spent more time online reading  about file permissions ( Read, Write , Execute ) , appending output file ,variables , shell scripting , process structure , for loops and many interesting stuffs.

The Bash shell is your main port of entry to Linux, since the shell interprets everything you enter on the command line before passing it along to the operating system for execution. I fell in love with shell scripting because unlike java you didn't need to assign data types ( Int , float , string , char ) when declaring a variable and you do not need a terminator (semi – colon ; ) in most instances.
eg. In java :
int $num1 = 70;
in shell scripting :
num1 = 20

Often, writing a shell script is much faster than writing the equivalent code in other programming languages like java and python. The many advantages include easy program or file selection, quick start, and interactive debugging. A shell script can be used to provide sequencing and decision-making linkage around existing programs, and for moderately-sized scripts the absence of a compilation step is an advantage. Interpretive running makes it easy to write debugging code into a script and rerun it to detect and fix bugs. Non-expert users can use scripting to tailor the behavior of programs, and shell scripting provides some limited scope for multiprocessing.
We will write a simple script that will allow us to let the bash sleep for a while,  delete all the files that is starts with KLM.
STEP 1: Let’s create three files in the bash terminal
touch klm1
touch klm2
touch klm3
STEP 2: Let’s give all the three files all  permissions rights for the user, group and others.
Chmod 777 klm*
NB: * stands for all files .
To view all files with the date last edited or permission rights and details use this command ls –la (Long listing) and check if all files have all the rights.
We will now write a simple program in the VI Editor to sleep for 5 seconds and afterwards delete all files.
echo “ Your text here “
Sleep 5
rm klm*
Final step is to execute this program in the main shell. To execute it use this simple command bash and the name of the file in the VI bash killklm

You have now created a simple shell script that automates the process of putting the shell to sleep and deleting the files that start with the word KLM. With just these few lines of code you can easily build a simple program in Linux.These are screen grubs from the simple script we wrote above in the bash terminal and the VI Editor.

Now let’s write a little complex program. This program that will have 5 options eg.
(1 FOR LOVE         (2 FOR DRUGS  (3 FOR SPORTS       (4 FOR HEALTH
Each option will contain a text eg. Love : feel tender affection for somebody so when a user choose is a number 1-5 it will display a text.
In the bash terminal you use the cat syntax to input append a text into a file:
Eg: cat > drugs
You will find the complete source code to a dummy program I wrote here on my github repository it contains a for loop and CASE conditions.  Unlike java I did not have to import any special packages to allow the user to input text. Enjoy!! 

If you've ever written a simple console program ,word processor macro or a spreadsheet formula, you're a programmer. By taking advantage of Linux's built-in programming features, you can automate repetitive tasks and build simple interactive applications without a degree in computer science.Send me a mail if you have any question or contribution iraindolf [at]

"Software is like sex: it's better when it's free." Linus Torvalds


  1. that's good stuff there man, that's a loosely typed language you are playing with. Big ups

  2. Hi, nice description about linux system programming.Thanks for your help..


  3. Thanks for review, it was excellent and very informative.
    thank you :)

  4. Thanks for your ideas. You can also find the details on Affity Solutions, at the System Programming. The main object of the Affity Solutions is to provide quality web services and is among the few software development company in Nagpur.

  5. Programming is very interesting and creative thing if you do it with love. Your blog code helps a lot to beginners to learn programming from basic to advance level. I really love this blog because I learn a lot from here and this process is still continuing.
    Love from Pro Programmer

  6. That is very interesting; you are a very skilled blogger. I have shared your website in my social networks! A very nice guide. I will definitely follow these tips. Thank you for sharing such detailed article.
    Android Online Training

  7. nice blog has been shared by you. before i read this blog i didn't have any knowledge about this but now i got some knowledge. so keep on sharing such kind of an interesting blogs.
    android training in chennai

  8. Great stuff about linux. Its is very neat explanation and i learnt lots of new information about linux. thanks for sharing this useful information for our vision. keep posting... Thank you!!!
    Salesforce Training in Chennai | Software Testing Training in Chennai