How to make a file password protected

You need to use htaccess to make a single file password protected and add these lines in to it.

<FilesMatch file.php>
AuthName “Restricted Area”
AuthType Basic
AuthUserFile /path/to/.htpasswd
AuthGroupFile /dev/null
require valid-user
</FilesMatch>

then run command

htpasswd -b .htpasswd username password

Posted in Uncategorized | Leave a comment

Mysql commands

To login (from unix shell) use -h only if needed.

# [mysql dir]mysql  -u username -p

Create a database on the sql server.

mysql> create database [databasename];

List all databases on the sql server.

mysql> show databases;

Switch to a database.

mysql> use [db name];

To see all the tables in the db.

mysql> show tables;

To see database’s field formats.

mysql> describe [table name];

To delete a db.

mysql> drop database [database name];

To delete a table.

mysql> drop table [table name];

Show all data in a table.

mysql> SELECT * FROM [table name];

Returns the columns and column information pertaining to the designated table.

mysql> show columns from [table name];

Show certain selected rows with the value “whatever”.

mysql> SELECT * FROM [table name] WHERE [field name] = “whatever”;

Show all records containing the name “Bob” AND the phone number ’3444444′.

mysql> SELECT * FROM [table name] WHERE name = “Bob” AND phone_number = ’3444444′;

Show all records not containing the name “Bob” AND the phone number ’3444444′ order by the phone_number field.

mysql> SELECT * FROM [table name] WHERE name != “Bob” AND phone_number = ’3444444′ order by phone_number;

Show all records starting with the letters ‘bob’ AND the phone number ’3444444′.

mysql> SELECT * FROM [table name] WHERE name like “Bob%” AND phone_number = ’3444444′;

Show all records starting with the letters ‘bob’ AND the phone number ’3444444′ limit to records 1 through 5.

mysql> SELECT * FROM [table name] WHERE name like “Bob%” AND phone_number = ’3444444′ limit 1,5;

Use a regular expression to find records. Use “REGEXP BINARY” to force case-sensitivity. This finds any record beginning with a.

mysql> SELECT * FROM [table name] WHERE rec RLIKE “^a”;

Show unique records.

mysql> SELECT DISTINCT [column name] FROM [table name];

Show selected records sorted in an ascending (asc) or descending (desc).

mysql> SELECT [col1],[col2] FROM [table name] ORDER BY [col2] DESC;

Return number of rows.

mysql> SELECT COUNT(*) FROM [table name];

Sum column.

mysql> SELECT SUM(*) FROM [table name];

Posted in Uncategorized | Leave a comment

qmailadmin was not found on this server

If you get message “qmailadmin was not found on this server” while browsing qmailadmin then it must be something with script alias. add this in your httpd.conf and restart the service

ScriptAlias /cgi-bin/ “/usr/lib/cgi-bin/”

<Directory “/usr/lib/cgi-bin”>
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>

Posted in Uncategorized | Leave a comment

INSTALL PERL IN UBUNTU

1.    Download the perl from below command

wget http://www.cpan.org/src/5.0/perl-5.14.2.tar.gz

2.    Unzip it

tar -xzf perl-5.14.2.tar.gz

3.    Change working directory to perl

cd perl-5.14.2

4.    Configure it with below commands

./Configure -des -Dprefix=/usr/bin/perl

make
make test
make install

5.    Once you have done this you can check your new version of perl by typing

Perl –V or perl –v

6.    to make this the default perl, you’d probably want to add to your .bashrc

export PATH=/usr/bin/perl:$PATH

Posted in Uncategorized | Leave a comment

How to enable tab command completion on linux

1 login to user in which you want to set command completion.

2 after that check its shell by typing following command

echo $SHELL

3 If you get /bin/sh than you need to change its shell and if you get /bin/bash than no need to do anything

4 change shell for user

5 chsh -s /bin/bash username

6 this will change the usermae user shell to /bin/bash

7 logout and login again to check

Posted in Linux | Leave a comment

How to install Cpanel in CentOS

Here are the steps to install Cpanel on CentOS server. It is recommended to have clean OS installation before you start installing Cpanel.

iptables -F
/etc/init.d/iptables save
cd /home
wget http://httpupdate.cpanel.net/latest
chmod +x latest
screen
./latest

I can take 30 mins to 3 hours based on your server configuration.

 

Posted in Linux | Leave a comment

Install clamav on debian

Here are the quick steps to install clamav on Debian.

1) Login to your server

2) Edit /etc/apt/sources.list and add this line at the bottom of the file.

deb http://volatile.debian.org/debian-volatile stable/volatile main contrib non-free

3) Then run “apt-get update; apt-get install clamav”
If you need clamd, you may also want to run apt-get install clamav-daemon

Posted in Linux | 5 Comments

mssql 2005 scheduling problem

Problem configuring mssql 2005 backup schedule.

TITLE: Microsoft SQL Server Management Studio
——————————

Property accessor ‘ScheduleDates’ on object ‘Microsoft.SqlServer.Management.SqlMgmt.SimpleJobSchedule’ threw the following exception:’Specified time is not supported in this calendar. It should be between 04/30/1900 00:00:00 (Gregorian date) and 05/13/2029 23:59:59 (Gregorian date), inclusive.
Parameter name: time’ (System)

———————————————————————————————————-
Solution:-
———
This is happening because of the timezone issue. Correct the time zone and try to make it English if possible.

 

 

Posted in Windows | 3 Comments

Warning: mysql_connect() [function.mysql-connect]: User already has more than ‘max_user_connections’ active connections in

Here are the steps.

Login to your server.

# vi /etc/mysql/my.cnf

Then add these lines in the config line.

max_connections = 100
max_user_connections = 10000

Save and exit from the configuration file and restart mysql using this command.

/etc/init.d/mysql restart
OR
/etc/init.d/mysqld restart

Posted in Linux | 7 Comments

How to create mysql database in cpanel

1) Login to your cpanel control panel.
2) You will find a main tab called “Databases”
3) Under that you will find a link called “Mysql Databases”. Just click on it and it will take you to the next page.
4) In the next page you will find a button called “Create Database” with  a text box.
5) You need to type database name in the text box and click on “Create Database”
6) Then go to “Add New User” on the same page and type “Username” and “Password” for the database and click on “Create User”
7) Then go to “Add User To Database” and select database and username you created and click on “Add”.
8) That is it. You are done with database creation.

After that you will have to assign permission to that user on the database based on your requirement.

Posted in Linux | 25 Comments