Import MySQL – the command line way

Here’s a neat way to import sql script into MySQL database via command line.

mysql -u [database_user_name] -p -h localhost [database_name] 
< [/path/to/sql/file] > null

This will prompt you for the password and you’re done in a jiffy.

Enforce www on domain names

There are many samples around this. But I find the following one if you’re parking many domains on the same hosting…

RewriteCond %{HTTP_HOST} !^www\.
RewriteRule (.*) http://www.%{HTTP_HOST}/$1 [R=301,L]

A very useful tutorial around .htaccess I found is here.

Resellerclub – domain management tip

More often than not, we may need to change the name servers for multiple domains and within the interface it is very difficult to do this as quick as you want to. First you need to go to the home page, search for it and them go about it. Here’s how I found a solution. productCategory=domorder&domain=<>

Obviously, replace the ‘‘ with yours and make sure that you are logged in. This would obviously bring up the domain management page and you can get to work right from there.

Hope there’s a better one!

Recursively modify permissions

It might look all that simple, but it took me a while to figure out. The following command looks for directories and sets the permission to 777. First you need to ch into the directory and change them from there.

find . -type d -exec chmod 777 \{\} \;

If you’re installing SugarCRM you are required to set the entire directories as well as files under modules directory to writable. Go on now.

Common Shell Commands

cd [directory] The cd command changes your current working directory to the directory you specify.


% cd ~/www/htdocs/
pwd The pwd command prints your current (or present) working directory. Simply type pwd and hit
return to display your current working directory.Example:

% pwd
ls [directory] The ls command is used to list the file in the directory specified, or if you do not specify a
directory, the current working directory. You can also add some additional arguments to customize the list
display.If you type ls -F it will append a forward slash to the subdirectory names so you can
easily distinguish them from file names.

If you type ls -a it will show all hidden files. Hidden files begin with a dot
(.), such as .htaccess files.

If you type ls -l it will show detailed information about each file and directory,
including permissions, ownership, file size, and when the file was last modified.

You can also mix the arguments. If you type ls -aF you will see a list of all file
names (including hidden files) and a forward slash will be appended to directory names.


% ls -al
cat [filename] The cat command displays the contents of filename. If you want to display the file one screen
at a time try cat [filename] | more or simply more [filename].Example:

% cat ~/var/log/messages
mkdir [directory] The mkdir command makes a new directory with the name directory, that you specify.


% mkdir myfiles
rmdir [directory] The rmdir command removes the directory that you specify.


% rmdir myfiles
cp [source-file] [target-file] The cp command creates a copy of source-file with the name target-file. You can specify
pathnames as part of the file specification. If target-file exists it is overwritten.Example:

% cp index.html ~/www/htdocs/index.html
mv [source-file] [target-file] The mv command renames a file or moves it to a new location. You can specify pathnames as part of the
file specification. If target-file exists it is overwritten.Example:

% mv ~/www/htdocs/index.html ~/www/vhosts/mydomain/index.html
rm [filename] The rm command deletes (removes) a file.To remove a directory and eveyrthing inside, you can use the
-r (recursive) flag (e.g. rm -r filename).You can specify pathnames as part of the file name

% rm ~/www/htdocs/old-index.html
grep [pattern] [filenames] The grep command finds lines in files that match specified text patterns. You can specify pathnames
as part of the file specification. For example if you want to search for the pattern gif in all html files
in your current working directory, you would type grep gif *.html and hit return. The grep command would
then list all occurrences of gif it finds in .html files in the current working directory.Example:

% grep href *.html
tar [options] [tarfile] [files] The tar command copies a file or files to or from an archive. To put all the files in a
directory into one tar format file, simply type tar -cvf tarfile directory at a telnet
command prompt and replace tarfile with the name you want to call your archived file,
and replace directory with the name of the directory that contains the files you want
to compress.To extract the files from a tar format archive, simply type tar -xvf tarfile at a
telnet command prompt and replace tarfile with the name of the archived file you are

For example, you could type tar -cvf pages.tar htdocs at a telnet command prompt to
archive the files in the htdocs directory to a tar format file called pages.tar.
To view the contents of the pages.tar tarfile without extracting them, type tar -tvf
. This will display all files that are included in the tar archive. You could also
type tar -xvf pages.tar at a telnet command prompt to extract the files in the archive
pages.tar into your current directory.


% tar -cvf mysite.tar ~/www/htdocs/
zip [options] [zipfile] [files] The zip command compresses a file or list of files into a zip format archive file. Zip files
are a common archive format used on PCs (using programs such as PKZip or WinZip), so the zip utiltity
is ideal to compress large files or several files for transfer between your Virtual Private Server and your PC. Adding -r attribute recursively adds

% zip ~/www/htdocs/
% zip -r *
unzip [options] [zipfile] unzip extracts the contents of a zip file made using the zip command or using
WinZip or PKZip on your PC.Example:

% unzip ~/www/htdocs/
du [options] [path] du displays the disk usage / directory size for the specified path The options -hs provides human readable summary.

% du -hs ~/www/htdocs/

Reseller Club – Personal DNS – How to

So your webhost has given you your own IP addresses. How do you set them up? Here’s how…

  1. In your Domain Reseller Control Panel, Under Domains Menu, search for the domain you wish to create Personal DNS
  2. Click on the link which says Click to Manage against the domain name which you wish to manage
  3. Click on the Modify Child Name Server button
  4. Enter “NS1” in the Name Server textbox and the first IP address provided by the webhost and click on ADD
  5. Enter “NS2” in the Name Server textbox and the other IP address and click on ADD
  6. You can repeat this for as many IP addresses you have received
  7. Finally, Click on the Modify Name Server button
  8. Supply the Name Server you have setup a while ago on your domain name and Click on Submit [ex: NS1.YOURDOMAIN.COM , NS2.YOURDOMAIN.COM ]

Moving into Apache

The PHP5 move also meant many hosts also upgraded to a fresh apache – 2.0.62? Now, many .htaccess rewrite rules failed to work and one of the main reasons that I could learn was that the previous rewrite engine was very forgiving with the regex rules and this new one hits right back at you!

RewriteCond %{HTTP_HOST} !^$
# was okay with the previous one but now you better have it as
RewriteCond %{HTTP_HOST} !^www\.foodomain\.com$

Does that ring a bell?

Moving to PHP5

World’s saying bye to PHP4 which had kept us busy for more than 3 years now. Some of the moves were forced even as early as one year ago. But yes, who likes more work!

zend.ze1_compatibility_mode – On

#.htaccess way
php_value zend.ze1_compatibility_mode “On”

might as well do the trick for most of us. But yes, the effort of writing things from scratch sometimes leaves a great cleaner stuff and less patchy stuff.

So dear fellow geeks, all the best in moving to PHP5