Welcome to Linux Family

Linux is a powerful opensource OS. Once you are in it, you feel like a genious! Now what are you waiting for? Install Linux in your machine and make the world out of it!

Apache Webserver Installation guide

Have a Linux server or localmachine? Need to power your own websites in it? Here you go!! Click to unleash apache webserver installation guide and learn to host your own sites

Linux Processes Overview

This document will give you an overview of linux processes. Advanced topics yet to come!!

Stop spamming!Sign outgoing mails

DKIM is an excellent software to digitally sign your outgoing mails and thus ensuring proper inbox delivery of all your mails.

Saturday, August 6, 2011

make servername remote in sendmail in ubuntu

In some cases, we need to make the mail handling of server name itself to be done by a remote server. Let the server name be test.com. Then if you sent a mail from the server of test.com (from backend or through a php mailer) using sendmail to user@test.com, then the mail will be tried to be delivered locally in the main server rather than actual mail handling server and this results in a failure. In that case, what I did was the following: Hope this might help you.

checked /etc/mail/local-host-names and make sure that server name (test.com) is not there. Then did the following:

1. Open /etc/mail/sendmail.mc
vi /etc/mail/sendmail.mc

2. Added the following in the end:
define(`MAIL_HUB', `test.com.')dnl define(`LOCAL_RELAY', `test.com.')dnl 
3. ran the following command to reflect the changes:
sendmailconfig
Restarted the sendmail service and I was able to send mail to the remote mail server fine.

Thursday, August 4, 2011

backup automation script in linux

sorry for the inconvenience. but the link broke and you wont be able to download the script. I will be updating this soon to a new location with an improved version.

You can download this script by clicking here.
Description:
This script when executed will generate a customized script file according to your backup needs and you just need to execute that script file in your cronjob for your backup process. Upon execution, you will be asked for a series of qns according to which the final script will be generated.
This will also display the line that you need to enter into your cronjob, so all you have to do is:
1. Open cronfile.
crontab -e
2. Paste the cron line that is displayed at the end of executing this script.

PS: cronscript.sh is the name of customized script that is generated at the end of execution and will be stored where you are executing this script. If you change its location after that, change the path in cron entry as well.

Requirements:
1. ncftp package is needed if you are going to use FTP for remote backup. You can install it using yum.
yum install ncftp*

2. If you are using ssh for backup, just make sure that you atleast connect once from the source machine to backup machine using ssh. This is to avoid the extra prompt while cron script tries to connect to remote machine.

Thats all for now. ENjoy!!

Tuesday, August 2, 2011

no mysql_check in nagios plugins ubuntu

1. apt-get install libmysqlclient15-dev
2. Now recompile nagios plugins with mysql plugin.
./configure --with-mysql
make
make install

Now check the folder /usr/local/nagios/libexec/ or wherever you had installed nagios and you will find check_mysql plugin required for checking mysql service.

how to detect servername as remote domain for mailing by sendmail

In some cases, the mails for the main hostname will be handled by remote mail servers and sendmail will tend to detect it as local domain name and hence mails from the server to the particular hostname will be taken as local. To rectify this problem, you can follow the following steps:

Before performing the following, make sure that mx entries of the hostname is resolving properly to the remote mail server. You can check this using the command:
dig mx hostname.com

1. open /etc/mail/sendmail.cf
vi /etc/mail/sendmail.cf

2. make the following change:

O DontProbeInterfaces=False

3. Save the file and restart sendmail

/etc/init.d/sendmail restart

Now mails to the hostname from the server will be relayed remotely.

sendmail how to relay mails to servername remotely

In some cases, the mails for the main hostname will be handled by remote mail servers and sendmail will tend to detect it as local domain name and hence mails from the server to the particular hostname will be taken as local. To rectify this problem, you can follow the following steps:

Before performing the following, make sure that mx entries of the hostname is resolving properly to the remote mail server. You can check this using the command:
dig mx hostname.com

1. open /etc/mail/sendmail.cf
vi /etc/mail/sendmail.cf

2. make the following change:

O DontProbeInterfaces=False

3. Save the file and restart sendmail

/etc/init.d/sendmail restart

Now mails to the hostname from the server will be relayed remotely.

Monday, August 1, 2011

trouble installing vlc in ubuntu 11.04 natty version

If you encounter problems while installing vlc player in ubuntu 11.04 , then just do the following as a speedy solution:

1. Open /etc/apt/sources.list in your favorite editor:

nano /etc/apt/sources.list

2. Add the following entry at the bottom of the file:

deb http://ubuntu.mirror.cambrium.nl/ubuntu/ natty main

3. apt-get update

4. apt-get install vlc mozilla-plugin-vlc

And you are done! Now right click on any video files and select "open with" and then select vlc from the list. Enjoy :)

how to install vlc in ubuntu 11.04 natty

First add the required repo path in sources.list file.

1. Open /etc/apt/sources.list in your favorite editor:

nano /etc/apt/sources.list

2. Add the following entry at the bottom of the file:

deb http://ubuntu.mirror.cambrium.nl/ubuntu/ natty main

3. apt-get update

4. apt-get install vlc mozilla-plugin-vlc

And you are done! Now right click on any video files and select "open with" and then select vlc from the list. Enjoy :)

vlc : Depends: vlc-nox (= 1.1.9-1ubuntu1) but it is not going to be installed natty

This is quite a nasty error when trying to install vlc player in ubuntu.

If you encounter this problem while installing vlc player in ubuntu 11.04 , then just do the following:

1. Open /etc/apt/sources.list in your favorite editor:

nano /etc/apt/sources.list

2. Add the following entry at the bottom of the file:

deb http://ubuntu.mirror.cambrium.nl/ubuntu/ natty main

3. apt-get update

4. apt-get install vlc mozilla-plugin-vlc

And you are done! Now right click on any video files and select "open with" and then select vlc from the list. Enjoy :)

This error took a lot of headaches and finally I succeeded in installing vlc in this way.

create ssh-keypair using putty-gen in windows

If you don't have puttygen, Download putty-gen utility from this link

You can also view the list of puttygen for various OS distros here

1. Download puttygen
2. Run the downloaded software.
3. You will be presented with the following API:

4. Click on "Generate" button. You will need to keep the mouse moving for generating random key. You will see the following image:
5. Save the private key. (You do not need to enter a passphrase if you dont want to enter the passphrase each time you login to the server using this key). Note the location in which you save the key. Give a suitable name. The extension will be ppk.

6. Save the public key. No extension needed. The contents inside this file will be the same which is highlighted under "Public key for pasting into OpenSSH authorized_keys file.

7. Now copy the contents of this public key into the proper location in the server into which you are logging into. The location should be as follows:

/root/.ssh/authorized_keys (if you need to login as root into the server)
or
/home/user/.ssh/authorized_keys (if you need to login as "user". /home/user is the home directory of the user and it can vary. if there is no .ssh directory inside the home dir of the user, then just create one and create the file authorized_keys inside it).

And you are done.

Now you can connect to the server using putty and the private key in your local machine using the following steps:

1. Run putty (not putty-gen). You can get putty.exe from the link here
2. As shown in the pic, expand "SSH" and select "Auth" in the left pane. Click "Browse" button and select the previously saved private key.

3. Now select "session" from the left pane and fill in the server IP address and ssh port and click on "Open" button.
PS: ensure that there are no default login names by clicking on "Data" option under the section "Connection" in the left pane.

You are done. Enjoy!

create ssh-key pair for key based authentication

For windows users:
To generate ssh keypair using puttygen in windows, follow my guide here.

For linux users:

This guide assumes that key based authentication is already enabled in the server. If you are a server admin, you can follow the guide here to set it up. If you are an end user, just confirm with your server provider whether key based authentication is enabled in ssh.

1. Create a key pair in local machine using the following command:

ssh-keygen -t rsa

Just press enter to save the key pair in the default location. For root user, it will be /root/.ssh and for any other user, it will be /home/user/.ssh (assuming /home/user is the home dir of user)

You do not need to enter any pass-phrase during key creation, or else you will be asked to enter pass-phrase each time you login with key.

You now have two keys generated inside .ssh directory. id_rsa and id_rsa.pub.
id_rsa_pub is the public key and needs to be put in the server.

2. Assign proper permission.
chmod 600 .ssh/id_rsa

3. copy the contents of id_rsa.pub into the file '/root/.ssh/authorized_keys' in the server to which you need to connect (if you need to connect as root user) or '/home/user/.ssh/authorized_keys' if you need to connect as "user".
(IMP: if there is no .ssh folder in your user's home directory, create one)

scp .ssh/id_rsa.pub user@serverip:~user/.ssh/temp.pub

4. Now login to the server and copy the contents of id_rsa.pub into the file authorized_keys.

ssh user@serverip
cat .ssh/temp.pub >> .ssh/authorized_keys

And you are done. Just logout and then simply login using the normal ssh command and you won't be prompted for a password.

Note: if you didn't save the private key in the default location, just use -i flag along with ssh command and specify the location of private key file.

ssh -i /test/id_rsa root@serverip

Note: In some cases, you would need to add the private key into ssh-agent after generating it. For that issue the foll command in your local machine after generating key pair.
ssh-add .ssh/id_rsa
.ssh/id_rsa is the private key path and may vary according to the way you saved them.
If you experience an error when issuing the above command, it can be rectified by issuing the following command:

eval `ssh-agent`
and then
ssh-add .ssh/id_rsa

ssh-add Error:'Could not open a connection to your authentication agent'

If you see this error, just use the following command to export the value of ssh-agent.

eval `ssh-agent`

227 Entering Passive Mode. ftp: connect: Connection refused vsftp

In the case of vsftp, you need to give the following in the configuration file: /etc/vsftpd/vsftpd.conf

open the conf file in your favorite editor and edit the following:

#(xx.xx.xx.xx is the server's public IP)
pasv_address=xx.xx.xx.xx
pasv_min_port=60000
pasv_max_port=65000

Save the file and restart vsftp.
/etc/init.d/vsftpd restart

Now open the ports 60000 to 65000 in your server firewall. In the case of aws instance, you can do this through "security group" in the aws interface.