Thursday, May 7, 2015

How to block websites and show warning page in local machine using webserver?

This post specific to Debian based linux

3 main steps:
1. Add website entries in the /etc/hosts file
2. Setup a webserver in local machine
3. Create files to serve using web server.

1. Add website entries in /etc/hosts file

    Open /etc/hosts file in an editor (as a super user, for normal users the file will open only in readonly mode.).  The typical content of the file will looks like

#Local Machine
127.0.0.1    localhost
127.0.1.1   

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters


add your new entries (websites to be blocked) at the bottom of the file like

127.0.0.1    twitter.com
127.0.0.1    yahoo.com
127.0.0.1    facebook.com
...
...
save and exit.

2. Setup a webserver in local machine.


  Any webserver can be used for the very purpose which ranges apache, Thin, twiggy, yaws, wbox, webfs, mini-httpd, lighttpd etc.,   As we are going to serve only one static webpage, It would be better if we use a very minimal, low foot print server.

I found micro-httpd a optimum one for the purpose.  Now, do the following steps in terminal.

#touch /etc/inetd.conf

#sudo apt-get install micro-httpd inetutils-inetd

By default the service directory for the micro-httpd server is "/var/www".  But, if you want to change it, you can do so in the file "/etc/inetd.conf".

3. Create files to serve using web-server


Content of a sample warning page.

<html>
<head> <title> Warning page! </title> </head>
<body bgcolor="black">
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<div align="center" style="color: red; margin-top: 25%;">

<b><h2>
Very Sorry!The website you are trying to acces is blocked </h2>
</b> </div>
</body>
</html>

copy paste the above content in a file and save it with the name "index.html" under "/var/www/" directory.  Now, reboot your machine then try to access the blocked websites via browser.  Now, you can access all the websites for blocked one your browser will show the warning page.

Thursday, April 9, 2015

How to Open/Browse sqlite files in Linux?

What is sqlite?
As per "wikipedia"
    SQLite is a relational database management system contained in a C programming library. In contrast to other database management systems, SQLite is not a client–server database engine. Rather, it is embedded into the end program.
   
Where it is used?
    Browsers,
    Mobile Operating systems
    Mobile Apps,
    Web Frame Works like Django, Ruby on Rails etc.,
   
In (Debian based)Linux (am Using BOSS GNU/Linux) there are many GUI/CUI applications available to work with sqlite. Few of them are
CUI:
    sqlite
    sqlite3
   
GUI:
    sqlitebrowser (Now renamed as  "SQLite Database Browser" or simply DB browser)
    sqliteman (Download from here http://sqliteman.yarpen.cz/)
    sqlitestudio (Download from here http://sqlitestudio.pl/)
   

Wednesday, December 31, 2014

Thursday, September 25, 2014

Mangalyan - Victory in Maiden attempt :)

First ever country in the world in its first ever attempt to Mars mission with a victory.  Proud to be an Indian.  #Mangalyan #Mars #Victory #ISRO #INDIA



Mangalyan - ISRO

Wednesday, June 25, 2014

How to install Samsung SCX-4521-NS multifunction printer in Linux?


Steps to install drivers for SAMSUNG SCX-4521-NS multifunction printer

1. Download the driver file for linux from the following url

2. extract the downloaded file then open Applications → Terminal
Assume that the downloaded file is in the directory ~/Downloads

3. Issue the following commands as in the same order
$cd ~/Downloads/uld
$./ install.sh

give proper values (mostly yes/no options) whenever prompted

4. Once the driver got installed, connect your printer with the PC/Laptop then do the following steps

5. Go to Applications → System tools → Administration → Printing this will open printer configuration wizard.  (Am Using a debian derived distro named BOSS GNU/Linux, in your destro the "Printing" may be available under different menu item, with different name)

6. Click on Add button, give password whenever prompted. The connected printer will be automatically detected and then click on Forward button. Now a new popup window will open select the option “provide ppd file”

7. Now browse to the location of ppd file (which is /usr/share​/ppd/uld-samsung)

8. Now select the ppd file with the exact name as “Samsung_SCX-4650_4x21S_Series.ppd”
then proceed.

9. Now, test your configuration with “print test page”