Wednesday 1 February 2012

The application finder can't be opened (10810)

Before some days I had issue with the finder due to improper shutdown.  Then I've goggled for the same issue & I find below solution. Not sure but its worked for me.

I've rebuild LaunchServices database in Leopard with "lsregister". May be "lsregister" have different location in another version. Locate & run below command from Terminal. 

You can use "spotlight" to open terminal as finder is not working. 

/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.fram ework/Support/lsregister -kill -r -domain local -domain system -domain user

Monday 23 January 2012

Configure LAMP server (Linux + Apache + MySQL + PHP/Perl) on Linux

Configure LAMP server (Linux + Apache + MySQL + PHP/Perl) on Linux

1) Install Apache
# yum install httpd httpd­devel

start the apache service
# /etc/init.d/httpd start


2) Install MySQL Database Server

# yum install mysql mysql­server mysql­devel
# /etc/init.d/mysqld start
# mysql

Changing MySQL Root Password

# mysql> USE mysql;
# mysql> UPDATE user SET Password=PASSWORD('newpassword') WHERE user='root';
# mysql> FLUSH PRIVILEGES;

Once done, check by logging in:

# mysql ­u root ­p
Enter Password:

To Create A New MySQL User

# mysql > create database demo
# mysql >GRANT ALL PRIVILEGES ON demo.* TO 'guest'@'localhost' IDENTIFIED BY 'guest'
WITH GRANT OPTION;
# mysql> UPDATE user SET Password=PASSWORD('guest') WHERE user='guest';

3) Install PHP5
# yum install php php­mysql php­common php­gd php­mbstring php­mcrypt php­devel php­xml

Test If PHP Is Working Or Not:
Create a file named /var/www/html/test.php with the following phpinfo() function inside php
quotes.
// test.php
phpinfo();
?>
Then point your browser to http://ip.address/test.php.


4) Install phpMyAdmin
phpMyAdmin is a free web based MySQL database Administration Tool

# yum install phpmyadmin
Point your browser to: http://ip.address/phpmyadmin.

5) Install Webmin
wget
rpm ­ i webmin­1.410­1.noarch.rpm

Point your browser to: http://ip.address:10000

You should see a webmin login. But we don't know the login and password yet! To set up the
webmin password run the script below...

# /usr/libexec/webmin/changepass.pl /etc/webmin admin

Log in with the admin username and new webmin password!
To uninstall webmin, just run:

# /etc/webmin/uninstall.sh

6) Final Steps
We want the Apache and mysql to be loaded at every boot so we switch them on using chkconfig:
# chkconfig httpd on
# chkconfig mysqld on

Recover MySQL root Password


You can recover MySQL database server password with following five easy steps.

Step # 1: Stop the MySQL server process.

Step # 2: Start the MySQL (mysqld) server/daemon process with the --skip-grant-tables option so that it will not prompt for password.

Step # 3: Connect to mysql server as the root user.

Step # 4: Setup new mysql root account password i.e. reset mysql password.

Step # 5: Exit and restart the MySQL server.

Here are commands you need to type for each step (login as the root user):

Step# 1 : Stop mysql service

# /etc/init.d/mysql stop
Output:

Stopping MySQL database server: mysqld.

Step # 2: Start to MySQL server w/o password:

# mysqld_safe --skip-grant-tables &
Output:

[1] 5988
Starting mysqld daemon with databases from /var/lib/mysql
mysqld_safe[6025]: started

Step # 3: Connect to mysql server using mysql client:

# mysql -u root
Output:

Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 4.1.15-Debian_1-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>

Step # 4: Setup new MySQL root user password

mysql> use mysql;
mysql> update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root';
mysql> flush privileges;
mysql> quit
Step # 5: Stop MySQL Server:

# /etc/init.d/mysql stop
Output:

Stopping MySQL database server: mysqld
STOPPING server from pid file /var/run/mysqld/mysqld.pid
mysqld_safe[6186]: ended

[1]+ Done mysqld_safe --skip-grant-tables

Step # 6: Start MySQL server and test it

# /etc/init.d/mysql start
# mysql -u root -p

How To Flush Linux / UNIX DNS Cache

Flush nscd dns cache

Nscd caches libc-issued requests to the Name Service. If retrieving NSS data is fairly expensive, nscd is able to speed up consecutive access to the same data dramatically and increase overall system performance. Just restart nscd:

$ sudo /etc/init.d/nscd restart
OR
# service nscd restart

Flush dnsmasq dns cache

dnsmasq is a lightweight DNS, TFTP and DHCP server. It is intended to provide coupled DNS and DHCP service to a LAN. Dnsmasq accepts DNS queries and either answers them from a small, local, cache or forwards them to a real, recursive, DNS server. This software is also installed many cheap routers to cache dns queries. Just restart to flush out dns cache:

$ sudo /etc/init.d/dnsmasq restart

Flush caching BIND server dns cache

A caching BIND server obtains information from another server (a Zone Master) in response to a host query and then saves (caches) the data locally. All you have to do is restart bind to clear its cache:


# /etc/init.d/named restart

How to check a perticular process uptime in Linuz

We can check a uptime for any process using linux command. But you should have to know process ID for this.

We can find process ID using below commands.
#ps -ef | grep process_name

Below is the command which provides you the uptime for this process.

 #ps -p 12119 -o "%t"





Alter Multiple tables using bash script

Below is the shell script to alter multiple tables.


#!/bin/bash

DATABASENAME="DBNAME"
for t in `echo "show tables" | mysql --batch --skip-column-names $DATABASENAME`;
do mysql $DATABASENAME -e "ALTER TABLE $t ENGINE=NDBCLUSTER";
done



How to repaire all MySQL tables in one command

You can use below command to optimize & repair all tables.

#mysqlcheck -u root -p --auto-repair --check --optimize --all-databases

Count all records from your MySQL databse

If you want to count all records from your database, follow below instructions.

1) Login To your database.

2) Execute below query

> SELECT table_name, TABLE_ROWS FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'DATABASE_NAME' order by TABLE_ROWS asc;

You have to change only database_name from above query.

MySQL Change root Password


How do I change MySQL root password under Linux, FreeBSD, OpenBSD and UNIX like operating system over ssh / telnet session?

Setting up MySQL password is one of the essential tasks. By default root user is MySQL admin account user. Please note that the Linux / UNIX root account for your operating system and MySQL root are different. They are separate and nothing to do with each other. Sometime your may remove mysql root account and setup admin as mysql super user for security purpose.
mysqladmin command to change root password

If you have never set a root password for MySQL server, the server does not require a password at all for connecting as root. To setup root password for first time, use mysqladmin command at shell prompt as follows:

$ mysqladmin -u root password NEWPASSWORD

However, if you want to change (or update) a root password, then you need to use the following command:

$ mysqladmin -u root -p'oldpassword' password newpass

For example, If the old password is abc, you can set the new password to 123456, enter:

$ mysqladmin -u root -p'abc' password '123456'

Change MySQL password for other users

To change a normal user password you need to type (let us assume you would like to change password for user vivek) the following command:

$ mysqladmin -u vivek -p oldpassword password newpass

Changing MySQL root user password using MySQL sql command

This is another method. MySQL stores username and passwords in user table inside MySQL database. You can directly update password using the following method to update or change password for user vivek:

1) Login to mysql server, type the following command at shell prompt:

$ mysql -u root -p

2) Use mysql database (type command at mysql> prompt):

mysql> use mysql;

3) Change password for user vivek, enter:

mysql> update user set password=PASSWORD("NEWPASSWORD") where User='vivek';

4) Finally, reload the privileges:

mysql> flush privileges;
mysql> quit

The last method can be used with PHP, Python or Perl scripting mysql API.

Know your Motherboard in linux

check motherboard information in Linux

To check motherboard information in Linux, you can use either lspci or dmidecode.

# lspci –vv
# dmidecode

Could not start a new session. Response code 500. Message: Failed to read marionette port

There is bug in firefox binary installed using apt/snap, I faced same issue when I installed firefox from apt package respository. I solved ...