Pages

Tuesday, 5 March 2013

How to increase SWAP space in Ubuntu?

All command should be run with root privileges,.

1. Create empty file:
This file will contain virtual memory contents so make file big enough for your needs. This one will create 1Gb file which means +1Gb swap space for your system:
dd if=/dev/zero of=/media/swapdd/swapfile.img bs=1024 count=1M

If you want to make 3Gb file then change count value to count=3M. See man dd for more information.

2. Bake swap file:
Following command is going to make "swap filesystem" inside your fresh swap file.
mkswap /media/swapdd/swapfile.img

3. Bring up on boot:
To make sure that your new swap space is activated while booting up computer you should add it to filesystem configuration file /etc/fstab.
/media/swapdd/swapfile.img swap swap sw 0 0

4. Activate:
You can either reboot your computer or activate new swap file by hand with following command:
swapon /media/swapdd/swapfile.img

You can use following commands to check your new swap and confirm that it is active:
cat /proc/swaps
Filename Type Size Used Priority
/media/swapdd/swapfile.img file 8388604 2724 -1

grep 'Swap' /proc/meminfo
SwapCached: 4772 kB
SwapTotal: 8388604 kB
SwapFree: 8355812 kB

Thursday, 15 November 2012

How To Enable Remote Access To MySQL Database Server

If you want to remotely access to the database server from the web server or home, follow this quick tutorial.By default remote access to the MySQL database server is disabled for security reasons.

Step # 1: Login Using SSH (if server is outside your data center)

First, login over ssh to remote MySQL database server:
ssh user@server.nitingoura.com

Step # 2: Edit my.cnf File

Once connected you need to edit the MySQL server configuration file my.cnf using a text editor such as vi.
  • If you are using Debian Linux file is located at /etc/mysql/my.cnf location
  • If you are using Red Hat Linux/Fedora/Centos Linux file is located at /etc/my.cnf location
  • If you are using FreeBSD you need to create a file /var/db/mysql/my.cnf
Edit /etc/my.cnf, run:
# vi /etc/my.cnf

Step # 3: Once file opened, locate line that read as follows

For example, if your MySQL server IP is 192.168.2.25 then entire block should be look like as follows:
bind-address    = 127.0.0.1 192.168.2.25
# skip-networking
  • bind-address: IP address to bind to.
  • skip-networking: This option is highly recommended for systems where only local requests are allowed. Since you need to allow remote connection this line should be removed from my.cnf or put it in comment state.

Step# 4 Save and Close the file

If you are using Debian / Ubuntu Linux, type the following command to restart the mysql server:
# /etc/init.d/mysql restart
If you are using RHEL / CentOS / Fedora / Scientific Linux, type the following command to restart the mysql server:
# /etc/init.d/mysqld restart
If you are using FreeBSD, type the following command to restart the mysql server:
# /usr/local/etc/rc.d/mysql-server stop
# /usr/local/etc/rc.d/mysql-server start

OR
# /usr/local/etc/rc.d/mysql-server restart

Step # 5 Grant access to remote IP address

Connect to mysql server:
$ mysql -u root -p

Grant access to a new database

If you want to add a new database called nitin for user goura and remote IP 10.0.0.2. then type following commands
mysql> CREATE DATABASE nitin;
mysql> GRANT ALL ON nitin.* TO goura@'10.0.0.2' IDENTIFIED BY 'PASSWORD';

Step # 7: Open port 3306

You need to open TCP port 3306 using iptables or BSD pf firewall.

A sample iptables rule to open Linux iptables firewall

/sbin/iptables -A INPUT -i eth0 -p tcp --destination-port 3306 -j ACCEPT
OR only allow remote connection from your web server located at 10.0.0.5:
/sbin/iptables -A INPUT -i eth0 -s 10.0.0.5 -p tcp --destination-port 3306 -j ACCEPT
OR only allow remote connection from your lan subnet 192.168.1.0/24:
/sbin/iptables -A INPUT -i eth0 -s 192.168.1.0/24 -p tcp --destination-port 3306 -j ACCEPT
Finally save all rules (RHEL / CentOS specific command):
# service iptables save

A sample FreeBSD / OpenBSD pf rule ( /etc/pf.conf)

pass in on $ext_if proto tcp from any to any port 3306
OR allow only access from your web server located at 10.0.0.5:
pass in on $ext_if proto tcp from 10.0.0.5 to any port 3306  flags S/SA synproxy state

Step # 8: Test it

From your remote system or your desktop type the following command:
$ mysql -u goura –h 192.168.2.25 –p
Where,
  • -u goura: goura is MySQL username
  • -h IP or hostname: 192.168.2.25 is MySQL server IP address
  • -p : for password
You can also use the telnet or nc command to connect to port 3306 for testing purpose:
$ echo X | telnet -e X 192.168.2.25 3306



Tuesday, 6 November 2012

OpenSSL on Ubuntu

First, log on to your server and install Apache:
# sudo apt-get install apache2
Now, install and enable SSL module:
# sudo a2enmod ssl
# sudo /etc/init.d/apache2 reload
Creation a directory on this location
# mkdir /etc/apache2/ssl
# cd /etc/apache2/ssl
Run these following commands
# openssl genrsa -des3 -out server.key 1024
# openssl req -new -key server.key -out server.csr
# openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
# chmod 0400 /etc/apache2/ssl/server.key
# chmod 0400 /etc/apache2/ssl/server.crt
# cp /etc/apache2/ssl/server.key server.key.orig
# openssl rsa -in server.key.orig -out server.key
# chmod 400 /etc/apache2/ssl/*


Find and edit the RED TEXT.
# vi /etc/apache2/sites-available/default-ssl
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/server.crt
SSLCertificateKeyFile /etc/apache2/ssl/server.key

Restart WebServer
/etc/init.d/apache2 restart

Thursday, 25 October 2012

How to configure Symfony 2.0 on Ubuntu Server 12.04

Download the framework from the Symfony website. Here's a link.
Either download the package directly to your /var/www directory or move it there yourself.
# cd /var/www
# wget -O symfony.tgz http://symfony.com/download?v=Symfony_Standard_Vendors_2.0.0BETA1.tgz
# tar xfz symfony.tgz
You'll now have a directory labelled Symfony in your /var/www directory.
Now navigate to http://localhost/Symfony/web/config.php.
Some comman requirements and warnings :
1. Install and enable the SQLite or PDO_SQLite extension. Just run these two commands. It doesn't matter what directory you're in.
#apt-get install php5-sqlite
#sudo apache2ctl restart
2. Change the permissions of the app/cache/ directory so that the web server can write into it.
#sudo chmod -R 777 /var/www/Symfony/app/cache
3. Change the permissions of the app/logs/ directory so that the web server can write into it.
#sudo chmod -R 777 /var/www/Symfony/app/logs
4. Set the date.timezone setting in php.ini. (like Europe/Paris).
#sudo vim /etc/php5/apache2/php.ini
Find the line with ;date.timezone = under the [Date] section, and set it to your timezone based on PHP's list of timezones. I chose America/New_York because sometimes I wish I lived there. Also, make sure to remove the semicolon at the beginning of the line!
#sudo service apache2 restart
5. Install and enable a PHP accelerator like APC (highly recommended).
#sudo apt-get install php-apc
#sudo apache2ctl restart
6. Install and enable the intl extension.
#sudo apt-get install php5-intl
#sudo apache2ctl restart
7. Set short_open_tag to off in php.ini.
#sudo vim /etc/php5/apache2/php.ini
Find the line with short_open_tag = On and change it to short_open_tag = Off

Configure

  1. At the end of the configuration script, it will try to write to /var/www/Symfony/app/config/parameters.ini, so we have to make sure it's writable.
    #Sudo chmod 777 /var/www/Symfony/app/config/parameters.ini

Wednesday, 24 October 2012

script to take a photo of my screen every five minute



sudo apt-get install scrot
#!/bin/bash
# ^This first line just tells linux which script language to use.
# We're using bash
# Because this script runs as a Cron-job, it runs as root and doesn't
# necessarily know which user you're logged in as.  For me, this says "use
# the default display, ie the first person logged in on the computer"
DISPLAY=:0
HOME=/home/vose
export DISPLAY
export HOME
# Create the screenshots directory in case it doesn't exist yet
mkdir -p /home/vose/Pictures/Screenshots/
# Delete any screenshots more than 7 days old.
find /home/vose/Pictures/Screenshots/ -type f -mtime +7 -delete
# Launch the browser (I use firefox for normal, so I'll use chrome for this)
# The "sudo -u vose ..." means "run the command as user `vose`". You'll
# You'll need to put your username in there...
# The "&" at the end means 'launch in the background', so the script
# can keep going.
echo "Opening the browser"
sudo -u vose chromium-browser http://google.com &
# This records the ProcessID (pid) of the last opened program
# (chromium) so we can kill it later
pid=$!
# Wait 10 seconds for the browser to open and page to load
# On a slow computer/connection/webpage you may need to wait longer
sleep 10
# Take the screenshot using scrot.  Save it to this file
scrot /home/vose/Pictures/Screenshots/screenshot_`date +%F-%H-%M-%S`.jpg
echo "Created screenshot_`date +%F-%H-%M-%S`.jpg"
# Kill the browser
kill $pid
Before you try go too far, stop and see if this works.
First, save the script above as takeScreenshot.sh.
Then from a terminal, type chmod +x takeScreenshot.sh (Chmod changes the permissions on a file, and '+x' means we're giving it permission to "execute" the script.)
Run ./takeScreenshot.sh from a command line - this will run the script manually. See if the file shows up in your pictures folder after doing this.
If that worked, we need to now add it to Cron.
At a command line, type sudo crontab -e. (If it asks you which editor, choose Nano. If you haven't used it before, ask around for some help).
In the file, you want to add a line at the bottom, like this:
# m h dom mon dow command
*/5 * * * * /home/vose/Scripts/takeScreenshot.sh
What this says:
Every 5 minutes
Every hour, every day-of-month, every month, every day-of-week
Run "/home/vose/Scripts/takeScreenshot.sh"

Sunday, 1 May 2011

Linux KDE Platform.

Linux also provides the KDE Platform.
  What is KDE.?????????
                  KDE stands for K Desktop Environment. It is a desktop environment for Linux based operation system. You can think KDE as a GUI for Linux OS. KDE has proved Linux users to make it use as easy as they use windows. KDE provides Linux users a graphical interface to choose their own customized desktop environment. You can choose your Graphical Interface among various available GUI interfaces that have their own look.
KDE is a Windowing Manager and Graphical User Interface for the UNIX operating system, not just Linux (but was made on Linux machines). KDE has been with us since approximately 1997 and is the one of two most popular desktops for Linux. You can freely download and distribute KDE, and these days, there is no restriction on copying it.
At the heart of KDE, lies a graphical toolkit and fully featured programming language called Qt. Qt is found on many platforms including Mobile Phones/PDAs, Windows and Mac OS, but is still most popular on the Linux/UNIX platform. Qt is made by a commercial company called Trolltech. Before early 2000, KDEs main aims are to make a highly usable, user friendly, functional and highly powerful graphical user interface. They definitely have fulfilled that goal.

Tuesday, 5 April 2011

Linux is future

Predicting the future is always risky for an author, especially one who contributes to internet sites, where your words are often instantly accessible to the curious. But I'm going to put my money on the table and take some guesses about the future of Linux. Here, in no particular order, are six theories that I believe are inevitabilities. Keep in mind that although I've been liberal in tone, nearly everything in this piece is speculation or opinion and is subject to debate. Not all of these theories are necessarily entirely original thought, but all arguments are.
1) Major Linux distributions will collapse into a small, powerful group.
"Major players" in the Linux market, until recently, included Red Hat, SuSE, Mandrake, Debian, and Slackware. Some would argue more or less, but now you have a number of popular distros making inroads into the community, Xandros, LindowsOS, and Gentoo to name a few. Another fringe including Yoper, ELX, and TurboLinux are making plays for corporate desktops. I'm coining a new term for this era of Linux computing: distribution bloat. We have hundreds of groups offering us what is essentially minor tweaks and optimizations of a very similar base. This cannot continue at this pace. There will from this point on, be a growing number of Linux installation packages as people become more skilled, but there will be fewer distributions on a mass scale as commercial Linux stabilizes.
I think we'll see the commercial Linux market boil down to two or three players, and this has already begun. I expect it to be a Ximian-ized Novell/SUSE distribution, Red Hat, and some sort of Debian offshoot - whether it's User Linux or not remains to be seen. Sun's Linux offering, Java Desktop System, will be deployed in Solaris committed companies and not much more.
2) Neither KDE nor Gnome will "win;" a third desktop environment will emerge.
The KDE/Gnome debate is a troll's dream come true. People are often passionate about their desktop environment. I believe they both have strengths and weaknesses. However, a third DE, with a clean and usable base, will emerge in time, its sole mission to unify the Linux GUI. Only when there is true consistency of the look and feel of the desktop, or close to it, will Linux become a viable home OS for an average user. Currently, we see this consistency forged by common Qt and GKT themes, and offerings like Ximian Desktop which attempts to mask the different nature of each application. This is not about lack of choice - it is, however, about not allowing choice to supercede usability of the whole product.
Features that a desktop must include are obvious by now: cut & paste must work the same way throughout the OS, menus must be the same in all file manager windows, the same shortcut keys must apply in all applications, and all applications must have the same window borders. Many seemingly basic tasks that haven't entirely matured, or in some cases, been accomplished at all, yet.
In any event, the DE's importance will lessen once greater platform neutrality exists. This will doubtlessly cause many to argue that I am wrong - admittedly, it's a tall order especially with Gnome and KDE becoming established and accomplishing so much. I maintain that unless there is some sort of merging, not a set of standards like freedesktop.org, but rather, a common base for development, that there will be a fragmented feel to Linux that simply doesn't exist in Windows today.