Sunday 25 March 2012

10 Questions ?

When you begin any project, are trying to make a change in your life, or are faced with a difficult undertaking, the best way to improve your result is to ask the important questions first. If you are working as part of a team, some questions may need to be asked of others. When working towards an individual goal, you will be the one giving the answers

Inline image 1

Ask, ask, ask — until you're confident that you have a firm understanding. Don't wait until you're stuck and spinning your wheels. Ask the questions and find the answers first!
 
"Quality questions create a quality life. Successful people ask better questions, and as a result, they get better answers"

Questions ?

Why am I doing this?

It's important to understand the reason behind anything you undertake. Whether it's a goal, task, habit, or project, "why am I doing this?" should be the first question you ask yourself. Understanding the reason behind the actions can be a tremendous motivator.

What is the desired outcome?

Without being clear about the desired result, you can't plan how to get there. Identify what you're trying to accomplish and exactly what that will look like. Clarity is key. Vague targets are rarely attained. Defined and tangible objectives have much greater success.

When is the deadline and are there periodic checkpoints?

Know when the action or project needs to be complete. Be aware of any phases or interim deadlines along the way. If you know how much time you have to work with, you can better plan backwards and set aside the necessary amount of time.

What is my role?

Understanding your role is crucial. Are you the leader or a worker bee? Are you a researcher or a communicator? Are you a team coordinator or planner? It's important to know which role you play so you can align your actions. If it is an individual undertaking, then you are most likely all of the above.

Who is responsible or accountable for which tasks or projects?

This is related your role, but in a more specific and tangible way. Determine which specific tasks you are personally responsible for. Know who maintains accountability. Perhaps you are the one whom others are accountable. Define your responsibilities.

Do I have metrics or some form of measurement?

Establish a measurement of success, so that progress can be determined. If metrics are set by someone else, know what they are and if there is any flexibility.

What are the possible roadblocks or obstacles?

We almost always encounter snags along the way to completion. However, difficulties can more easily be overcome if we can prepare for them. It's not always possible to prepare, complications by their very nature, are frequently unforeseen, but if you at least try to anticipate potential setbacks, they can often be resolved quickly.

What are the available resources?

Be aware of what resources are available. Be cognizant of the number of people involved or accessible to you and their skills. Be honest about the amount of time that can be committed. Also, understand if there are financial constraints.

How important is this project or task?

The importance of any goal or project determines how much attention and effort it deserves. Higher priority items get moved to the top of the list, while less crucial tasks can often be pushed back. If a project affects the profitability of a business or the health and well-being of an individual, it usually gets top priority.

What can I do to be more effective?

Develop strategies to help you be more efficient and productive. Improve the quality of your work by utilizing useful and effective tools. Better organizational skills greatly enhance effectiveness.

"Learn to be resourceful"


 

Saturday 24 March 2012

Linux OS is wrong. It is ....

Journey of GNU project and FSF:

Opensource was started specially to reject the ideas that every individual stand for. It is mainly a journey of freedom.
Let's find more in detail about GNU and FSF(Free Software Foundation):

When it comes to Free Software Foundation, there can be no one as assertive as Richard M Stallman.He knew from his experience that free software was a good way of life, when he was working at the MIT Artificial Intelligence in 1970s. The lab was part of free software community. Software's used were very rare exceptions, and was free. A lot of it had been written by Stallman and developers. They were able to fix things that was bothering people.


Inline image 3


In 1971, he was hired by a lab. Lots of operating systems were free. But, by the end of 1980s, free software had become rare. Proprietary software was the norm everywhere--and then in the early 80s, our community died, and he was dropped into proprietary world. He refused to live that way, making all his efforts for you.

1983, launched Free Software movement, with the goal to make it possible to use computers and have freedom. So wanted to have an operating system that was free. They had PDP10, which became obsolete in 80s; so all software was absolete too. All other computer systems with software was proprietary.

Stallman decided to plan UNIX-like OS that would be entirely free software. Hence he named as GNU which means GNU is Not Unix.

1980s, lot of work was done for UNIX-like OS, which has hundred of components. Few components were found from somebody else who wrote for different purpose, and were free software. other components we had to develop. CSRG(Computer Systems Research Group) at Berkeley had written a code to change UNIX, but their was mixed in AT&T's and so was propritery. Stallman suggested them to write separate software and release it freely, later can be used into GNU system.

Inline image 2


1992, GNU was complete system, but one essential component was missing, kernel. So started to develop in 1990, which gave it somewhat character of a research project, taking six years to get a test version. 1992, Linux Torvalds, who had a proprietary kernel called Linux kernel, decided to make it free. The combination of the Linux kernel with the rest of the GNU system made a complete OS, which was basically GNU, but also contained Linux.

So calling Linux OS is wrong, it is GNU/Linux.

Productive Leader

Lead without title:

When it comes to self leadership it's about taking control and responsibility for your own circumstances. It's about stepping forward, instead of stepping back. It's about raising your hand and not staying in the background. If everyone were to step up and take responsibility the world would be a better place.

Leadership and productivity:

For me Leadership and Productivity are very closely linked. Productivity is synonymous with getting things done but what few people consciously realize is that it is also synonymous with creativity; and these two elements are essential for effective leadership. We all know that to achieve anything in life we need to get things done but if we are merely to complete tasks as they come our way this will amount to nothing. We need time for creative and strategic thinking. The most effective leaders are those who have the vision to make the world a better place and have the means through being highly productive to get the job done.

Here are 9 suggested habits that can help you become a more productive leader whether you have a title or not.

1. Have a clear Vision

Having a crystal clear vision of what you want to achieve which is communicated clearly to all involved will ensure the commitment and motivation are present to achieve the goal.

2. Have a Workflow System

A workflow system will allow you to work effectively and creatively by freeing up time to do the work the matters.Understanding the most effective flow of work will ensure that work is not duplicated or distractions don't interfere with the work that matters.

3. Take Responsibility

Take responsibility for all of your actions and behaviours. Eliminate any victim behavior, Remember that you are the master of your fate.

4. Work Your Body

All of the worlds high achievers work out regularly, Obama, Bush, Branson, all know the benefits of regular exercise for stamina, for performance and for productivity. It is one of the best habits you can adopt to become more productive. The extra energy that you gain from working out along with the de-stressing effect will enhance your productivity and performance more than any other habit.

5 Relax Your Body

Along with exercise the body needs rest, relaxation and plenty of sleep to perform at its best. Meditation and Yoga can also help to relax and de-stress the body.

6. Value your Time

Delegate, outsource and share your work.

"Only do what only you can do."

Your time is too precious to waste so only use it to do the work that no one else can do for you.

7. Become a good Listener

If you lead other people it is essential to listen well but you will also find that if you listen well it can make you more productive by eliminating duplication of work or misunderstandings that can lead to unessential work being completed.

8. Be the best you can be

Always do your best and you will have no regrets. Success doesn't come to those who sit and wait, it is necessary to work towards your vision. Engage with your vision, keep taking action.

"Nothing will work unless you do."

9. Make time for Thinking


In order to excel at what you do, You must make time for thinking. Creative thinking and strategic thinking. This is one of the biggest mistakes people in business make. They are too busy with day to day tasks that they forget to plan, to innovate, to dream. And without these factors there will never be growth or involvement, simply stagnation.

Friday 23 March 2012

Advance Linux File Permissions

In this article, we discuss about the SUID, SGID, and sticky bit.

when you look around in your file system you see 's' and 't' bit. These are the special file permissions for the files.
[sunil@server ~]$ ls -ld /tmp
drwxrwxrwt 6 root root 4096 Mar 23 07:14 /tmp

[sunil@server ~]$ which passwd
/usr/bin/passwd

[sunil@server ~]$ ls -l /usr/bin/passwd
-rwsr-xr-x 1 root root 22960 Jul 17  2006 /usr/bin/passwd

When special mode of the file needs to set, then we use below values;
SUID=4
SGID=2
Sticky bit=1

Let us discuss, in detail

SUID(Set-User-Id):

when user executes a file, the process by default has the same permissions as the user. In other words process inherits his default group and user identifications.
By setting SUID, process doesn't use the user's identification but the user identification of the file owner.

[sunil@server ~]$ ls -l /etc/passwd /etc/shadow /usr/bin/passwd
-rw-r--r-- 1 root root  1725 Mar 23 07:27 /etc/passwd
-r-------- 1 root root  1214 Mar 23 07:27 /etc/shadow
-rwsr-xr-x 1 root root 22960 Jul 17  2006 /usr/bin/passwd

From above we observe that 'passwd' is readable by all, but shadow is un-readable by group and other users.
Normal user wants to change the password, he can by running /usr/bin/passwd which have a special permission mode that lets users update sensitive system files like /etc/shadow --something they can't do directly with an editor. True fact of 'passwd ' command.

[sunil@server ~]$ ls -ld /usr/bin/passwd
-rwsr-xr-x 1 root root 22960 Jul 17  2006 /usr/bin/passwd

Observe letter 's' which is SUID, which sets a process have the privileges of the owner of the file during running instance.
Thus when a non privileged user executes passwd, the effective UID of the process is not the user's, but of root's.

[sunil@server ~]$ id -a
uid=502(sunil) gid=502(sunil) groups=502(sunil)

Take a look at below script.

[sunil@server ~]$ cat reids.pl
#!/usr/bin/perl
# printing Real UID
print "RUID: $<\n";
# printing Real GID
print "RGID: $(\n";
# printing Effective UID
print "EUID: $>\n";
# printing Effective GID
print "EGID: $)\n";

The file is owned by sunil, and observe file permissions.

[sunil@server ~]$ ls -l reids.pl
-rwxrwxr-x 1 sunil sunil 187 Mar 23 07:56 reids.pl

When you run the script you will see that the process that runs it gets your user-ID and your group-ID:
[sunil@server ~]$ ./reids.pl
RUID: 502
RGID: 502 502
EUID: 502
EGID: 502 502

Now changing owner ship to another user.
[root@server ~]# chown gee /home/sunil/reids.pl

[root@server ~]# ls -l /home/sunil/reids.pl
-rwxrwxr-x 1 gee sunil 200 Mar 23 07:32 /home/sunil/reids.pl

Running script again,
[sunil@server ~]$ ./reids.pl
RUID: 502
RGID: 502 502
EUID: 502
EGID: 502 502

Output of the program depends only on the user that runs it and not the one who owns the file.

SUID permission:

[root@server ~]# chmod 4775 /home/sunil/reids.pl

[root@server ~]# ls -l /home/sunil/reids.pl
-rwsrwxr-x 1 gee sunil 187 Mar 23 07:56 /home/sunil/reids.pl

Once 's' bit is set, file is executed under the UID of the user that owns the file rather than user who is ececuting the file.
so, even when sunil runs the file, EUID=103 which is not sunil's.

[sunil@server ~]$ ./reids.pl
RUID: 502
RGID: 502 502
EUID: 503
EGID: 502 502

SGID(Set-Group-Id):

Similar to SUID, except that a program with SGID set allows the user to have the same power as the group.
Created two users(sunil,gee), who shares a common directory(/admin) with write permission, with group ownership(admin).
[root@server ~]# groupadd admin
[root@server ~]# chgrp admin /admin/
[root@server ~]# mkdir /admin
[root@server ~]# chmod 775 /admin/

[sunil@server ~]$ ls -ld /admin/
drwxrwxr-x 2 root admin 4096 Mar 23 08:27 /admin/

Adding, users to admin share.
[root@server ~]# usermod -G admin sunil
[root@server ~]# usermod -G admin gee

Login with sunil credentails and create file in /admin directory.
[sunil@server admin]$ pwd
/admin

[sunil@server admin]$ ls -l
total 0
-rw-rw-r-- 1 sunil sunil 0 Mar 23 08:39 sun-beforesgid

Login with user gee and create a file in /admin directory.

[gee@server admin]$ pwd
/admin

[gee@server admin]$ ls -l
total 0
-rw-rw-r-- 1 gee   gee   0 Mar 23 08:40 gee-beforesgid
-rw-rw-r-- 1 sunil sunil 0 Mar 23 08:39 sun-beforesgid

SGID bit is not set, when files are created in /admin, the group for the file is user's primary GID.
Setting SGID bit, and login as sunil and create file.

[root@server ~]# chmod 2775 /admin/
[root@server ~]# ls -ld /admin/
drwxrwsr-x 2 root admin 4096 Mar 23 08:27 /admin/

[sunil@server admin]$ ls -l
total 0
-rw-rw-r-- 1 gee   admin 0 Mar 23 08:41 gee-aftersgid
-rw-rw-r-- 1 gee   gee   0 Mar 23 08:40 gee-beforesgid
-rw-rw-r-- 1 sunil admin 0 Mar 23 08:41 sun-aftersgid
-rw-rw-r-- 1 sunil sunil 0 Mar 23 08:39 sun-beforesgid

Notice the group ownership for " *-aftersgid ". It inherits group permission from the parent directory
"Enabling SGID on a directory is extremely useful when you have a group of users with different primary groups working on the same set of files."

Sticky bit:

Everyone can read,write and access the directory.The 't' indicates that only the user (root and owner of the directory,of course) that created a file in this directory can delete that file.

One user could remove another user's file
Eg:
[sunil@server admin]$ ls -l
-rw-rw-r-- 1 gee   admin 0 Mar 23 08:41 gee-aftersgid
-rw-rw-r-- 1 gee   admin 0 Mar 23 08:48 gee-afterstickybit
-rw-rw-r-- 1 gee   gee   0 Mar 23 08:40 gee-beforesgid
-rw-rw-r-- 1 gee   admin 0 Mar 23 08:48 gee-beforestickybit
-rw-rw-r-- 1 sunil admin 0 Mar 23 08:41 sun-aftersgid
-rw-rw-r-- 1 sunil admin 0 Mar 23 08:48 sun-afterstickybit
-rw-rw-r-- 1 sunil sunil 0 Mar 23 08:39 sun-beforesgid
-rw-rw-r-- 1 sunil admin 0 Mar 23 08:48 sun-beforestickybit

[sunil@server admin]$ rm gee-beforestickybit
[sunil@server admin]$ ls gee-beforestickybit
ls: gee-beforestickybit: No such file or directory
[sunil@server admin]$

Sunil was able to remove file. In order to prevent we use sticky bit.

[root@server ~]# chmod +t /admin/
[sunil@server ~]$ ls -ld /admin
drwxrwsr-t 2 root admin 4096 Mar 23 08:27 /admin/

Here it throws the below error, while removing the file.
[sunil@server admin]$ rm gee-afterstickybit
rm: cannot remove `gee-afterstickybit': Operation not permitted

Hope by this article you would have understood about the importance of advance linux file permissions.

Monday 19 March 2012

Linux: How kernel talk to devices

Inside the kernel are functions for each of the devices the kernel is going to access. All the routines for a specific device are jointly referred to as the Device driver. Each device on the system has its own device driver. Eg: for devices such as a hard disk or terminal, the system needs to be able to open the device, write to the device, read from the device, and close the device, therefore, the respective drivers will contain the routines needed ..

The kernel needs to be told how to access the device. Not only does the kernel need to be told what kind of device is being accessed and this special information is accomplished by Major and Minor numbers.

The major device numbers are used to distinguish between different devices and their controllers.The major number is actually the offset into the kernel's device driver table, which tells the kernel what kind of device it is.

The minor number tells the kernel special characteristics of the device to be accessed.

It is through this table that the routines are accessed that, in turn, access the physical hardware. Once the kernel has determined what kind of device to which it is talking, it determines the specific device, the specific location, or other characteristics of the device by means of the minor number.

The major number for the sd (SATA) driver is hard-coded at 8.  The minor numbers have the format
(<unit>*16)+<part>) where,

unit- SATA drive number on the first controller either 0 or 1. so all sd devices has minor number less than 16.
part- Partition number, which can be anything from 1 to 20.

Which minor numbers you will be able to access will depend on how many partitions you have and what kind they are (extended, logical, etc.). The minor number of the device node that represents the whole disk is 0. This has the node name sda, whereas the other device nodes have a name equal to their minor number (/dev/sda2 has a minor number 2)

root@slackware:/dev]#fdisk -l

Disk /dev/sda: 48.1 GB, 48181477376 bytes
255 heads, 63 sectors/track, 5857 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x20d0a085

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        1824    14651248+  83  Linux
/dev/sda2            1825        5857    32395072+   5  Extended
/dev/sda5            1825        5654    30764443+  83  Linux
/dev/sda6            5655        5857     1630566   82  Linux swap

From above we can conclude that :-

1. /dev/sda is the first controller and it's unit=0
2. Disk partitions are /dev/sda1, /dev/sda2, /dev/sda5, /dev/sda6.

Minor numbers are calculated as per formula -
(<unit>*16)+<part>):Substituting above we get,
(0*16)+0=0
(0*16)+1=1
(0*16)+2=2
(0*16)+5=5
(0*16)+6=6

In-case of another controller(unit=1), you would have minor numbers > 16.

root@slackware:/dev]#pwd
/dev

root@slackware:/dev]#ls -l sda*
brw-rw---- 1 root disk 8, 0 2012-03-19 13:06 sda
brw-rw---- 1 root disk 8, 1 2012-03-19 13:06 sda1
brw-rw---- 1 root disk 8, 2 2012-03-19 13:06 sda2
brw-rw---- 1 root disk 8, 5 2012-03-19 13:06 sda5
brw-rw---- 1 root disk 8, 6 2012-03-19 13:06 sda6

you could calculate Major and Minor according to the device info (Char/Block).

root@slackware:~]#cat /proc/devices
Character devices:
  1 mem
  2 pty
  3 ttyp
  4 /dev/vc/0
  4 tty
  4 ttyS
  5 /dev/tty
  5 /dev/console
  5 /dev/ptmx
  6 lp
  7 vcs
  9 st
 10 misc
 13 input
 14 sound
 21 sg
 29 fb
 89 i2c
 99 ppdev
116 alsa
128 ptm
136 pts
171 ieee1394
180 usb
189 usb_device
245 pcmcia
246 rtc
247 hidraw
248 usb_endpoint
249 usbmon
250 gdth
251 megaraid_sas_ioctl
252 megadev_legacy
253 aac
254 bsg

Block devices:
  1 ramdisk
  3 ide0
259 blkext
  7 loop
  8 sd
  9 md
 11 sr
 22 ide1
 65 sd
 66 sd
 67 sd
 68 sd
 69 sd
 70 sd
 71 sd
 80 i2o_block
128 sd
129 sd
130 sd
131 sd
132 sd
133 sd
134 sd
135 sd
253 device-mapper
254 mdp

More information on "Devices" could be found in the below path.

root@slackware:~]#ls -l /usr/src/linux/Documentation/devices.txt
-rw-r--r-- 1 root root 118525 2009-07-02 23:41 /usr/src/linux/Documentation/devices.txt

Thursday 15 March 2012

Self Improvement

1st : Use your energy on important things
If you want to succeed in life, you should not waste your energy on activities that do not bring any benefits.Such useless activities include surfing the Internet without any purpose, watching TV, worrying and wasting money.When you are involved in such activities, you have no or little energy left for activities that can create a better future. It is worth prioritizing and accomplishing important tasks first, and then if you still have enough energy, you may decide to do the unimportant.

2nd : Focus on one task at a time
If you want to get perfect results, you should only concentrate on one activity. This way all your energy will go into it and you will accomplish it perfectly.If you waste your energy on several things at the same time, you will get average results because you will divide your energy between the activities.

3rd : Control your thinking
To avoid chaos in your mind resulting in chaos in the outside world, you should try to observe your thoughts. Once you start doing that, you will notice how many negative thoughts you get daily. By observing negative thinking you will be able to emotionally disengage from it. As a result, negative thinking will affect you less and you will notice that your days are getting more peaceful and positive.

4th : Get organized
When you live in an organized manner, you do not suffer from stress and your life is peaceful and balanced. To start living this way, you should start planning your day in advance. This will eliminate any stress caused by being late to a meeting or forgetting to complete some task.You should also live in tidiness because by keeping your home clean you also keep your mental state clear and peaceful. Such mental state will benefit you in many ways, including improved memory and less negativity.

5th : Live in the present
Although this self improvement activity may seem strange to you, it is a very important activity that many ignore. The majority of people do not live in the present. They either dwell on their past or daydream about the future. They seem to forget the most important time of all - the present. You should enjoy every present moment because your current state of mind always manifests in the outside world, creating your future accordingly.Therefore if your main mood is very positive, you will experience only happy days. However, if you dwell on negative thoughts, you are sure to encounter many obstacles and misfortunes in the present and days to come.

6th : Complete each task in a perfect manner
Whenever you are working on some project, try to accomplish it in the best way possible. Always ask yourself 'Is this project turned out as perfect as it could possibly be?' If the answer is no, try to correct or add something to it until there is nothing that you can improve.This way you will make sure that each single task you accomplish is done in an excellent manner. By doing this you will create successful future because you cannot possibly fail if you only get perfect results.Also, when you entirely focus on one task excluding everything else, you will notice that you start enjoying the task. If you concentrate on the task but still do not enjoy it, that means that you probably see the task as a means to an end rather than the process.You should start focusing on the process itself to find enjoyment in the task. Such enjoyment will fuel motivation and you will accomplish everything quicker and better.If you enjoy your work, you will put only positive energy into it. As a result, your completed tasks will bring you success.

7th : Challenge yourself
Nothing develops you more than challenges. Challenges force you to shift your comfort zone, experience new situations and make you grow. Without challenges life would be very boring and depressing.Challenges are necessary for every human being who is seeking quality life. Only through trial and error you realize who you really are, which activities you like and what preferences you have.You can easily measure the success of a person by the amount of challenges she/he had.

8th : Read personal development books
There is nothing more important than searching information about self improvement. Without reading any self improvement books or articles you cannot improve yourself.

9th Self Improvement Activity: Socialize only with positive people
Positive people can inspire, empower and make you happy. It is so much worth to be at least once in a while with positive people rather than constantly spend time with negative friends or relatives.If you spend your days with, for example, lazy people, you may notice that you are becoming lazy.If all your friends' main qualities are negative, try to avoid all of them. This way you will not be affected in a negative way and after some time will start attracting positive people.

10th : Exercise
Daily exercise develops determination, focus and patience. It improves your health and strengthens your body. It makes you more active, positive and invincible.People who exercise every day are always perceived as strong-willed and disciplined.