Author Archives: shibaa987

About shibaa987

A B.Tech degree holder with more than 5 years of experience on Embedded Systems design domain. He has worked on Aerospace domain, NAND storage, Server storage and Wireless networking.

How to Configure vncserver in Fedora

Vnc server and vnc viewer is used to Remote Access in most of the Linux machines like Fedora, RHEL, Ubuntu or any other Linux distro. Sometimes it is necessary for System Administrators and developers to access a Linux machine remotely. Usually things can be done via SSH but you cannot do graphical stuffs using SSH. It’s just a text based command line utility.

Think of vnc as a remote display. Basically you can’t see the display biut whenever you will login to the particular display number then you will see from where you left unlike ssh where all the previous session is gone and you start afresh.

How to configure vncserver in Fedora Linux

How to configure vncserver in Fedora Linux

Here I will show you how to configure VncServer on a Fedora machine. The configurations will be mostly similar in other Linux distros too.

Install and Configure VncServer :

Installing Vnc Server on a Fedora machine:

yum is the utility used to install any application package on Fedora. So we will go ahead and use the same to install Vnc server.
Enter the following command with root privilege on your Fedora machine:

[[email protected]]# yum install vnc-server

or the below command:

[[email protected]]# yum install tigervnc-server

This should install the vncserver on your machine. Important is configuring vncserver so that you can access it from a remote location.

Configuring Vnc Server on a Fedora machine:

If you have a Fedora system with version 18 or earlier then the configuration vncserver is much simpler as compared to the later versions.

Configure vncserver the following way if you have fc18 (Fedora 18) or earlier:
Vnc server is running as a service. The vnc server service uses the /etc/sysconfig/vncservers config file to configure vnc server.

The above file should look something like this:

# vim /etc/sysconfig/vncservers
......
# VNCSERVERS="2:myusername"
# VNCSERVERARGS[2]="-geometry 800x600 -nolisten tcp -localhost"

If you want to configure the vncserver for only root user then do the following modification on the above file after the last line:

# vim /etc/sysconfig/vncservers
......
# VNCSERVERS="2:myusername"
# VNCSERVERARGS[2]="-geometry 800x600 -nolisten tcp -localhost"

VNCSERVERS="1:root"
VNCSERVERARGS[1]="-geometry 1024x768"

If you want to configure the vncserver for multiple users then do the following modification on the above file after the last line:

[[email protected]]# vim /etc/sysconfig/vncservers
......
# VNCSERVERS="2:myusername"
# VNCSERVERARGS[2]="-geometry 800x600 -nolisten tcp -localhost"

# Different display numbers for different users
VNCSERVERS="1:root 1:user2 2:user2 3:user3"

# Set arguments for display#1 (which is root in this case)
VNCSERVERARGS[1]="-geometry 800x768"
# Set arguments for display#2 (which is root in this case)
VNCSERVERARGS[2]="-geometry 1024x768"
# Set arguments for display#3 (which is root in this case)
VNCSERVERARGS[3]="-geometry 1024x768"

You can observe the VNCSERVERS=”1:root 1:user2 2:user2 3:user3″ has 1:root and 1:user2 both in the username arguments which means the display number 1 can be accessed by both root and user1. I hope you understand what am I trying to convey. If you remember I had told at the first of this post that think of vnc as multiple remote displays.

Configure vncserver if you have fc19 (Fedora 19) or later version:
For fc19 or later, path to the vncserver configuration file has been changed from /etc/sysconfig/vncservers to /etc/sysconfig/vncservers. The earlier file is still present which only has some text that tells the file has been moved to the later location. Even some of the configuration parameter has been changed.

First copy the configuration file:

[[email protected]]# cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@.service

Now edit the copied file and change the parameters as desired. I will demonstrate the configuration for ROOT user.

[[email protected]]# vim /etc/systemd/system/vncserver@.service
ExecStart=/sbin/runuser -l root -c "/usr/bin/vncserver %i -geometry 1280x1024"
PIDFile=/root/.vnc/%H%i.pid

If you want multiple users to access vnc server then go to /etc/systemd/system/ directory, copy the vncserver@.service to vncserver-user1@.service, vncserver-user2@.service and so on.
If you want to add multiple display numbers then you can copy the vncserver@.service to vncserver@:1.service, vncserver@:2.service and so on.

Then edit individual files and change the user settings. For example:
Open the /etc/systemd/system/vncserver@:1.service for and add parameters for say user1 (make sure to change user1 to username used on your system):

ExecStart=/sbin/runuser -l root -c "/usr/bin/vncserver %i -geometry 1280x1024"
PIDFile=/home/user1/.vnc/%H%i.pid

Vnc server configuration is DONE now but still you cannot access because we need to set password for individual users. Its time to set a password for a vnc user. This password is only used when the vncserver is accessed via vncviewer from a remote machine or a client.

Follow the below command on the command line to set a password for a specific vnc user lets say user1:

[[email protected]]$ su - user1
[[email protected]]$ vncpasswd
Password:
Verify:
[[email protected]]$ su - user2
[[email protected]]$ vncpasswd
Password:
Verify:

Enter the password and the system is ready to be accessed via vnc viewer for the user user1. Similarly do the same for other users. Make sure to change the user1, user2 to specific usernames on your system.

How to start vncserver :

Follow the below command to start vncserver:

[[email protected]]$ vncserver :1

enter the following command to start vnc server with a particular resolution:

[[email protected]]$ vncserver :1 -geometry 1024x768

The above command will start a vncserver on the display number 1. The configuration for the display number 1 will be taken from VNCSERVERS=”1:root” argument in fc18 or earlier and from the /etc/systemd/system/vncserver@:1.service config file in fc19 or later.
Similarly you can start N number of displays.

The above command should work in all Fedora versions. If that does not work for newer versions then you can enter the following command:

[[email protected]]# systemctl start vncserver-user1@display_number.service
[[email protected]]# systemctl start vncserver-root@:1.service

How to STOP vncserver:

If you feel like the vncserver is not working or you need to restart it the you know how to start it but see the below command to stop a vncserver:

[[email protected]]# vncserver -kill :1

The :1 is for display number. If you want to stop display number 5 then replace :1 with :5.

That’s all folks. Vncserver is up and running. The next thing is to access the running vncserver from a vncviewer or a client which I will write in a later post.


How to Change the Hostname on a Linux Machine

Sometimes you wanted to change the Hostname on a Linux machine like on your Ubuntu PC or a Fedora machine or any other Linux distro like a Citrix XenServer to somewhat relevant to the service running on a server or say you have some slogan of yours that you want to put as a Hostname on your computer. Here I will show you how exactly you can change the Hostname on a Linux powered computer machine.

If you are a newbie to Linux then you might be wondering what is a Hostname and where can you find it on a Linux machine?
When you type the following command on a Linux machine:

uname -a

You will get similar outputs as below:

Linux infysim-machine.infysim.org 2.6.18-308.20.1.el5 #1 SMP Tue Nov 6 04:38:29 EST 2012 x86_64 x86_64 x86_64 GNU/Linux

The string “infysim-machine” is the hostname or system name you can say. Sometimes the hostname will be visible on your command prompt itself. Like this:

[email protected]:~$

The “root” is the username and the “infysim-machine” is the Hostname.

Can I change the Hostname for the current session only?

Yes. Instead of changing the Hostname permanently if you want it to be changed for the current session only then yes you can do that easily but you need to be a ROOT user.
Just follow the below command to change the Hostname for the current session only and not permanently:

[email protected]:/# hostname
infysim-machine.infysim.org
[email protected]:/# hostname new_hostname

The hostname command (the 1st command) will print the current hostname set in the system.
The second command hostname NEW_HOSTNAME will change the hostname temporarily.

Hostname changes will be lost after logout or machine reboot.

How to change the Hostname permanently?

Usually the Hostname string is stored in a file. The filename may be different for different platform.
For Ubuntu and Fedora the file is located at: /etc/hostname and for Citrix Linux machine the file is at /etc/hosts. The file content may be looking like this:

[email protected]:/# cat /etc/hostname
infysim-machine.infysim.org

Or on a Citrix machine it may be looking like this:

[email protected]:/# cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1	localhost.localdomain localhost
xxx.xxx.xxx.xxx	infysim-machine.infysim.org

Open the file and change the string to a desired one:

[email protected]:/# vim /etc/hostname
or
[email protected]:/# vim /etc/hosts
#Change the current hostname to something you want:
new_hostname.infysim.org [Ubuntu and Fedora]
or
xxx.xxx.xxx.xxx	new_hostname.infysim.org [Citrix]

In some cases the /etc/hostname will have only the hostname without the domain name string at the end:

[email protected]:/# cat /etc/hostname
infysim-machine

Open the file and change the string to a desired one:

[email protected]:/# vim /etc/hostname

infysim-machine
#Change the above name to something you want:

new_hostname

Here Is How To Learn Android Application Development

If you are interested to Learn Android Application Development then here I have some free online Education courses and out of that there are some free courses provided directly by Google. Android being one of the leading Mobile Operating System in the market available since more than five years, it is good to learn Android Application Development to build your career, or to build an Android Application for your own business, website or even for fun I’ll say.

Free online Courses to Learn Android App Development

Free online Courses to Learn Android App Development

Why to go for a free Online Course?

I mainly search the Online Courses in various subjects for students or even professionals who are really interested to learn something new but they either don’t have money or time to learn. Students who are keen to learn will benefit out of these courses and for the professionals who don’t have time to learn will have much flexibility to learn the course at anytime at their own pace.

Sometimes you will face many JUNK PAID courses than damn brilliant free courses. Also, I would like to keep the PAID courses separate from free courses so that it will be helpful for the people to get what they want from the affordability point of view.

Here is the list of several free Online Courses to Learn Android Application Development:

Course #1: Available on Udacity, Designed by Google
Course #2: Android App development fundamental on Alison
Course #3: Many Android App development courses on Udemy
Course #4: Android.com’s Developers Resources

Course #1:

The first course in my list is the Developing Android Apps: Android Fundamentals and the Advanced Android App Development: Productionize and Publish Your Apps course on Udacity built by Google itself.

Developing Android Apps course summary:
– The course duration is approximately 10 weeks assuming 6 hour/week contribution.
– You will be getting instructor video access.
– As of writing the post 287,967 students were enrolled for this course, which means you will have a good community to discuss on your doubts.
– Most importantly all the instructors are from Google from who you will be learning this course.

Here is the link to the fundamental course.

Advanced Android App Development course summary:
– You will be getting all above advantages as above except that here only 26,242 students have enrolled for this course but still this is a large base of students community.

Here is the link to the advanced course.

Course #2:

Fundamentals of Google Android Development is a free Android App Development course offered on Alison. The course has the following highlights:
– 38,338 other students enrolled as of writing the post
– Short duration of 2-3 hours
– 4 stars rating course based on 447 votes
– You will get video and assessments

Here is the course link on Alison.

Course #3:

Second comes Android Application Development courses from Udemy. There are many free Android App Development courses for beginners as well as advanced courses. Also, the list contains Android Version specific or category App Development courses like: Android Lollipop 5.0 App Development, Mobile Game Development etc.

There are many courses available, so I have not picked any specific course here and also it is better for you to go and have a look and decide which is the one or many course(es) that you are interested on.

Here is the link for all the App Development list.

Course #4:

Last but not the least, the Android Developer Source on android.com.
Android.com’s developer resource is a good place to learn but the disadvantage is you won’t have an instructor to guide what to learn and how to keep thing on track. At least for beginners it is always good to have a mentor, no matter how good is the quality of the content written, it will be difficult to follow up a written article.

If you are starting to learn Android App development then I will strongly recommend you to take any beginner course from the above courses and then you can always have this as a reference in the secondary place.

Here is the link to Android Developer Resources.


Wondering How to Learn Photography At Home? See Here.

Learn Photography Online for FREE

Learn Photography Online for FREE


Photography is one of the cool thing I ever wanted to learn. I see some cool pics of my friends on their Facebook profile or WhatsApp profile an wonder how they have done it. And later on after a little research I found that the answer lies on Photography. So, what you need to learn photography? Definitely you need a Camera, some guide from somebody or some kind of exposure to photography. Sometimes I have seen people they will buy a costly DSLR camera but they will be using it only on AUTO mode because they really don’t know how to get most out of the camera. Or sometimes they don’t have time to learn photography out of their daily 9-6 office routine.

Do you feel sorry for yourself that you are unable to learn photography because of lack of time or you don’t have enough money to spend on photography classes? Then this is the right place where I will show you some FREE online education classes from EXPERTS. Yes, you read it right, EXPERT online Photography classes for FREE.

Why do you need this Online Photography Courses?

Recently I came across a photography course on Groupon that cost me around $10, (not really a huge amount to be spent) and for which I was really interested to pursue. Later I explored that the course was provided electronically, meaning you will get access to their videos and materials online. Then I thought why not to have a look around the web for some free photography courses??

And then I found some of the good places to start photography and thought to share all of them at one place to all of you who are really interested to learn photography. The biggest advantage of these FREE online courses/classes is you can learn at your own pace and also you can learn in your free or spare time, which means there is not a single missing class.

Source #1:

This free online course offered on ALISON one of the largest Online Education place.
As of writing this content 183,519 students had enrolled and based on 1677 ratings this course had a 4 star of rating out of 5.

The course duration is of around 10 – 15 hours and is divided into following modules:

  • Introduction to Digital Photography
  • Introduction to Software
  • Introduction to Light
  • Introduction to Exposure – Part 1
  • Introduction to Exposure – Part 2
  • Introduction to Optics
  • Introduction to Histograms
  • Introduction to Software Tools
  • Introduction to Digital Cameras – Part 1
  • Introduction to Digital Cameras – Part 2
  • Introduction to Color
  • Introduction to Artifacts
  • Digital Photography Assessment

Here is the link to the course.

Source #2:

This is A free online course offered on Udemy by Karl Taylor, a professional photographer spent more than 20 years in photography.
This course has 22 hours of lecture and 2 hours of video material which covers all levels of photography skills.
As of writing this content 117,398 students had enrolled and based on 1134 ratings this course had a 4.5 star of rating out of 5.

The course is divided into the following sections:

  • This Free photography course intro
  • Getting Started
  • Using Light In Your Photography
  • Portraiture
  • More Advanced Photography Techniques
  • Bonus Photography Tutorials

Here is the link to the FREE course.

Source #3:

Here is another free online course offered on Open2Study by Dr. Shane Hulbert
As of writing this content 62,037 students had enrolled and based on 3049 student reviews this course had 89% rating out of 100.

This course has a total of 40 videos, 36, quizzes, 4 assessments and is divided into the following sections:

  • Light Through Lenses
  • Photography’s Evolution
  • The Digital Darkroom
  • Visual Language & Creative Photography

Here is the link to the course.

Source #4:

Another free online courses offered on Photography Course website. There are many courses for beginners, intermediate, advanced photography and for Photo editing.
You can choose one or many of them based on what you want to learn unlike above all-in-one courses.

Here is the link to the website.

Source #5:

Unlike the above sources this not an Online Photography Course but a website which includes 12 photography lessons.

  • Camera Basics
  • Meters and Light
  • Digital Camera Histograms & Exposure
  • Intent
  • Exposure (Basic)
  • Exposure: High Key
  • Exposure: Low Key
  • Depth of Field
  • Shutter Effects
  • Rule of Thirds
  • Diagonal Lines
  • ‘S’ Curves
  • Balance
  • Negative Space
  • Pick A Subject

Here is the link to the website.

My list may be limited but provides you good options as compared to others but again of course there are many options available on the internet. If you happen to have some more quality info in this regard then please share it with us in the comments section. I will be keep on adding into the list if I will get some more options.


Top 4 FREE Online Education Websites With Mobile Application

Free Online Education websites with Free Application Support

Free Online Education websites with Free Application Support

Sometimes we understand the real meaning of Education lately by the time you won’t have any options left to learn more. And sometimes I have already attended some of our classes but did not understand anything from the class may be because the professor is fast or I was slow to catch things on the right time. But internet is one such place which has really made it possible for literally everyone including me who really want to learn whatever they want at their own pace.

Below are the Top FREE Online Education websites which offer mobile applications on Android OS and/or Apple iOS application for a convenient learning experience with video explanations. To access all of the Free Online Education websites you need to register with them and then you will get access to thousands of courses, video explanations, their discussion rooms etc.

Following are the top Free Online Education websites which also provides you mobile application access:

  1. Coursera
  2. Udemy
  3. edX
  4. Udacity

1. Coursera: A startup in Online Education

Coursera

Coursera


Coursera is one such big Online Education provider which offers a large collection of online courses and all that comes for free (hey also have some paid courses). At the time of writing this post Coursera had 1,801 courses from 138 partners and more than 17 millions of students. I have seen Coursera has grown much faster in terms of getting students attention, providing FREE courses, Mobile application support, video explanations, online forum for students, etc. Coursera is still growing and you may see many more courses will be added to their list.

Following are the links for Coursera mobile app and website:
Google Play Store link
Apple App Store link
Their website

Some of the Coursera’s partners are: The University of Chicago, University of Michigan, Columbia University and many more. You can visit the below link to get the complete list of Partners of Coursera.

2. Udemy: One of the largest Online Education provider

Udemy

Udemy


Udemy also offers a large collection of online courses but not all of them are free. Udemy has some of the free courses and some of the paid courses. At the time of writing this post Udemy had more than 32,000 courses and more than 8 millions of students. Udemy provides a very well organized categories of courses, video explanations and discussions on a course. Udemy also provides some of the courses in other languages than English.

Following are the links for Udemy mobile app and website:
Google Play Store link
Apple App Store link
Their website

3. edX: Another Online Education provider with mobile App support

edX

edX


edX also offers a good collection of online courses but it does not have such a larger collection of courses as compared to Coursera and Udemy. At the time of writing this post edX had 641 courses. edX provides a very well organized categories of courses, video explanations and discussions on a course.

Following are the links for edX mobile app and website:
Google Play Store link for edX
Apple App Store link for edX
edX website

4. Udacity: Another Online Education provider with mobile App support

Udacity Online Education with Mobile App Support

Udacity


Udacity is one of the best Free online education website. At Udacity you will find free courses designed by Google, Nvidia, Facebook, At&T, mongoDB etc. Udacity also has Android and iOS mobile app support which will be convenient for someone to take course. Below are the links to the apps and their website.

Google Play Store link
Apple App Store link
Their website

Although there are many Online Education providers but this list provides you the Online Education providers who also provide Mobile Application support which enables the students and easy-to-access interface to learn. If you happen to know some more websites with Mobile Application support then do post it here in the comments section and I will surely include them in this list.


Basic Operating System Services: A beginner’s guide

Operating System Services are the basic functionalities or the responsibilities of an Operating System that it provides to the Application programmers and Device Driver Developers to build applications and Device Drivers for a particular Operating System Like: Linux, FreeBSD, Windows or any other OS. In this article I will not go into the Device Driver level deep but I will be explaining Operating System Services concept from application programmer’s perspective and give some examples accordingly to help you understand.

In the last post of What is an Operating System, I gave an example of VLC media player and Windows Media Player (On Windows OS) playing different sound tracks at the same time and how the operating system manages to play both the sound tracks at the same on a single audio hardware.

Here is I have to show you some image presentation of the scenario and explain according to the image:

How Multiple Applications and Hardwares are handled by the Operating System

In the image I have drawn the black arrow marks are for the VLC player and the Green arrows are for the Windows media player. Both of the applications are running at the same time and the audio hardware is playing both the sound tracks from both the media players.
VLC media player reads the abc.mp3 from the hard disk, decodes the MP3 file and send the decoded data to the audio hardware to play the sound track.
Windows media player is also reading the xyz.mp3 file from hard disk, decodes the MP3 file and send the digital data to the audio hardware to play the sound track.

So, what’s the role of Operating system in this scenario?

  1. First of all both the media players are running at the same time. Running multiple applications is one of the responsibilities of the OS.
  2. Both the applications are reading some files (this is an input data) from the hard disk. The Operating System has some services to allow the applications to access the Files residing in the hard disk. We will see the Operating System Services shortly.
  3. Both the Applications are sending the decoded content to the audio hardware (this is an output data).
  4. Following are also some responsibilities of the Operating system those are not represented in the image:

  5. It is not represented in the picture but both the media players have to store the data in some of their local memory that they have read from the hard disk. This memory that the applications are using is provided by the Operating System.
  6. It is also not represented by the image, but sometimes applications have to communicate to each other to get some work done, which is also a responsibility of the Operating System.
      For example:

    • – When you run a command from a console (a command line shell). Output of the command is fed back to the console and then the console prints out the data fed by the application.
    • – Another example is when you load some file to your browser. You are required to upload some files from your local systems to some of the websites, let’s say a mail client where you send some files as attachments or a job portal where you need to upload your Resume. In this case the you have to click on Attach button or a Browse button which will open a file Browser which is entirely another application. With the help of the File Browser application you select the file and then click OK. When you click on OK button on the File Browser, the file path is sent back to the Web Browser application.
  7. Sometimes your system has to talk to some other computers in your room connected via LAN (Local Area Networking) or through the internet. The Operating System provides some services to do this.

Here goes the basic Operating System Services based on the above input:

Application or Process execution as a part of Operating System Services:

It is the responsibility of the Operating System to provide some services or functionalities to load and execute an application/Process at the run-time. When there are multiple applications present in the system, then it is the responsibility of the Operating System to execute both of them fairly. This is usually handled by the Scheduler or the Scheduling Algorithm present in the OS. Switching between multiple applications involves context saving and context switching which is also the responsibility of the Scheduler.

Filesystem to manage data as files as a part of Operating System Services:

In the above example VLC media player was reading abc.mp3 and Windows Media Player was reading xyz.mp3 from the hard disk. How they are distinguished differently? Here comes the Filesystem part of the Operating System. The Filesystem present in Operating System helps managing the hard disk contents in files and directories. Directories (called as Folders in Windows) are just place holders which hold files in them and can also contain another directories.

Filesystem is a hierarchical layout which the below image just represents the same:

Hierarchical representation of Files and Directories

Hierarchical representation of Files and Directories

Communicate to the external components (Input/Output hardware) of the system as a part of Operating System Services:

A system is more useful when it is flexible in terms of communicating to the external world. Think of an ATM machine without human interaction or without internet connection is really useless. Similarly if an Operating System is unable to handle external devices connected to it will also be useless. So, to deal with this the Operating System has an Input/Output subsystem that manages input and output devices. In our example the Operating System provides a mechanism to the Applications (VLC and Windows media player in our example) to communicate with the Audio Hardware.

You can add/remove a printer to your system, add/remove a USB flash drive or any other USB enabled device to/from your system, which is magically handled by the Operating System Input/Output subsystem.

Memory management as a part of Operating System Services:

An Operating System and its components all run from the System Memory which is the RAM (Random Access Memory). Also, when applications like VLC is loaded or run or executed, some memory has to be allocated to hold the application in memory. On top of that when VLC read some content from the hard disk it should have some place holder to keep the data holding, isn’t it? All the memory in a system has to be maintained by the Operating System for a reliable operation.

Inter Process Communication (IPC) mechanism as a part of Operating System Services:

For IPC mechanism I have already given the example in the upper section. There are times when different processes have to communicate to each other which is not possible if the environment on which they are running (the OS) will not allow to do so. So, the Operating System has to provide some IPC mechanism so that the applications can communicate to each other.

Sometimes multiple applications access a single region of data or resource(anything that can be used by an application code, whether it be some memory region, or some hardware or some structure of data etc. treated as a resource). So, to keep the multiple accesses atomic (exclusive or synchronous) the OS also has some synchronization mechanisms like: Semaphore, Spin Lock and Mutex.

Networking Services as a part of Operating System Services:

An individual PC is not a part of any network. But now a days Wi-Fi is the most portable mode to connect devices to a network. A network without communication is not at all a network but just individual systems.
So, how does a system communicates to other systems in an network? An Operating System in a computer system has Networking Services that enables a system to communicate to other systems.

Secured Access as a part of Operating System Services:

Basically an Operating System is managing the underlying hardware access by various applications. NO application is allowed to access any other application’s data directly. Even NO application is allowed to access a hardware directly. All accesses must go through the Operating System which internally checks access rights.
For example if some application A wants to access other application’s memory lets say B’s memory region then A has to request the OS via Shared Memory IPC mechanism that it wants to access B’s memory region. If process A accesses process B’s memory region directly then process A will be terminated abruptly.

Although there are other things that the Operating System provides like: Debugging Mechanisms, Error detection and handling services etc which are not the basic things but must be included in a system because no software system in this world is bug free.

That’s all folks. I think I have covered Operating System Services with decent examples to help you understand. If you still have any doubt then please do comment here. Also if I have missed something then please do comment to make this article better.


What’s an Operating system & why do we need one?

Basically an operating system (OS) is a software system (collection of interdependent software code) on its own that allows multiple software applications (multi tasking OS) to use a single set of hardware components at the same time. When I say “allows multiple software applications to use a single set of hardware components” literally it means a single hardware can be used by multiple applications and it is the responsibility of the Operating System to manage how exclusively each application can use the hardware without creating any kind of chaos in the system.

For example you can run a VLC media player and a Windows media player at the same time with different songs. There is only one audio hardware through which the audio will be played and only one hard disk from where the two songs will be read. it is all happening because of the Operating system that is running on your system. Now that’s magic, which is done by the Operating System.

Some of the examples of applications include: a web browser, music player, word processor, e-mail client like outlook etc.

Operating System

Operating System

Types of Operating Systems based on number of users and tasks:

  • Single user Single task
  • Single user multitask
  • Multi-user multitask

Why there is no Multi user single task OS?
When there are multiple users accessing a system at an instance, each user is using some Operating System services, say SSH service, which means multiple applications (multiple instances of SSH service) are already running. So, when we have multi user access to an OS then that is already a multi tasking system. A task is nothing but an application for an OS.

who is a user?
In most of the cases a human is a user to a system. Sometimes there are some bots that can also access an OS or a system to use some services and are also users to a system.

Single user Single task Operating System:

An OS that allows only one user and can run only one Application is called as a Single user Single task OS. DOS is such an example.
There can be many users registered on the same system but at an instance only one user can use the system. If another user wants to use the system, then the previous user has to log out.
Similarly there can be multiple applications present in the system but they cannot run simultaneously. One application has to complete then only another application can run.

Single user single task OS

Single user single task OS

Do we have this kind of Operating System now a days?
Yes, we have. The BIOS (Basic Input/Output System) of a computer system is managed by a DOS like OS where you don’t need multi user multi tasking.

Single user multitask Operating System:

An OS that allows multiple applications on the system at the same time but at an instance there can be only one user who can use the entire system.
No doubt that there can be many users registered on the system but no two users can use the system at the same time. If another user wants to use the system, then the previous user has to log out.
But one user can run multiple applications on the system.

Single user Mutitasking OS

Single user Mutitasking OS

Microsoft Windows XP is an example of single user multitask OS. At a time only one user can access the system but can run many application on the system like: Media Player, Browser, Word processor etc.

Multi-user multitask Operating System:

An OS that allows multiple users on a system and also multiple applications to run at the same time is called as a multi-user multitask Operating System.
A UNIX based OS like: FreeBSD, Linux OS X are examples of multi-user multitask OS.

Many users can be logged in to the same system by remote logins (via ssh or rsh etc.), and can obviously run multiple applications.

Multi user Multitasking OS

Multi user Multitasking OS

You might be thinking that a DOS command shell is similar to a UNIX shell but how the DOS is single task and UNIX shell is a multitask environment? Using the UNIX shell you can run tasks or processes in background which you cannot do in the DOS.

People say application programs usually require an operating system to function, which means an application cannot run on its own and it is dependent on an Operating system. But the fact is without an operating system there can be only one application that can use all the hardware components in a system. When you make that application to manage all operating system like functions it becomes the Operating System.

Lets discuss briefly of a system without an Operating System and a system with Operating System:

Think of a system where we don’t have an operating system but we have to write some software code that will make use of the system. Lets take this particular piece of software code as the only application running on the system. Now lets think that you need another similar application to run on the system, then you need another similar system with similar hardware components because the existing system cannot run two similar applications at the same time (without an OS), isn’t it!
If we will have an operating system on such a system which will enable us to run multiple applications on the same hardware. At the cost of an operating system, you have saved many hardware systems. Now that sound really cool!

Example of a system with and without an Operating System

Example of a system with and without an Operating System

Finally, why do we need an Operating System?

  • An OS helps multiple applications running on a single system at the same time, which saves much time.
  • As an OS virtualizes or shares a single hardware among different applications, hence we are saving more hardware resources by running an OS.
  • We can have only single system even for multiple users. Again hardware resource saving because of on OS.

There are lot many advantages of using of an Operating System than not using one. I have just presented some of the advantages, but definitely there are more. Including these, of course there many things to cover in the topic of Operating Systems but its really hard to fit everything into a single article. But I will be writing many other posts after this to cover most of the things.

Operating system is a design oriented or most appropriately a program oriented topic and not at all theoretical concept. In many colleges I have seen that Operating System is covered by Lecturers in theoretical approach where as to understand Operating System and the services given by an OS you have to do practical programming on Operating System itself to understand how it really works and how are the services used by the different modules of OS.

Have a look around the Operating System concept topics in our website.


How to Download, Extract and update the Linux Kernel source

When you are starting to learn Linux programming or Device driver development, then the first thing you need is the Linux Kernel which is available in a zipped archive format from kernel.org. Sometimes I just download the kernel to browse source code of some modules.

How to download the Linux kernel source?

You just go to kernel.org and download the desired kernel required to you. You can download the latest stable Linux kernel which will be highlighted in big on the website or else you can download any other earlier long term Linux kernel version.
Have a look on the below image where I have highlighted the latest stable and older long term kernel download links.

Linux kernel download link

Basically this will download the kernel archive file into the local storage. Sometimes you may be working on a remote machine using a command line where you don’t have the browser access immediately. So, in that case you need to copy the linux kernel download link by right clicking on the download button on the web page. See the below image:

Copy download link of Linux kernel

So, if you want to download the kernel into a remote system then use the following command in the remote machine:

$ wget <paste the download link>

The command should look something like this:

$ wget https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.4.tar.xz

Use the [shift + insert] key combination to paste the copied text into the console.

The download may take several minutes depending on the system’s internet connection where you are downloading.

How to Unpack the linux kernel archive:

Now that you have downloaded the linux kernel archive which is in a zip format and needs to be extracted or unpacked. Lets say if the downloaded file is at ~/Downloads/linux-4.4.tar.xz (I am taking an example of the latest 4.4 kernel). We will make a new directory (say kernel-src-4.4) inside /usr/src and move the new kernel archive file to the new location and start unpacking.

$ cd /usr/src
$ mkdir kernel-src-<version>  (use another name if already have a kernel version installed)
# cp ~/Downloads/linux.<version>.tar.xz /usr/src/kernel-src-<version>
# cd /usr/src/kernel-src-<version>
# tar xfv linux.<version>.tar.xz

NOTE:
Mostly the above mentioned tar command will unpack the linux kernel archive file. If it did not work then try with the following command:
# tar xjvf linux.<version>.tar.bz2

After executing all the commands successfully a new directory (linux-4.4) would have already created in the /usr/src/kerenl-src-4.4 location.
If you are only planning to browse the latest source code then

How to point to the new kernel:

We have done unpacking the kernel and now we need to point the default linux kernel source to our newly copied kernel source which the other packages should be pointing or using from. I am assuming that the current kernel source code is pointed by /usr/src/linux symbolic link (or the current kernel source directory). Follow the below commands to do that:

$ cd /usr/src/kernel-src-<version>
# rm /usr/src/linux (assuming that's a link to your old kernel)
# ln -s /usr/src/kernel-src-<version>/linux-<version> linux

Now the /usr/src/linux symbolic link will point to /usr/src/kernel-src-<version>/linux-<version>


[VIM] Removing new line at the End Of File in VIM

Vim is the best text editor when it comes to speed, handy and features comparison with any other text editor in this world. You will understand this if you are a UNIX user, administrator or a developer and more importantly if you really know how powerful VIM is. Anyways, today I am going to tell you guys how to remove the newline added by VIM automatically and how does this really impact???

There are different coding standards for different projects. For example in Linux
a new continuation line of code is indented with tabs but the same in FreeBSD is done using 4 white spaces.

Similarly in some projects GCC or any other compiler that is used, is configured to through a compiler WARNING if there is no new line at the end of file. This holds true for UNIX like OS for example: Linux FreeBSD etc. But at some places it is configured not to have a new line, where you will get a compiler warning when you compile a file which may have a new line at the end of file.

Sometimes these kind of stuffs are not configured in compiler because at production level projects, compilers are configured to treat compiler warnings as ERRORs. So, these new line stuff are checked via coding standard utilities or scripts.

What’s the big deal if VIM is adding a new line at the end of file?

Earlier I was working on Linux and FreeBSD projects but recently I was moved to a proprietary embedded system project where everything is customized and I got compiler warning after doing some modifications in some of the c and header files using VIM. Earlier, everything was fine. Later I noticed that VIM is adding an extra line at the End of File which was causing problem for me.

How to get rid of automatic new line added or removed by VIM

Run these following commands in VIM:

:set binary
:set noeol
:wq

Please NOTE that the above commands are VIM commands and not shell commands.

Basically, we set the file as a binary file, then we command VIM not to have EOL (End Of Line) and then write and quit the file.

This will change only for the particular file that you open explicitly. If you want to have these changes set for all the file you edit with VIM then you need to add the following lines to your ~/.vimrc file:

set binary
set noeol

[SHELL] How to know in which shell you are working

There are several ways to know the current shell on which you are working. We will be using some shell commands to know in which Shell you are working on.

#1 To know Which Shell you are working on:
The easiest way is by entering the following command in the shell itself:

    $ ps -p $$

Explanation:
Basically we are listing the process (by using the ps command) by process ID (the -p option to ps command) of the current process, which is the shell ($$). The ps command will report the PID of the current process and the name of the process.

#2 To know Which Shell you are working on:
You can also know the working shell by entering the following command in the shell itself:

    $ echo $SHELL

This will give you the path to the current shell that you are using. Basically SHELL is a environment variable set when you run the command line or the Shell. This method may not work in some shells if the particula shell is not setting this variable.

If you know other ways to get the current shell then you are most welcome to share your knowledge.