Saturday 13 April 2013

Significance of /etc

Last week one of my friend caught up in a difficult situation while testing some shell scripts in a development server. He changed some configuration files in some directories in dev server but unfortunately the changes got reflected in production server and screwed up some process. Ultimately it resulted in monetary loss and some embarassing situation with client.

How the change made in dev server able to hit the prod server? is it possible?

Yes, The reason is pretty much simple which we would have never thought off. Some of the directories in dev server is mounted with prod server or vice versa. So ultimately he has changed the files in prod server through dev box.This is one of the worst practice should not be followed at any case, what ever the justification or need is.

Let us dive in to the issue and see how to find such directories in advance especially  to avoid embarassing situations.

This can be acheived in two ways now let us see the first method.

Method 1:

As we all aware that in UNIX each and every OS action is file based so the mount information will definitely be maintained in some file or files.

Now the task for us is to find out the file. Here you go........

File /etc/mnttab is really a file system  that  provides read-only  access  to  the table of mounted file systems for the current host. Mounting a file system adds an entry to this file and Unmounting  removes  an  entry     from  this file

so spending a minute to fire "cat /etc/mnttab" in UNIX prompt will help us a lot.

Method 2:

Its pretty much simple than first method. Use the unix command mount. This command will list out the directories which are mounted. Ultimatley it will display the contents of /etc/mnttab.

So I advise the developers and testers to perform this simple check before doing any changes in configuration files or scripts or just a flat file....
Some of the other Important files to make our life easy.

cron.deny, cron.allow, vfstab, inittab, ssh* set of files

To make it simple /etc is the directory which holds many of the support and configuration files of the server. Its always better to understand the significance of the files listed especially in /etc .

Hope this information helps you.

Thank you. Happy Coding.........