How can I test my Linux hard disk if it is going bad?

You can check hard disk errors using utility for SMART disks under Linux / UNIX like operating systems.
Step 1.	Enable SMART: 
# smartctl -s on -d ata /dev/sdb
Step 2.	Run self-assessment test for hard disk:
# smartctl -d ata -H /dev/sdb
More detailed test:
# smartctl --attributes --log=selftest /dev/sda
You may get even more details with 
# smartctl -d ata -a /dev/sdb

Example

 
This is a screenshot of a typical report for a failing drive retrieved by the following command:
# smartctl -a /dev/sda