Sunday, April 19, 2009

Just opened binary file in vi !!!!!!!

By mistake,you have just opened one binary file in vi and screen continues to scroll. You may use CTRL + C to stop that. But now,junk characters are appearing in prompt. You are not able to read anything.Try reset command. It will Reset scrambled screen.

$reset


To test this command try opening some binary file and issue reset command after stopping scrolling by pressing CTRL + C.

How to see what others are doing in real time ?

There are some situation when you are only interested in knowing what others are doing.
Let say two guys are trying to fix a server and as a supervisor, you are interested in knowing how they are doing in real time.

You may do this using script command. Let say person is logged in and his terminal type is pts/0. Running "w" tells this.

script -f /dev/pts/0


This tool is good for learning from team member's skill.

Why dont you save your command and its output ?

Lets say you are working on a known issue and you need to document the commands and their result.
You may use script command to capture various commands and its output.

How to use script

$script FILE-NAME

This command will open new shell. Now what ever command you issue,along with its output will be logged into FILE-NAME. Once you are done,press "CTRL-D" and you are out of screen command.

Although this command is very simple but it helps to document things.

lsof can be used in many ways for troubleshooting purposes

lsof is a very useful command. Is shows various opened files. You may use lsof with specific port,pid or process.When used in correct context,it will save your life in difficult troubleshooting sessions.

Suppose you want to see what are the various services running in you server. I know you will say netstat. But you may also use lsof -i -n.

lsof -i -n

-n for overriding dns resolution
Lets discuss some of other cases too.
-i:portno
lsof -i:389


Port 389 is used by ldap by default.
This will show all the services on this port. It will also show connection status too.
lsof -i:143 -n

-n will give ip address instead of fqdn
-p:pid
lsof -p:1234


There were some situation when some stale processes were hindering new processes to spawn. This switch will display all the files,connections,sockets opened by it.
We can confirm if the particular process is stale(before kill -9)
-c process_name
lsof -c dhcpd

This switch will show all the files(connection status,type) and many other regular info of this process.

what are the various resources a process is utilizing ?

There was one particular incidence when i am making changes in some conf file but its not taking effect.There were some cases when i am expecting spool directory's path in some other location but postfix is picking up some other location.
In nutshell, we want to see what are the files a particular daemon is using or opening or referring.
Lets be more specific.As i mainly deal with postfix, there are mainly two conf files, master.conf and main.conf. We are interested in knowing what are the files master process is using, i will issue following command to get this info

lsof -c master


it will show all the files,sockets,tcp connections attached to this process.

You may use other processes too to track them down.

Very useful in case you are running out of ideas what next to do if correct thing in correct place( as you think) is not taking place.

I was trying to clear spool directory but master was using different location. I was expecting it to be where it should be(during build i specified) but default postfix installation in OS was forcing different spool location(during booting).

Whole story is too big to mention here. Not in context too.

How to log output of remote ssh session ?

There are many instances when you are going to ssh to remote server for troubleshooting and data gathering purposes and you want to save those data in your computer.
There is a less frequently but useful "tee" command which could be used to log all output in a remote ssh session. What it will actually do is that it will generate one file which will capture all the commands as well as their output.

ssh user@remote.server.com | tee /path/of/log/file


This command is very useful for troubleshooting purposes.

Sunday, February 10, 2008

How to configure BSNL Broabband Connection as truely Always On using Siemens C2110 ADSL Modem?

i have got my latest broadband connection from Calcutta Telephones(BSNL in Calcutta).They have given Siemens C2110 ADSL modem.This modem requires USB as well as Ethernet card unlike previous modems which worked either on USB or Ethernet. I have configured ADSL modem in ALWAYS ON (by storing UserID/password in Modem) so that i need not to connect from WINDOWS/LINUX.Dialing PPOE client from Windows XP was never been a problem but Linux is a bit shy from USB stuff,so i was a bit worried in Linux environment.Once i have configured modem,i was sure that as soon as Modem gets power it will establish connection irrespective of OS.Modem is working like router in pure PPPoE way unlike dialing from OS where it works as a bridge.THERE IS NO NEED TO CONFIGURE ANY NETWORK CONNECTION IN WINDOWS XP(or installing PPPoE client in Linux).I am so lazy,you know.

HOW TO CONFIGURE SIEMENS C2110 ADSL MODEM:-

Once you have properly connected USB as well Ethernet Card into modem,type http://192.168.1.1 in your browser.Login page will appear.Login as admin and default password is admin.Follow the following steps :-

(I assume internet is not connected in your PC and you have been intimated User Name and Password from BSNL.)

1) Configuration -->Internet

2) PPPoE_0_35 will appear in the right panel.If it does not come automatically,click on add and accept all the default parameters and keep on clicking Next till it ask for user Name and Password.

3)if PPPoE_0_35 appears,click on connect.Accept all the default perameters.Pls ensure that VPI is 0 and VC1 is 35.These values are defaulted too.So nothing to worry.

4)Clicking on Next will bring "Configure Connection Type" screen.Accept the default settings.It should be PPP over Ethernet (PPPoE).Click on Next.

5)If your Broadband settings is thru then, It Will show Some WAN IP Address.Accept the defaults and click on Next.

6)Next screen is "Configure Broadband User Name and Password".Its the only STEP where your intervention is required.Type Broadband User Name and Password provided by BSNL.You can also choose other options too like Always on OR Dial on Demand OR Manually Connect. I will suggest you to choose the default(Always On).Click Next.

7) Next is the summary page.Just have a glance and Click Apply.

In a nutshell,all the default parameters WORK well.You just have to provide User Name and Password and it will be REALLY ALWAYS NO Internet without any PPPoE client.