Thursday, July 29, 2010

Check linux kernel and CPU is 32 bit or 64 bit. | How many CPU in your server.

Find Out If Running Kernel Is 32 Or 64 Bit

$ uname -a
Linux hostname 2.6.9-89.0.20.ELsmp #1 SMP Tue Feb 2 18:35:37 EST 2010 i686 i686 i386 GNU/Linux

as there is i386 in end this means Kernel running is 32 bit. Still you can have 64 bit processor to check the same you need to see /proc/cpuinfo

$ grep flags /proc/cpuinfo

flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe lm constant_tsc pni monitor ds_cpl cid xtpr


flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe lm constant_tsc pni monitor ds_cpl cid xtpr

- If lm is present that means CPU is 64 bit if it is not there than 32 bit. We hardly going to see 16 bit proccessor.

■lm means Long mode - 64 bit CPU

■Real mode 16 bit CPU
■Protected Mode is 32-bit CPU
under "flags" parameter u will see various values.


Among them . u will find one of them with name "tm(transparent mode)" or
"rm(real mode)" or "lm(long mode)"
1. rm tells ,it is a 16 bit processor
2. tm tells, it is a 32 bit processor
3. lm tells, it is a 64 bit processor
 
You can also try this to find out if your CPU/Processor is 32 bit or 64 bit:

# getconf LONG_BIT
32

Linux display CPU information

Now to get the number of CPU in your Linux server.

Need to give command

#cat /proc/cpuinfo

  •  If you have two CPUs in cpuinfo with the same physical id and core id, than – it is hyperthreading!  (Hyperthreading is when One CPU is seen as 2 Logical CPU by OS, using Hyperthreading OS can send 2 instruction for processing to CPU)
  • When you have all CPUs with different physical ids, than you have SMP,
  • when you have CPUs with one physical id and different core ids – you have one multicore CPU. And so on…





 

How do I delete all but one directory in Linux

$ shopt -s extglob


$ rm -rf !(savedir)



you Korn shell users can ommit the first line.