top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Unix: Critical Errors Solved Easily

+2 votes
610 views

1. Bind Address Already in Use Error Message:

Error: Have you ever got this error message?

  bind: Address already in use

Solutions:
This error basically means that the program that you are using is trying to lock or bind a port that is already locked or binded by another program or process, and therefore your program can not lock and bind this port. Thus, your program is not able to use this port at all, and your program stops working.

If you know what port number that your program is using, then you can query the operating system to see who has the port locked or binded. Let us assume that the port number that you are trying to use is port 45078. So, this command will display the status of this port:

  netstat  -a  |  grep  45078

If the status of the port is available or free, then it is "LISTENING" and it should look like this:

  tcp        0      0  *.45078                *.*                     LISTEN

If the status of the port is not free, thus binded, then it will be either "CLOSED" or "WAITING" and it should look like this:

  tcp        0      0  MACHINE_NAME.45078       IP_ADDRESS.PROCESS_ID    CLOSE_WAIT

Please notice that both the IP address and process id of whatever has the port locked is listed above.

First, try running this netstat command several times to see if the port becomes free automatically.

Otherwise with this information, you have three possible solutions to resolve this problem. First, kill the process id if it is still an active process. Second, using the IP address, find the machine that is locking the port on your machine. You can either terminate the process that is keeping this port locked on this other machine or you can reboot this other machine. Finally, of course, you can always reboot your machine to severe this port connection too.

I hoped this helped.

2. could not open /dev/kbd

Error:

Well, I do. This week I kept getting this "could not open /dev/kbd to get keyboard type US keyboard assumed" warning message from several different UNIX scripts and programs, and it was driving me crazy. 

Here is an example of what I was getting: 

$ dos2unix file.txt > file2.txt 
could not open /dev/kbd to get keyboard type US keyboard assumed 
could not get keyboard type US keyboard assumed

Solutions
After considerable investigation, I figured out that this UNIX warning message means that the UNIX server that I was connected to either had no keyboard attached to it or that the keyboard was not defined correctly.

The ideal solution is to attach or configure a keyboard to the server in question, but I did not have access to the server room. So I discovered (thanks to Google) that there is an undocumented argument to suppress certain types of warnings, so that you do not have to see this UNIX warning message any more.

For example, this produces no warning messages:

$ dos2unix -437 file.txt > file2.txt

Of course, this argument can suppress additional useful warning messages, and you can also re-direct stderr to /dev/null too.

I hope this helps someone.

posted Apr 6, 2014 by Amit Kumar Pandey

  Promote This Article
Facebook Share Button Twitter Share Button LinkedIn Share Button


Related Articles

What is Inode 

In Unix or Linux file system file internal representation is called inode or index node.  An inode structure is an object in the file structure on a file system except the file contents and the file name and used to track the file(s) stored on the disk. The inode entries store metadata about each file, directory or object, but only points to these structures rather than storing the data.
 

What are the contents of Inode structure

  1. Inode number
  2. Access Control List (ACL)
  3. Extended attribute
  4. Direct/indirect disk blocks
  5. Number of blocks
  6. File access, change and modification time
  7. File deletion time
  8. File generation number
  9. File size
  10. File type
  11. Group
  12. Number of links
  13. Owner
  14. Permissions
  15. Status flags
 

 What is the catch 

There is no entry for file name in the Inode, rather the file name is kept as a separate entry parallel to Inode number. The reason for separating out file name from the other information related to same file is for maintaining hard-links to files. This means that once all the other information is separated out from the file name then we can have various file names which point to same Inode.

How to get the inode number of a file

[ec2-user@ip-172-31-42-140 ~]$ ls -il
total 130816
 13144 -rw-rw-r--  1 ec2-user ec2-user       30 May 25 08:49 1.c
 13136 -rw-rw-r--  1 ec2-user ec2-user   294241 Jan 26 14:04 a
   352 -rw-rw-r--  1 ec2-user ec2-user 57295640 Aug 31  2014 abc.tar.gz
 13139 -rw-rw-r--  1 ec2-user ec2-user      801 Feb 26 08:17 a.c
   368 -rwxrwxr-x  1 ec2-user ec2-user     6899 Feb 26 08:17 a.out
   369 -rw-rw-r--  1 ec2-user ec2-user      488 Dec 18  2013 apply-button.png
   370 -rw-rw-r--  1 ec2-user ec2-user      137 Dec 23  2013 a.py
   371 -rwxrwxr-x  1 ec2-user ec2-user    10140 Mar  8  2014 b
   372 drwxr-xr-x  1 ec2-user ec2-user      598 Aug  5  2014 xxx

The number on the far left is the inode number associated with the file. Also notice that there is a directory “xxx” that also has an inode associated with it. Each time a file or directory is created or deleted, an inode is created or deleted.

Inode Pointer Structure

According to the wikipedia, the structure used to have 11 or 13 pointers but most modern file systems use 15 pointers stored in the data structure. From wikipedia, for the case where there are 12 pointers in the data structure, the pointers are:

  • Twelve points that directly point to blocks containing the data for the file. These are called direct pointers.
  • One single indirect pointer. This pointer points to a block of pointers that point to blocks containing the data for the file.
  • One doubly indirect pointer. This pointer points to a block of pointers that point to other blocks of pointers that point to blocks containing the data for the file.
  • One triply indirect pointer. This pointer points to a block of pointers that point other blocks of pointers that point to other blocks of pointers that point to blocks containing the data for the file.

To make things easier, Figure below from wikipedia, shows these different types of pointers.


In the figure you can see the direct, indirect, and doubly indirect pointers. A triply indirect pointer is similar to the doubly indirect pointer with another level of pointers between the data blocks and the inode.

READ MORE
...