Wednesday, January 13, 2010

Count Total Process using pgrep..

Here is another useful command to count total process/thread is running.
When run ps aux... indeed can get all the running process..

# ps aux | grep httpd

But the list is too long..


Therefore.. have a try use pgrep..

# pgrep httpd

Can see all the list are the process id for the httpd process.

Then to count how much thread had been running by httpd..

# pgrep httpd | wc -l

Total process/thread is show up.

Tuesday, January 12, 2010

Check RAM slot in Linux using dmidecode..

Sometimes.. when a server is running..
It is impossible to check, how many RAM slot still available on this server..
Is quite hard to identify the hardware availability without open up the chasing..

I found out, there is a command called "dmidecode"..
Where it can be grab mostly the information you need..

When run
# dmidecode

can see the server chasing information such as server tag, server model, product model and more...

Let back to our main purpose..
# dmidecode -t -17 | grep Size

to can view the RAM size that been installed and the slot not yet installed RAM.

To check the maximum RAM capacity can installed..
# dmidecode -t 16

Sometimes, may face problem with the command such as No such file or directory..
Which may cause by some module not installed or different distro.

Therefore, ignore the -t 17 or -t 16 when execute and add pipe along with keywords..

# dmidecode | grep Size
same thing can be view, just with extra information which you may not need..

# dmidecode | grep Maximum


Sometimes.. you may forget about the case sensitive letters..
Therefore add the -i to ignore the case sensitive.

# dmidecode | grep -i size
output also same as what you need.

dmidecode can retrieve a lot data..
RAM model, speed also can be retrieve...



It do a really handy works for System Engineer when it come to upgrade devices..

Monday, December 14, 2009

Directory at /var/spool/clientmqueue/ consume a lot space

When a linux server does not allow sendmail port out but the service is running..
it will cause all the mail is in queue at the /var/spool/clientmqueue/..
due the mail cannot send out..
When left it like this all the time..
It will consume a large hard disk space..
what I face at here was, this directory had consume about 6G of the hard disk space..

When I run ls at the path, the server will hang..
nothing is about come out... for about roughly 1 or 2 hour or longer..
But when I df -h, the /var directory still have 2G available..
Although there had space but nothing can be start due to the error "not enough space to run services"..

What I can do is.. I try rm -rf * at the /var/spool/clientmqueue/..
"argument list too long error will appear"
Therefore, have to manually rm -rf one by one of the file with the mask attribute (*) at the send... example rm -rf Qm3w*
But this way consume a lot of energy and time.. and the space not decrease also..
Is totally waste of time..
So I try browse and google... I found out.. some solution.

Due to I not using sendmail at all.. I will disable the sendmail service.
By rename the file /etc/mail/submit.cf to /etc/mail/submit.cf.bak
Then I restart the sendmail service... The service cannot be start due to the
"Starting sm-client: /etc/mail/submit.cf: line 0: cannot open: No such file or directory"

Therefore.. my sendmail will not run anymore... Then I deal with the /var/spool/clientmqueue/ path by deleting all the file inside...
I use this command at /var/spool/clientmqueue/
"find . -type f -exec rm {} \;"

Left it run overnight.. and... the file at the directory is completely deleted...

Sunday, June 28, 2009

Wubi - ubuntu installer

New to ubuntu? not used to ubuntu environment yet?
Dont want use virtual machine for ubuntu?

No need to worry, there is WUBI... an ubuntu installer..
Wubi can help you install the ubuntu in your hard disk and make it dual boot loader.
You can choose either to boot into ubuntu or your current windows..


Wubi is an officially supported Ubuntu installer for Windows users that can bring you to the Linux world with a single click. Wubi allows you to install and uninstall Ubuntu as any other Windows application, in a simple and safe way. Are you curious about Linux and Ubuntu? Trying them out has never been easier!


Very simple step..
get yourself the wubi installer at here and the ubuntu desktop cd at here.

Then.. insert the ubuntu desktop CD to the CD-ROM and run the wubi installer..
It will ask where you wish to install the ubuntu.
Just follow the instruction... It will guide all the process..
Once done.. when you reboot your PC/ Laptop, the boot menu will ask which OS you wish to boot into..

That all.. you can experience ubuntu on your PC.. without touching on the current windows..
If not satisfy or want to uninstall the ubuntu, you can just re-run the wubi installer.

Wubi Website

Wubi installer

Monday, June 22, 2009

Find words in each files..

This is something useful command when you want to scan hundreds of file for 1 specified words..
Such as.. you have thousands of files.. and you want to check which file consists "kame" words inside the files..
This is the commands..

grep -n -r 'kame' *

Sunday, June 21, 2009

NTLDR is missing..

Sometimes.. It is very common to see such missing or file corrupt for windows..
Just dont be panic.. everythings can be solved...
Most serious ma just FORMAT LOL..
That why, at least.. 2 partition will be made whenever I do the formatting..
1st Partition only store the Windows and Software..
No important data will store..
Which mean, My Document folder I wont use at all..
2nd partition will store all the important and personal data..
So.. when the main Windows file system corrupt..
Personal data at 2nd partition still safe..

Therefore.. when say whatever file is missing.. no harm.. just repair the windows whatever you like..
For this problem..

NTLDR is missing
Press Ctrl+Alt+Del to restart

What does NTLDR means and the function.. can be found at here
When this message appear after boot the windows..
What you need to do are:

1. Put OS Cd to the CD-ROM and boot into the CD.
2. Then enter to the repair mode which you need press "R".
3. Then you will require to choose which Windows to repair.. Choose "1" which is the main Windows.
4. It will require your Windows Administrator Passwords.. If you have then keyin, else just press "Enter".

Then you will enter the repair mode.. At here, you needs:

1. Run this 2 command..
copy e:\i386\ntldr c:\
copy e:\i386\ntdetect.com c:\
2. exit the repair mode and reboot.

After reboot, you will able to login to the Windows.. Then do some checking on the boot.ini file is it still at there or deleted. This file is located at:
Control Panel > System > Advanced > Startup and Recovery > Settings > System startup

If still exist, check the file is correct or not.. check the boot sequence is it Windows XP Pro/Home as main boot loader.

If not exist anymore..
Then just Edit and create a new boot.ini file.
Add this value into the file.

For Windows XP Professional:
[boot loader]
timeout=30
default=multi(0)disk(0)rdisk(0)partition(1)\WINDOWS
[operating systems]
multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Microsoft Windows XP Professional" /fastdetect

For Windows XP Home:
[Boot loader]
timeout=30
default=multi(0)disk(0)rdisk(0)partition(1)\WINDOWS
[operating system]
multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Microsoft Windows XP Home Edition" /fastdetect


After do the changes on boot.ini.. Restart the Windows..
To make sure does the problem still exist or not...
For more info on boot.ini and the tuning.. Mayb can refer to here and here

Friday, June 5, 2009

Forget MySQL Root Password

It is normal to forget password when you have to remember so many diff and type password..
For MySQL, there are few way you can reset the root password..
But the main condition is.. you must have access to the physical server..
It can't be reset through mysql connection..

Here I will use 1 simple way which I prefer the most.

1. Check which mysql daemon need to reset. At here.. I want to reset mysql port 3306 which using the /etc/my5.cnf config file. Use command "netstat -ntulp" to check the running process and port.


2. Check the mysql /etc/my5.cnf daemon PID. Use command "ps aux | grep mysqld".


3. After identify the pid. Kill the process with "kill -9 db_pid".


4. Double check the mysql port 3306 had been killed or not.


5. Start the mysql with additional parameter "--skip-grant-tables".. which the command will be "mysqld_safe --defaults-file=/etc/my5.cnf --skip-grant-tables --user=root &".


6. Enter the mysql port 3306. It can be access without any password.


7. Now update the root password with new password with command "UPDATE mysql.user SET Password=PASSWORD('new_password') WHERE User='root';".
Then flush the privileges with "flush privileges".

8. Shutdown the mysql with "mysqladmin -uroot -h127.0.0.1 -P3306 shutdown". At here.. since the grant-tables privileges not open yet, shutdown also does not require password.


9. Start back the mysql without the "--skip-grant-tables" parameter.



That all. The MySQL root password had been reset. Here is some reminder.. After reset, remember to restart the mysql without the skip-grant-tables.

Do not let anyone have access to the physical DB server, to avoid DB daemon is restart without knowledge.