Thursday, December 16, 2010

Getting started with Linux File System



Via my friend Sachin Nain...


Linux is a open source so every body has the freedom to put their source codes where he/she wants(Just like a person who want to decorate his home he is free to put things where he likes it). There are no boundation regarding it but if you want to distribute it then it may create the confusion to others because there are so many vendors of Linux (Suppose you are made to enter somebody's home and asked to find something from there then think of that situation. You will be total balnk).

So to avoid this confusion a International FSSTND ( File System Standard ) was made. So that user and developer should not get confused and to save the time in searching the things.

I am going to explain the Linux Dir. Structure based on FSSTND....

/
|---root
|---home
|          |----ftp
|          |----httpd
|          |----samba
|          |----user1
|          |----user2
|---bin
|---sbin
|---proc
|          |
|          |----1
|
|---usr
|          |
|          |----bin
|          |----sbin
|          |
|          |----include
|          |
|          |----lib
|          |----local
|          |----man
|          |----info
|          |----doc
|          |----tmp
|          |----X11R6
|          |
|          |----X386
|---boot
|---lib
|          |----modules
|
|---dev
|---etc
|          |----skel
|          |----sysconfig
|---var
|          |----file
|          |----lib
|          |----local
|          |----lock
|          |----log
|          |
|          |----run
|          |
|          |----spool
|          |----tmp
|          |
|          |----catman
|---mnt
|---tmp


"/"
Root directory do not get confuse with root user account it is point where the Linux directory starts.(You may consider it as the main gate of a home)

"/root" 
It is the super user home dir. Don't get confused with "/" dir.

"/home"
As Linux is the multiuser OS every user is given the personal dir to keep the related files, directories and configuration files and other stuffs. It is the playground for the user to do any thing like create, save and delete the files and installing the softwares. The config. files are saved with of '.' as the prefix which can be seen by giving '-a' as the argument to the ls command. The configuration file keeps the personal setting of the user like which environment is to start on login. Home dir contains the separate sub dir for each user.

You may consider the home dir as the House and user specific dir as the personal room of the individual family member in the house. Every member is free to do anything his/her room same in the linux.

"/bin"

It is the most essential directory of the linux operating system. It contains all the binaries for basic need of the system and command which are used by the multiple user. These can be used in single user mode even. This dir contains the commands which are used by the shell script indirectly.

"/sbin"
This dir is like the bin dir contains the basic binaries but these can be used by the 'super user' only.
e.g. shutdwon command which can be used by root user only

"/proc"
This dir contains the virtual files so called virtual file system.
It contains the the files which have the basic hardware, time, date and other system informations which keeps updated frequently. It contain bunch of numbers which have the information file related the particular process and the user login sessions etc.

"/usr"
This directory contains user applications and a variety of other things for them, like their source codes, and pictures, docs, or config files they use.
It also contains the c and c++ compiler header files in /usr/include subdir. 

"/boot"
As the name suggests, this is the place where Linux keeps information that it needs when booting up. For example, this is where the Linux kernel is kept.

"/lib"
It contains the shared binaries at the root file system. It is just like the .DLL file in windows.

"/div"
It contains the devices which are available to your linux system. Like cdrom (/div/cdrom), harddrive(/div/hda).
Keep in mind linux treats the devices as the file.

"/etc"
This is the dir which contains the system and other config files. These files are the text files and can be edited manually.

"/var"
It contains the variables which keep changing constantly like log, mail, and spool.

"/mnt"
This is the mounting point of the other devices like harddrive, cdrom, pendrive etc. the need to be attached in the dir tree to access called mount point. 

"/tmp"
This is the dir where a program writes the temporary files.

Wednesday, December 15, 2010

Chrome Experiments: Web experiments and more...

Chrome Experiments is a showcase for creative web experiments, the vast majority of which are built with the latest open technologies, including HTML5, Canvas, SVG, and WebGL. Users interested could submit their experiments in the same and demonstrated their work in the field of web. Web development and creating something new in the above technologies is the prime motive of the website. Each experiment preferably requires Google Chrome browser. 
Some of my favorites :

1. Google Gravity: Each element in the Google homepage falls under the effect of gravity & is a lot of fun to play with them. Technology used in the experiment is JavaScript, box2d-js.

Snapshots:

 


2. Google Sphere: Each element in the Google homepage forms a sphere after the a search is made. The experiment looks awesome when the images are searched. Technology used are Google api, jstween, threedoob.

Snapshots:




Friday, December 10, 2010

My first experience with Webmin

Today I will share my first experience with webmin. It happened sometime back but I am expressing it to you all now. I was shifting one of the servers from windows platform to linux. It was then I got to know of webmin from one of my seniors who was working with me.

What is Webmin?


Webmin is a web-based interface for system administration for Unix. Using any modern web browser, you can setup user accounts, Apache, DNS, file sharing and much more. Webmin lets you manage a system from the console or remotely.

Installating webmin on Ubuntu or Debian
Installtion of webmin is quite simple you need to follow the following steps to install webmin in any Debian based platform.

1. Download the webmin's debian package. It is easily available at sourceforge or you could download it from here. Save the package, it is just 14Mb in size.

2. Open the package and click install.

3. Webmin will automatically get installed to /usr/share/webmin/.

4. The username would be set to root and the password will be the current root password. If there is any other user present on the system, the username & password of that user could also be used.

5. Webmin could be accessed by using the url http://localhost:10000/
(Here 10000 is the default port for the webmin service.)
Webmin could also be accessed remotely by using your system's ip in place of localhost in the above url.

Important Note:
If debian complains of missing dependencies the it could be sort by typing the following on the terminal

apt-get install perl libnet-ssleay-perl openssl libauthen-pam-perl libpam-runtime libio-pty-perl

For more help and support you can refer the official website or contact me, I would try to help you out.

Configuring LAMP on Ubuntu

This post is for those who have a very little knowledge of linux based operating systems. LAMP stands for Linux, Apache, Mysql, Php. The following are steps to install LAMP on Ubuntu.

Installation guide for Apache.

To start off with the installations, we will first install apache.

1. Open up the Terminal (Applications > Accessories > Terminal).

2. Copy/Paste the following line of code into Terminal and then press enter:

sudo apt-get install apache2
3. The Terminal will then ask you for you're password, type it and then press enter.

Testing Apache 

To make sure we have installed everything properly we will test the apache installation.

4. Open up any web browser and then enter the following into the web address:

http://localhost/

5. You should see a folder entitled apache2-default/. Open it and you will see a message saying "It works!" , congrats to you!
 

Installation guide for PHP 

In this part will install PHP on our systems.

1. Again open up the Terminal (Applications > Accessories > Terminal).


2. Copy/Paste the following line into Terminal and press enter:

sudo apt-get install php5 libapache2-mod-php5

3. In order for PHP to work and be compatible with Apache we must restart it.  Type the following code in Terminal to do this:

sudo /etc/init.d/apache2 restart

Test PHP

To ensure there are no issues with PHP let's give it a quick test run.

1. In the terminal copy/paste the following line:

sudo gedit /var/www/test.php

This will open up a file called test.php.

2. Copy/Paste this line into the test file:

<?php phpinfo(); ?>

3. Save and close the file.

4. Now open you're web browser and type the following into the web address:

http://localhost/test.php

The page should look like this:
Congrats you have now installed both Apache and PHP!

Installation guide for MySQL

To finish this guide up we will install MySQL


1. Once again open up the amazing Terminal and then copy/paste this line:

sudo apt-get install mysql-server

2 (optional). In order for other computers on your network to view the server you have created, you must first edit the "Bind Address". Begin by opening up Terminal to edit the my.cnf file.

gksudo gedit /etc/mysql/my.cnf

Change the line
bind-address = 127.0.0.1
And change the 127.0.0.1 to your IP address.

3. Now begin by typing the following into Terminal:

mysql -u root

Following that copy/paste this line:

mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('yourpassword');
 (Make sure to change yourpassword to a password of your choice.)

4. Now we are going to install a utility called phpmyadmin. This utility is available here. This is useful in database administration. Download the latest version and extract the contents of the utility in the directory /var/www/phpmyadmin/

phpmyadmin could now be accessed by using the following url http://localhost/phpmyadmin/
It requires a mysql username and password which you have already set in the last step.


5. After that is installed our next task is to get PHP to work with MySQL. To do this we will need to open a file entitled php.ini. To open it type the following:
 
gksudo gedit /etc/php5/apache2/php.ini

6. Now we are going to have to uncomment the following line by taking out the semicolon (;).
Change this line:

;extension=mysql.so

To look like this:

extension=mysql.so

7. Now just restart Apache and you are all set!
sudo /etc/init.d/apache2 restart

Now we have successfully configured LAMP on ubuntu. This is my first attempt to write a post like this. I would like hear from you what you have to say about the same.

Sunday, August 29, 2010

Simple C++ code on g++ compiler

I remember my encounter with the g++ compiler, it was just before a coding competition. Owing my background to Windows and turboc, it was a good experience to work on linux(Ubuntu) and g++ compiler.  The following simple steps show how to write and execute a simple c++ code.

1. Check your g++ installation by typing the following on the terminal:
~$g++
If g++ is installed the following will be the response:
g++: no input files

If not then Ubuntu and Debian users type the following to install:
~$sudo apt-get install g++

2.After checking your compiler open and empty document and name it suppose hello.cpp

3.Type the following using your favorite text editor

#include<iostream>
using namespace std;
int main()
{
cout<<"hello";
return 0;
}

save the file. Make sure you save it in your current working directory.

4. On the terminal type the following:
~$g++ hello.cpp
~$./a.out
and vol la you are done.