Tag Archives: svlinux

Useful Linux Commands……

General Information
# cat /proc/version  (Linux Version)
# cat /proc/meminfo (Memory Information)

Zip File/Folder in Linux
# zip -9 -r <zip file> <folder name>
# zip -9 <zip file> <filename>
Use “-9? for best compression. The compressed file works fine with Windows XP compression tool.

Execute Shell Script
# chmod x+
# ./

System User
# useradd -d /var/www wwwuser
# passwd wwwuser
# userdel wwwuser
# userdel -r wwwuser

List loaded Modules
# lsmod

Extract here
# tar -xvzf latest.tar.gz -C ./(folder name)
# unzip

Upload site with zipped version
# zip -9 -r /var/www/html/ /var/www/html
# wget
# unzip
# cd /root/var/www/html
# mv * /var/www

Create shortcuts in linux
# rm -rf /var/www/
# ln -sf /var/scalr/app/www /var/
# chmod a+rX -R /var/www
# ln -sf /var/log/apache2 /var/www/logs

Compute Load
# uptime   (1,5,15 minute)
# w
# top
* CPU usage
* ‘uptime’ for load average
* ‘top’ for an overall system view
* ‘iostat’ for storage I/O statistics
* ‘netstat’ for network statistics
* ‘mpstat’ for CPU statistics
* ‘tload’ for display an ncurses graphic of the recent load

Linux Ports/processes
# netstat -an
# lsof -i
# nslookup www.*.com
# ps aux | grep mysqld
# netstat -an
# netstat -an | grep 3306

Updrage php 5.2.x
cd /etc/yum.repos.d
yum –enablerepo=remi update mysql
yum –enablerepo=remi update php
apachectl restart

# whereis  file
# locate filename
# find / -name filename
# shutdown -r now (restart)

1 Comment

Posted by on January 9, 2009 in Linux, php, resources


Tags: , ,

MySQL backup by command line

# mysqldump -u username -p databasename > filename.sql
Compress the .sql file with gzip:

#gzip filename.sql

# mysqldump --all-databases > all_databases.sql

# mysqldump --user=root \
> --password=sa --host=localhost \
> database > backup.sql

# mysqldump --user=root --password=sa --host=localhost  database > /var/www/backup.sql
Leave a comment

Posted by on November 13, 2008 in Linux, php, resources


Tags: , , ,

upload MySQL database – Command Line

Method 1 :

Create database for database_name and import the sql:
$ mysqladmin -p create database_name
$ mysql -p database_name < /var/www/html/database.sql

Method 2 :

Upload large SQL file by command line
copy SQL (database.sql) file to mysql/bin

D:……\>mysql -u root -p
Enter Password:

mysql>use database_name;
mysql>source database.sql

SQL ok.
Enjoy, may it will save someones some time!

Leave a comment

Posted by on November 13, 2008 in Linux, php, resources


Tags: , , ,

How to create .htpasswd?

Create .htpasswd file from commandLine:

# htpasswd -c  /var/www/html/.htpasswd sandeep
New password:
Re-type new password:
Updating password for user sandeep

Add these lines to .htaccess file

AuthType basic
AuthName “Ooops! Temporarily Under Construction…”
AuthUserFile /var/www/html/.htpasswd
AuthGroupFile /dev/null
Require valid-user # password prompt for everyone else
Order Deny,Allow
Deny from all
Allow from # Your, the developers IP address
Allow from # css/xhtml check
Allow from # Allows google to crawl your pages
Satisfy Any # no password required if host/ip is Allowed

Leave a comment

Posted by on November 13, 2008 in Linux, php


Tags: , , , ,

Weblog Thumbnails


Html2image can convert html to bmp, convert html to png and convert html to jpg.

Installation process

1. Download html2image tool

2. Extract html2image
tar xvzf html2image.i386.tar.gz
cd html2image

3. Run Xvfb
Xvfb :1 -screen 0 640x480x24 -nolisten tcp -audit 4 -auth X1.cfg & export DISPLAY=:1

(virtual framebuffer X server xvfb provides an X server that can run on machines with no display hardware and no physical input devices. It emulates a dumb framebuffer using virtual memory.)

4. Convert html 2 image by below command
./html2image a.jpg

Shell Script to access this tool from command line


cd; cd /opt/html2image



#rm /tmp/.X1-lock

./Xvfb :1 -screen 0 1024x768x24 -nolisten tcp -audit 4 -auth X1.cfg & export DISPLAY=:1

./html2image $1 /home/siteroot/public_html/html2image/$2

echo “html 2 image Done!”

PHP script (html_2_image.php)


exec(“export LD_LIBRARY_PATH=/opt/”); // if html2image folder in /opt folder

// here html_2_image is above shell script

exec(“/opt/html_2_image yahoo.png”, $result, $returnValue);


Execute “html_2_image.php” with cron job, the result image will saved to “/home/siteroot /public_html/html2image/” folder.


Posted by on June 20, 2008 in Linux, php, resources


Tags: , , , ,