hwinfo – know your hardware

Install hwinfo in ubuntu(tested on Ubuntu 12.04.4 LTS).

sudo apt-get install hwinfo

Following are some of the device type supported by hwinfo.

cdrom cpu disk ide memory netcard partition printer scanner scsi gfxcard sound usb wlan bluetooth monitor

Example to know about CPU(detailed).

hwinfo – -cpu

Output will be something like following

01: None 00.0: 10103 CPU
[Created at cpu.304]
Unique ID: rdCR.j8NaKXDZtZ6
Hardware Class: cpu
Arch: X86-64
Vendor: “GenuineIntel”
Model: 6.42.7 “Intel(R) Core(TM) i7-2600 CPU @ 3.40GHz”
Features: fpu,vme,de,pse,tsc,msr,pae,mce,cx8,apic,sep,mtrr,pge,mca,cmov,pat,pse36,clflush,dts,acpi,mmx,fxsr,sse,sse2,ss,ht,tm,pbe,syscall,nx,rdtscp,lm,constant_tsc,arch_perfmon,pebs,bts,rep_good,nopl,xtopology,nonstop_tsc,aperfmperf,eagerfpu,pni,pclmulqdq,dtes64,mo
Clock: 1600 MHz
BogoMips: 6784.36
Cache: 8192 kb
Units/Processor: 16
Config Status: cfg=new, avail=yes, need=no, active=unknown

02: None 01.0: 10103 CPU
[Created at cpu.304]
Unique ID: wkFv.j8NaKXDZtZ6
Hardware Class: cpu
Arch: X86-64
Vendor: “GenuineIntel”
Model: 6.42.7 “Intel(R) Core(TM) i7-2600 CPU @ 3.40GHz”
Features: fpu,vme,de,pse,tsc,msr,pae,mce,cx8,apic,sep,mtrr,pge,mca,cmov,pat,pse36,clflush,dts,acpi,mmx,fxsr,sse,sse2,ss,ht,tm,pbe,syscall,nx,rdtscp,lm,constant_tsc,arch_perfmon,pebs,bts,rep_good,nopl,xtopology,nonstop_tsc,aperfmperf,eagerfpu,pni,pclmulqdq,dtes64,mo
Clock: 1600 MHz
BogoMips: 6784.36
Cache: 8192 kb
Units/Processor: 16
Config Status: cfg=new, avail=yes, need=no, active=unknown

Example to know about CPU(short).

 hwinfo – -cpu – -short

Output will be something like following

cpu:
Intel(R) Core(TM) i7-2600 CPU @ 3.40GHz, 1600 MHz
Intel(R) Core(TM) i7-2600 CPU @ 3.40GHz, 1600 MHz
Intel(R) Core(TM) i7-2600 CPU @ 3.40GHz, 1600 MHz
Intel(R) Core(TM) i7-2600 CPU @ 3.40GHz, 1600 MHz
Intel(R) Core(TM) i7-2600 CPU @ 3.40GHz, 3400 MHz
Intel(R) Core(TM) i7-2600 CPU @ 3.40GHz, 1600 MHz
Intel(R) Core(TM) i7-2600 CPU @ 3.40GHz, 1600 MHz
Intel(R) Core(TM) i7-2600 CPU @ 3.40GHz, 1600 MHz

Insert into mysql from text file

If you have text file with multiple columns separated by space(or something else). you want to take entries from each row and  insert into MySQL database from a text file.

Following steps should be useful.

input.txt is a text file with below entries

105  bill@<domain.com>
304  lance@<domain.com>
605  foo@<domain.com>
609  bar@<domain.com>

inputfile="input.txt"
cat $inputfile | while read id map; do
echo "INSERT INTO <tablename>(users_id,email,email_map) VALUES ('$id','$map', '$map');"
done | mysql -u<username> -p<password> <database>;

Kill zombie process in Linux

When a process in Linux dies, process’s status becomes EXIT_ZOMBIE and its parent is notified that its child has died with sending SIGCHLD signal.The parent process then executes wait() system call and get process exit status. on successful execution of wait(), the zombie process exits completely from memory. Otherwise it remains as zombie process.
Zombie process stores very tiny amount of system memory to store its process descriptor.
Command to get list of zombie processes running

ps aux | awk '{ print $8 " " $2 }' | grep -w Z

Above command will display something like:
Z 8960
Z  = Zombie
8960 = process PID

Killing the zombie process is not easy.try killing it by following command

kill -9 8960

This probably wont kill it.Now try to find out the parent process of this process.

pstree -H 8960 -p

Now kill the parent process.
kill -9 1649

This should kill the zombie process.