September 28, 2009    |    Posted by 
admin   |    Category: Mysql & PostGres SQL 
										HowTo GRANT privileges to a Mysql user from the command line? This can be done by logging to the server via SSH. Once you are logged in, goto the Mysql prompt with the mysql user and password.
# mysql -uroot -p<mysql-pass-here>
Once at the prompt, create a database:
mysql> create database dbname;
The database with ‘dbname’ has been created. Now we need to create a user who will have access to the database. This can be done by granting privileges using ‘grant’ command
mysql> grant all on dbname.* to 'dbuser'@'localhost' identified \
by 'password';
The user ‘dbuser’ will now have access to database ‘dbname’ using the password ‘password’. This user can access only from the local server and not from external machine.
To allow user to access the database remotely, say from IP 1.2.3.4, execute:
mysql> grant all on dbname.* to 'dbuser'@'1.2.3.4' identified \
by 'password';
Using the above command, you can grant privileges to multiple users to access a database.
					 Comments Off on Grant privileges to a Mysql user from Mysql Command line? 
					
				 
				
             		
		 		
September 28, 2009    |    Posted by 
admin   |    Category: Scripts 
										If you mess up with the ownership of all the users on a cPanel server, following script will help you to correct the ownership:
#  for i in `cat /etc/trueuserdomains | awk ‘{print $2}’`
> do
> /bin/chown $i.$i /home/$i -R; 
> /bin/chown $i.mail /home/$i/etc -R;
> /bin/chown $i.nobody /home/$i/public_html;
> done;
The ownership of the home directory of a user, etc and public_tml will be corrected in a one go.
					 Comments Off on Correcting ownership of all cPanel Users 
					
				 
				
             		
		 		
September 27, 2009    |    Posted by 
admin   |    Category: cPanel Management 
										The  path to various logs files on a cPanel server for different services is listed below:
Apache Web Server Logs:
/usr/local/apache/logs/access_log
/usr/local/apache/logs/error_log
Exim (Email) Logs:
/var/log/exim_mainlog
/var/log/exim_paniclog
/var/log/exim_rejectlog
Ftp Logs:
/var/log/messages
Mysql Logs:
/var/lib/mysql/server.hostname.err
Cronjob Logs:
/var/log/cron
Server Logs:
/var/log/messages
SSH Logs:
/var/log/secure
cPanel Installation Logs:
/var/log/cpanel-install-thread0.log
ChkServd (cPanel Monitoring Daemon) Logs:
/var/log/chkservd.log
Named (Bind) Logs:
/var/log/messages
Last successful login attempts to the server:
/var/log/wtmp (but to view the details, execute the command “last”)
 
Last unsuccessful login attempts to the server:
/var/log/utmp (To view the logs, execute “lastb” command)
Domlogs of an Account:
/usr/local/apache/domlogs/domainname.tld
Mod Security Logs:
/usr/local/apache/logs/modsec_audit.log
/usr/local/apache/logs/modsec_debug_log
Apache SUEXEC Logs:
/usr/local/apache/logs/suexec_log
cPanel Access and Error Logs:
/usr/local/cpanel/logs/access_log
/usr/local/cpanel/logs/error_log
Stats Execution Logs:
/usr/local/cpanel/logs/stats_log
cPanel License Logs:
/usr/local/cpanel/logs/license_log
cPanel Backup Logs:
/usr/local/cpanel/logs/cpbackup/*.log
Tomcat Logs:
/usr/local/jakarta/tomcat/logs/catalina.err
/usr/local/jakarta/tomcat/logs/catalina.out
					 Comments Off on Know cPanel logs in detail OR List of different log files in cPanel 
					
				 
				
             		
		 		
September 27, 2009    |    Posted by 
admin   |    Category: cPanel Management, Linux Administration 
										Howto check number of emails in the mail queue:
exim -bpc
To check the email ID, sender and receiver of the each email:
exim -bp | more
To delete frozen emails from the mail queue, execute:
exim -bp | grep ‘frozen’ | awk ‘{print $3}’ | xargs exim -Mrm
similarly, to delete emails sent using a script’
exim -bp | grep ‘<>’ | awk ‘{print $3}’ | xargs exim -Mrm
					 Comments Off on Delete Frozen Emails 
					
				 
				
             		
		 		
September 27, 2009    |    Posted by 
admin   |    Category: Plesk Management 
										Plesk uses a database called ‘psa’ to save all the details about the domains, settings, users and their passwords in plain text. A person with root access to the server can easily retrieve email account passwords in a Plesk server from the Mysql prompt.
SSH to the server and connect to the Mysql server
# mysql -uadmin -p`cat /etc/psa/.psa.shadow`
At the mysql prompt, goto the ‘psa’ database which is used by Plesk.
mysql> use psa;
and execute the following command to retrieve passwords of all the email accounts on a domain
mysql> select mail_name, password from domains, mail, accounts where \
domains.name='domainname.com' and domains.id=mail.dom_id and \
mail.id=accounts.id;
where,
replace domainname.com with the actual domain name whose email account passwords you wish to retrieve.
domains, mail, accounts are the table names where different entries of an email account is stored.
					 Comments Off on HowTo: retrieve email account passwords in Plesk?