Pages

Tuesday, January 28, 2014

You don't have permission to access /nagios/ on this server.

For this issue we have to just install php package and try to restart apache service and it should work with out any issue.

Friday, September 27, 2013

syntax error at abc.pl line 10, near "$h ("

Perl language have bit different mechanism when dealing with errors. Some points you should know before debugging errors.

1)Always use shebang statement with  -w option as shown below.
#!/usr/bin/perl -w
2)Always use strict and warnings package to report all syntax errors.
use strict;
use warnings;

When you get above error do not just check error on the given line try to check before and after the line of error report. This tip will resolve most of your errors like missing closing brace "}", sentence termination like ";", etc.

Can't find string terminator "EOF " anywhere before EOF at test.pl line 21.

This issue will come when you are using EOF or EOM string to send multiple line to a perl print statement or a command. Just have look at below code

I have a file descriptor which will take input from a string as shown below.

printf FD1 "this my first line";

This will work with out any issue, but when you want to send multiple lines as shown below we have to use PERL here-docs as shown below.

printf FD1 << EOM;
statement1
statement2
EOM

other than this syntax, if you give any other thing it will fail. Observe that there is no double quotes before or after EOM and there is a ; colon after first EOM. We even have to remember that there should not be any space between << and EOM. Hope this helps some one who did this mistake.

Tuesday, September 17, 2013

Can't open /dev/sdb1 exclusively. Mounted filesystem?

This is an issue we will get for many reasons, one reason we get this error is when we try to use the partition which is already mounted or used in your machine. This occurs some times due to LVM which is not properly implemented

If you fee this is new partition and want to unlock the file from kernel follow below steps

Step1: Check what are the partitions known to the kernel by using proc file system as shown bleow

[root@gnani surendra]# cat /proc/partitions
major minor  #blocks  name

   8        0    8388608 sda
   8        1    5120000 sda1
   8        2    1024000 sda2
   8        3    2240906 sda3
   8       16    8388608 sdb
   8       17     112423 sdb1
   8       18     112455 sdb2
   8       19     112455 sdb3
 253        0     112423 dm-0
 253        1     112455 dm-1
 253        2     112455 dm-2

Step2: Check if your required partition is in the list or not? If yes, then try to check status of that disk by using dmsetup command as shown below

[root@gnani surendra]# dmsetup status
sdb3: 0 224910 linear
sdb2: 0 224910 linear
sdb1: 0 224847 linear

Step3: If you see your desired partition, try to unlink it from the kernel

dmsetup remove sdb1

Now try to use your partition and see if you still have issue. Hope this helps someone in need.

Wednesday, May 8, 2013

Perl Error: readdir() attempted on invalid dirhandle

Q. I am seeing "readdir() attempted on invalid dirhandle DIR at" error when attempting to open a directory using readdir function in Perl. How can I resolve this?

The error "readdir() attempted on invalid dirhandle DIR at" clearly states that PERL was unable to open directory by using readdir function. There are number of situations which causes this error

1)Check if user who executed perl script have permissions on that directory or not. User should have read permissions to open a directory in Perl. Check permissions by using ls command.

2)Check if directory exists or not? Sometimes users will forgot to check if directory exists or not before opening a directory. To avoid this we can use below code to check before opening a directory.



opendir DIR, $SRCDIR || die ("Can not open dir $SRCDIR");


Keep this line before readdir function so that it will give you a meaningful error message before reading a directory.

3) Are you reading an input from user? Then make sure that your variable which contain directory name should not contain newline character. So use chop or chomp function to remove last character.

chop($DIR=<>)

This will chop of last character.

Hope this helps someone when dealing with open directory in perl.

Tuesday, May 7, 2013

Solution for: mv: cannot move `' to a subdirectory of itself,

Q. How can I move all my files in my working directory to a sub-directory with the working directory? I am getting error "mv: cannot move `' to a subdirectory of itself," Can I move all the files/folder to sub-directory with out this error?

Yes, you can move all your files/folders present in your directory to a sub-directory with out getting that error. This error will occure when mv command try to move this sub-directory as well which it can not do and throws this error. All you have to do set shopt extglop option and try below command

shopt -s extglob
mv !(subdir) subdir/

Know more about shopt here.

Thats it, you will not see the error as shown above. hope this helps some one.

Thursday, May 2, 2013

isohybrid: Warning: more than 1024 cylinders: isohybrid: Not all BIOSes will be able to boot this devic

Q. I am facing issue "isohybrid: Warning: more than 1024 cylinders:  isohybrid: Not all BIOSes will be able to boot this devic", How can I resolve this?

First this is not an issue or error. This is just a warning not an error and it is just a warnning. This warning will be displayed when you are trying to convert a normal ISO file to hybrid ISO file by using isohybrid command

isohybrid /path/to/normal/iso/file

This error will come when your ISO file is more than 1GB size.

Wednesday, February 27, 2013

error: Requested operation is not valid: Disk does not support snapshotting

error: Requested operation is not valid: Disk  does not support snapshot

This error arises when you try to take a snapshot of a VM hard disk with virsh command
as shown below


virsh snapshot-create Clusterbase

error: Requested operation is not valid: Disk '/path/to/kvm/clusterbase.img' does not support snapshot.

If you see image of this VM is .img format, by default Virsh snapshot will work only for qcow2 format as of time of this post writing. So first convert that image to qcow2 format and then try to do a snapshot t with same command.

Convert img file to  qcow2 format


qemu-img convert -f raw -O qcow2 /path/to/kvm/clusterbase.img /path/to/kvm/clusterbase.qcow2

Hope this helps to resolve this error.

Sunday, February 24, 2013

Loaded plugins:fastest mirror Loading mirror speed from cached hosfile Setting up install process Nothing to do

Q. I am seeing below error when installing some packages


 Loaded plugins:fastest mirror
  Loading mirror speed from cached hosfile
  Setting up install process
  Nothing to do

This error will come when you execute below command

yum install somepackage

and the repo is set with "enable=0", try to change it or use --enablerepo= as shown below.

yum --enablerepo=yourreponame install somepackage


If you set enable=0 that indicates that dont include this repo when installing RPM packages. And enable=1 will include this repo when installing packages.

Hope this helps some one.

Friday, February 22, 2013

error: command 'save' requires option

This error will come when you are trying to save VM using virsh command. When you try to save VM status using Virt-manager we no need to mention any file to save the status. Virt-manager will take care of saving it. But virsh have no mechanism like this. We have to provide a file to save the machine status.

virsh save domaname filename

Example
virsh save linux1 /opt/linux1.stat

Thursday, January 17, 2013

Failed to mount ': Input/output error NTFS is either inconsistent, or there is a hardware fault, or it's a SoftRAID/FakeRAID hardware.

Q. I am getting following error when I mounted my external HDD in Ubuntu Linux and getting below error.



root@linuxnix.com:~# mount -t ntfs /dev/sde1 /mnt
$MFTMirr does not match $MFT (record 0).
Failed to mount '/dev/sde1': Input/output error
NTFS is either inconsistent, or there is a hardware fault, or it's a
SoftRAID/FakeRAID hardware. In the first case run chkdsk /f on Windows
then reboot into Windows twice. The usage of the /f parameter is very
important! If the device is a SoftRAID/FakeRAID then first activate
it and mount a different device under the /dev/mapper/ directory, (e.g.
/dev/mapper/nvidia_eahaabcc1). Please see the 'dmraid' documentation
for more details.

This error usually occurs
  • When computer shutdown/restarted/suspended/hibernated
  • Not properly mounted etc.
To fix this issue you have to install ntfsprogs which will provide fixing of 

As a root run below command

apt-get install ntfsprogs

Fixing by using ntfsfix as root

ntfsfix /dev/sde1

Once this is fixed you can try to mount once again.

mount -t ntfs /dev/sde1 /mnt

Wednesday, January 9, 2013

mount: could not find any free loop device

mount: could not find any free loop device solution


This is the error you will get when mounting an ISO or img file. This is due to limitations of number of loop devices available in a machine. To eliminate this error we have to unmount unnecessary images before mounting any other image file in the machine.

Friday, December 14, 2012

Linux error "There are stopped jobs"

This error will come when you try to logout or exit from a terminal and there are some tasks which are running in background. 


surendra@linuxnix.com:~$ ping linuxnix.com
PING linuxnix.com (216.239.38.21) 56(84) bytes of data.
64 bytes from any-in-2615.1e100.net (216.239.38.21): icmp_req=1 ttl=50 time=61.3 ms
64 bytes from any-in-2615.1e100.net (216.239.38.21): icmp_req=2 ttl=50 time=63.2 ms
^Z
[1]+  Stopped                 ping linuxnix.com
surendra@linuxnix.com:~$ exit
There are stopped jobs.
surendra@linuxnix.com:~$ 

If you observe I started a ping program and sent that process to background. And when I try to logout from that terminal I got an error stating that there are still some programs running. To stop this error we have to see if you really like to kill the jobs.

How to kill those jobs?
Execute/press below commands/shortcuts

fg
ctrl+c


How to retain job running though you try to logout?
Just press below commands/shortcuts

ctrl+z
bg
disown

This will allow us to run the process in background though you try to logout.

 

Sunday, December 2, 2012

Solution of "No Route to Host error" Issue

No Route to Host error Linux solution

Q. I am seeing an error when trying to connect to a server, but I am able to ping and see other ports open by using telnet command? Is there a solution to resolve this issue?

First of all check what are open ports on that machine

nmap server-ip

Check if your service is running and showing in nmap output.Check if your service is running or not on tha

If your port is not open check your iptables output.

iptables -L

This will show all the rules. You can flush the iptables if you are not much concern about security.

iptables -F

Stop iptables and save iptables

service iptables stop
service iptables save

Perminently off iptables service.

chkconfig iptables off





Saturday, November 17, 2012

'main' not defined in your config (for this host).

This is the error you will see when configuring drbd(Distributed Replicated Block Device). This is caused when the main resource in not defined in any or .res files in /etc/drbd.d folder. So check you defined main as resource in the .res files or not. If its defined and you feel there is no config error, check if the host name is matching in the res file to the uname -n command

uname -n

if you see the difference between the names then change the config files according to the uname -n command output.

Sunday, October 14, 2012

WARNING: Re-reading the partition table failed with error 16: Device or resource busy

WARNING: Re-reading the partition table failed with error 16: Device or resource busy


We will see this error from RHEL6 on words. This error is due to the partition table changes are not updated to kernel. When ever we change the partition table and try to save the table changes we get this error. Even you will get the following error as well


The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.


when you see this error and executing partprobe command can not do anything, in RHEL5 based partprobe is the command to update the partition table changes to kernel, but from 6 we have to use partx command to update the partition table changes to kernel. 

Use below command to update the partition table changes.

partx -a /dev/sda

This will update the partition table changes of /dev/sda hard disk to the kernel.

Try to run above command two times, because first time it will try to sync previous partition table changes.

Hope this helps some one.


Wednesday, October 3, 2012

Failed to connect socket to '/var/run/libvirt/libvirt-sock': Permission denied

Failed to connect socket to '/var/run/libvirt/libvirt-sock': Permission denied


This error will occurs if the user do not have permissions to connect to virt-manager or virtviewer tools.
To resolve this issue execute below commands

Step1: Conform if your root user account have permissions or not

virsh -c qemu:///system list

if you dont see any issue from root user, try to execute the same command with normal user where you want to start virt-viewer or virt-manager. If you see any issues such as "failed to connect socket" issue with normal user then he should be member of libvirtd group first. Follow below procedure.

Step2: Add the user account as secondary group member to libvirtd group

Note: Before doing anything keep in mind that this user may be member of many other already existing groups so add this user account to them as well.

usermod -G libvirtd,group2,group3 -a username

Step3: Now we have to change the settings in /etc/libvirt/libvirtd.conf. Open /etc/libvirt/libvirtd.conf as root and search for following lines and remove the comments for that lines.
vi /etc/libvirt/libvirtd.conf
Now remove comments from the lines which contains below info.

unix_sock_group = "libvirtd"
unix_sock_ro_perms = "0777"
 unix_sock_rw_perms = "0770"

With the first line we are mentioning that libvirtd group is allowed to very one and r/o and r/w permissions for all the users who belongs to this group.

Hope this helps some one.


(98)Address already in use: make_sock: could not bind to address 192.168.1.1:443 no listening sockets available


Solution for (98)Address already in use: make_sock error


The error

(98)Address already in use: make_sock: could not bind to address 192.16.1.1:443 no listening sockets available

is commonly seen when we are starting a network related service such as Apache(httpd), DNS(bind) squid etc.

When and Why this error occurs?

This error occurs when service tried to bind that particular port to the IP address. In other words for example there is service ABC running on port 443 and you tried to start some other service XYZ on the same port with out knowing that ABC service is running on that 443 port.

Technical details?

When ever you want to run a network related service we have to bind this service to a port and IP address so that once its assigned what ever packets coordinated to that service are routed through this port.

What about Solution?


Step1: First you have to check what service is running on that IP address by using nmap port mapping tool.

From the above error I am taking my IP as 192.168.1.1

nmap 192.168.1.1

Sample output



root@linuxnix.com:/var/log# nmap localhost

Starting Nmap 5.21 ( http://nmap.org ) at 2012-10-03 12:35 IST
Nmap scan report for 192.168.1.1
Host is up (0.0000090s latency).
Not shown: 997 closed ports
PORT     STATE SERVICE
53/tcp   open  domain
443/tcp  open  sshd
3689/tcp open  rendezvous

Nmap done: 1 IP address (1 host up) scanned in 0.25 seconds

Step2: Once you find the service name which occupies the port try to stop if the service is not required.

service sshd stop

Step3: Now start your Apache service and this error will vanish.




Tuesday, October 2, 2012

All about Linux and Open source errors with their solutions

The idea of this blog is simple. This is totally meant for the errors which are seen daily when we are configuring some servers, applications, tools etc. I felt there is no dedecated blog which deals only with errors related to Linux, Unix and open source tools which work on Linux/Unix based flavors. This site is for those people who are looking for the errors they are seeing on day to day activities.

What you will see in this blog?

All about errors and their solutions so that you no need to scratch your head on what went wrong in creating this error?

Can any one contribute to this site?
Yes, All are welcome. A person in this world will never come across all the problems faced by other users. So it should be corroborated way rather than one man army.

Thanks,
Surendra Anne.