Linux, Php, Tools

Make any directory as web server root directory

In your local system temporarily you can make any directory as localhost web server root directory. If you have some static web application or static pages and you want to test. One option is you copy that web application folder in your localhost root directory then browse that directory through localhost. Another thing you can do is make that directory as web server root directory temporarily. You can do this in two ways one with PHP build in server and another with python. For PHP you should have php 5.4 or higher.

With PHP

php -S localhost:<port number>

Here -S tell php to start builtin server

example :

php -S localhost:9000

Now the current directory in which you run this command will become the web server root directory and web server will listen at 9000 port.

With Python:

python -m SimpleHTTPServer 9000

here -m tell python to import SimpleHTTPServer module.

Now the current directory in which you run this command will become the web server root directory and web server will listen at 9000 port.

Of course another way to do this is changing the configuration in apache’s httpd.conf file.

I think Ruby also provide builtin server for development, i am not aware about that. Please leave in comments if you know some another languages also provide builtin server.

Linux, Tools

Grab a static website with Wget linux command

You can get any static websites on your local system with wget linux command. Let say there is simple static web application which you want to run on your local system. One option could be that you save each page and every script and css files embedded on each page as well of that application, and then you have to correct the path of the script and css files if the paths are not relatives. Wget can do this for you. For example: is very good static web application which create awesome css shapes just using drag and drops. If you want to run this application in your local system, in case you don’t have internet access. Using the following wget command you can get this application running on your local system.

wget --recursive --no-clobber --page-requisites --convert-links --no-parent

you can pass several option to wget command. The options are:

--recursive: download the entire Web site.

--domains don't follow links outside

--no-parent: don't follow links outside the directory tutorials/html/.

--page-requisites: get all the elements that compose the page (images, CSS and so on).

--html-extension: save files with the .html extension.

--convert-links: convert links so that they work locally, off-line.

--restrict-file-names=windows: modify filenames so that they will work in Windows as well.

--no-clobber: don't overwrite any existing files (used in case the download is interrupted and


Thats all now you can open index.html file in browser and everything works, in case if this doesn’t work as expected then you can put this grabbed website directory in your localhost document root.


import command for screenshots in linux

Screenshots: Every computer guy need it either you are normal computer user or developer.
There are many tools for screenshots but what about screenshots in linux.
If you use gnome as desktop manager then there is utility available for this gnome-screenshots.
In terminal type


if you little bit nerdy and linux guy then definitely you like terminal. There is a tool to capture screenshot directly from command line. This is the import command. This command is part of a tool called ImageMagick. Before using this command you should have this tool installed on your system. This tool is for image processing and work as back end for several applications.
You can install this tool via command line.

yum install ImageMagick.

For more detail you can see this link

import filename

As you type this command your mouse pointer converts into cross “X” mark and now you can select any region or any window to capture. If you want to capture any particular window then just select that window, or any region by selecting it.

you can specify different file extensions like(jpeg, png, gif etc) in which format you want to save your screenshot. If you didn’t specify any extension then by default it saves in poscript format.


Recursively extract all compressed files in a dir

Today i need to upload some tar.gz files to ftp server then i want to extract them. one way was to extract each file individually. Then i thought to write a simple shell script to extract them because i have ssh access to that server. So this is the simple script to extract all the tar.gz compressed files in a directory.

for user in $( ls *.tar.gz )
tar zxvf $user

if you have zip file then change the *.tar.gz to *.zip and tar zxvf to unzip. If you have tar.bz2 file change tar zxvf to tar jxvf