Linux user's guide

Find out the Linux distribution name, version and Kernel details

Sometimes, You might forget the running Linux distribution version, name, and Kernel details in  your VPS. Probably, you will get those details easily from the Settings menu if your system has a GUI. But in CLI mode, it is bit difficult for beginners to find out these details. No worries, Here I come up with simple, yet useful commands that will help you to achieve this goal.

1. Find out Linux distribution name, version etc.

There are many methods can be used to find out what OS is running on in your VPS.

Method 1:

Fire up your Terminal and run the following command:

cat /etc/*-release

Sample output from CentOS 7:

CentOS Linux release 7.0.1406 (Core) 
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"

CentOS Linux release 7.0.1406 (Core) 
CentOS Linux release 7.0.1406 (Core)

Sample output from Ubuntu 14.04:

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=14.04
DISTRIB_CODENAME=trusty
DISTRIB_DESCRIPTION="Ubuntu 14.04.3 LTS"
NAME="Ubuntu"
VERSION="14.04.3 LTS, Trusty Tahr"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 14.04.3 LTS"
VERSION_ID="14.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
Method 2:

The following command will also get your distribution details.

cat /etc/issue

Sample output from Ubuntu 14.04:

Ubuntu 14.04.3 LTS \n \l
Method 3:

The following command will get you the distribution details in DEB based systems like Debian and Ubuntu.

lsb_release -a

Sample output:

No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 14.04.3 LTS
Release: 14.04
Codename: trusty

2. Find out Kernel details

Method 1:

To find out your Linux kernel details, run the following command from your Terminal.

uname -a

Sample output in CentOS 7:

Linux server.ostechnix.com 3.10.0-123.9.3.el7.x86_64 #1 SMP Thu Nov 6 15:06:03 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

Sample output in Ubuntu 14.04:

Linux ostechnix 3.13.0-62-generic #102-Ubuntu SMP Tue Aug 11 14:29:36 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

Or,

uname -mrs

Sample output:

Linux 3.13.0-62-generic x86_64

Where,

  • Linux – Kernel name
  • 3.13.0-62-generic – Kernel version
  • x86_64 – System hardware architecture (i.e 64 bit system)

For more details about uname command, refer the man page.

man uname
Method 2:

From your Terminal, run the following command:

cat /proc/version

Sample output from CentOS 7:

Linux version 3.10.0-123.9.3.el7.x86_64 (builder@kbuilder.dev.centos.org) (gcc version 4.8.2 20140120 (Red Hat 4.8.2-16) (GCC) ) #1 SMP Thu Nov 6 15:06:03 UTC 2014

Sample output from Ubuntu 14.04:

Linux version 3.13.0-62-generic (buildd@lgw01-59) (gcc version 4.8.2 (Ubuntu 4.8.2-19ubuntu1) ) #102-Ubuntu SMP Tue Aug 11 14:29:36 UTC 2015

That’s it. I hope you have learnt how to find out the running Linux distribution name, version and Kernel details. Pass it on to your friends and colleagues.

Cheers!

CouchPotato

CouchPotato – Download Movies as soon as they are released

Greetings!

Today, we’ll see an interesting and useful tool which will help the Movie freaks to download movies in the best quality as soon as they are released in popular torrent and Usenet sites. Meet CouchPotato, a free Open Source, multi-platform application. It is easy to install, use, and configure and it saves lot of time. It is an automatic NZB and torrent downloader. You can keep a “movies I want”-list and it will search for NZBs/torrents of these movies every X hours. Once a movie is found, it will send it to SABnzbd or download the torrent to a specified directory. You don’t have to manually search on each torrent site to download best quality movies. Just add the movie titles you want to download in CouchPotato and do your regular work. It will automatically download the movies in your desired location when they are available on Internet. And of course you can define the download location of your own. How cool, isn’t it? It works well on Linux, Windows, and Mac OS X. Also, it has browser extension for popular web browsers including Mozilla Firefox, Chrome, and Safari.

Features

  • Automatic downloading and sending of NZBs to SABnzbd.
  • Automatic downloading of torrents files to a specified directory.
  • Easily add movies via IMDB UserScript.
  • Movie sorting & renaming.
  • Trailer downloading.
  • Quality options to download best available. Overwrite if better is found.
  • A “Coming Soon” page with soon to be released DVD and Theater info.
  • Support for NZBs.org, NZBMatrix, Newznab.com and ThePirateBay.

Install CouchPotato

First, install the following prerequisites:

  1. Python
  2.  Git

To install python and Git on Debian/Ubuntu based systems, run the following command from your Terminal:

sudo apt-get install python git

On Fedora, CentOS:

sudo yum install python git

Make a directory for CouchPotato in /opt/ location.

sudo mkdir /opt/couchpotato

Change to the CouchPotato directory, and git clone CouchPotato repository as shown below.

cd /opt/couchpotato/
sudo git clone https://github.com/RuudBurger/CouchPotatoServer.git

Now, make CouchPotato to run automatically on every reboot.

Copy the init script to /etc/init.d/ location.

sudo cp CouchPotatoServer/init/ubuntu /etc/init.d/couchpotato

Create a file called couchpotato:

sudo nano /etc/default/couchpotato

Add the following contents:

CP_USER=sk
CP_HOME=/opt/couchpotato/CouchPotatoServer
CP_DATA=/home/sk/couchpotato

Here, “sk” is my username. Replace it with your own username.

Make it executable using command:

sudo chmod +x /etc/init.d/couchpotato

Add it to defaults:

sudo update-rc.d couchpotato defaults

Finally, start CouchPotato daemon using command:

sudo service couchpotato start

Open your web browser and navigate to http://localhost:5050/wizard/.

This is how my CouchPotato web console looks.

CouchPotato - Google Chrome_001

Usage

In CouchPotato dashboard, Scroll down a little bit, and fill the details in the General section. If you want to access CP(CouchPotato) from outside your local network, you better secure it a bit with a username and password.

CouchPotato - Google Chrome_002

Select your default torrent application (Ex. Transmission) and Enter the username and password. Also, select the location where you want to download the torrent files. If you leave blank, the torrent will downloaded in your Torrent application’s default download directory.

CouchPotato - Google Chrome_004

Scroll down further and fill all required details.

Finally click the Big green button at the bottom

CouchPotato - Google Chrome_005

You’ll be redirected to the CouchPotato login screen again. Enter the username and password which you defined before.

CouchPotato - Google Chrome_006

Voila! We’re ready to download the movies. By default, CouchPotato will show some suggested movies. If you want them, just hover the mouse over the movie and click the (+) button to add it your wanted list.

CouchPotato - Google Chrome_007

Select the movie quality (Ex. 1080p, 720p etc.) and click Add.

CouchPotato - Google Chrome_008

Now, the added movies will be shown in the “Wanted” section.

CouchPotato - Google Chrome_009

To add additional movies, enter the movie name on the Search box (Ex. Mission Impossible). Select the movie quality and click Add.

CouchPotato - Google Chrome_011

Similarly, you can add any movies of your choice. Once they available on the Internet, they will be automatically downloaded to the specified directory. You can access the Settings page later bu clicking on the gear button on the top right corner of the CouchPotato dashboard.

CouchPotato - Google Chrome_012

Also, CouchPotato developer has developed extensions for Mozilla Firefox, Google Chrome, and Safari browsers to add movies easily via IMDB.com.

Updating Couchpotato

To update CouchPotato to latest available version, do the following.

cd /opt/couchpotato/CouchPotatoServer/

Pull new updates using command:

sudo git pull

Or, you can directly update it from the CouchPotato from the Dashboard.

Go to Settings by clicking on the Gear button on the top right corner.

Select Check for Updates.

Selection_001

Disclaimer: 

Some countries have banned Torrents and copyrighted movies on Internet to download and use them. Check with your Country rules. Neither me nor Ostechnix is responsible for any kind of misuse or troubles. Use this application with caution.

Cheers!

Source & Reference:

Webcam

How To Disable Built-in Webcam In Ubuntu

Hello Ostechnix readers, What’s up?

It’s been a long time since I have published an article in our blog. It’s time to restart my work again in this blog. From today, I have decided to publish something useful and cool articles regularly in Ostechnix.

Well, today we’ll see how to disable your Laptop or desktop built-in or external webcam when it’s not used, and how to enable it back when it’s required in your Ubuntu operating system. A recent study confirms that some advanced hackers can spy on you using your webcam without your knowledge. By hacking your webcam, the user can send your private photos and screenshots to someone whom you never knew or met ever. It’s really disgusting and it could lead you into biggest trouble you ever imagine.

Spy webcam

Also, you can benefit from disabling your Web Camera in two ways. Firstly, you can save little power, and secondly you can save some bit amount of RAM usage by your webcam. So that your computer might boot bit faster.

Disable Built-in webcam in Ubuntu

First, let me show you how much memory is consumed by your Webcam driver.

To find it out, run the following command:

sudo lsmod | grep uvcvideo

Sample output:

uvcvideo 80885 0 
videobuf2_vmalloc 13216 1 uvcvideo
videobuf2_core 40664 1 uvcvideo
videodev 134688 2 uvcvideo,videobuf2_core

As you see in the above output, my webcam driver is consuming about 8MB. It’s not that big, but atleast we can save it, and hide from the prying eyes.

Now, let us disable webcam.

To do that, edit file:

sudo nano /etc/modprobe.d/blacklist.conf

Add the following lines at the End.

##Disable webcam.
blacklist uvcvideo

The line “##Disable webcam” is not necessary. I have added it to find this line easily later.

Save and exit the file. Reboot your laptop.

That’s it.

To verify, whether Webcam is really disable or not, open any web cam software such Cheese or Gucview. You will find that the webcam is not working anymore.

Cheese Output:

Cheese_001

Gucview output:

_002

Hurrah! The web cam is disabled and is not working.

To enable it back, edit:

sudo nano /etc/modprobe.d/blacklist.conf

Comment the above lines which you have added earlier.

##Disable webcam.
#blacklist uvcvideo

Save and close the file. Then, reboot your Computer to enable your Webcam.

Conclusion

This method is not only for the built-in cam, also for external web camera. It’s very good idea to cover or unplug your external camera as well or disable it in the BIOS when it’s not used. Prevention is better than cure, right?

Hope this helps. Have a good day!

ftp

Setup FTP Server step by step in CentOS / RHEL / Scientific Linux 6.3/6.4/6.5

This tutorial shows you how to install and configure FTP server in CentOS 6.5. Though the steps provided here are tested in CentOS 6.5, it should work on RHEL 6.x(x stands for version) and Scientific Linux 6.x too. In this tutorial my ftp server ip and hostname are 192.168.1.200 and mainserver.ostechnix.com respectively. I have already configured a local repository and i am gonna to install FTP from my local repository. For more information navigate to setup your local repoistory in CentOS 6 / RHEL 6 / Scientific Linux.
Before proceed, stop the firewall.
[root@mainserver ~]# service iptables stop
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
iptables: Unloading modules:                               [  OK  ]
[root@mainserver ~]# service ip6tables stop
ip6tables: Flushing firewall rules:                        [  OK  ]
ip6tables: Setting chains to policy ACCEPT: filter         [  OK  ]
ip6tables: Unloading modules:                              [  OK  ]
[root@mainserver ~]# chkconfig iptables off
[root@mainserver ~]# chkconfig ip6tables off
[root@mainserver ~]#
Now let us install FTP service.
[root@mainserver ~]# yum install -y vsftpd
[root@mainserver ~]# Start vsftpd service.
[root@mainserver ~]# service vsftpd start
Starting vsftpd for vsftpd:                                [  OK  ]
[root@mainserver ~]#
Enable vsftpd in multi-user levels.
[root@mainserver ~]# chkconfig vsftpd on
Now edit the /etc/vsftpd/vsftpd.conf file. Uncomment and edit the lines in the vsftpd.conf file which are shown in bold.
[root@mainserver ~]# cat /etc/vsftpd/vsftpd.conf 
# Example config file /etc/vsftpd/vsftpd.conf
#
# The default compiled in settings are fairly paranoid. This sample file
# loosens things up a bit, to make the ftp daemon more usable.
# Please see vsftpd.conf.5 for all compiled in defaults.
#
# READ THIS: This example file is NOT an exhaustive list of vsftpd options.
# Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd's
# capabilities.
#
# Allow anonymous FTP? (Beware - allowed by default if you comment this out).
anonymous_enable=NO
#
# Uncomment this to allow local users to log in.
local_enable=YES
#
# Uncomment this to enable any form of FTP write command.
write_enable=YES
#
# Default umask for local users is 077. You may wish to change this to 022,
# if your users expect that (022 is used by most other ftpd's)
local_umask=022
#
# Uncomment this to allow the anonymous FTP user to upload files. This only
# has an effect if the above global write enable is activated. Also, you will
# obviously need to create a directory writable by the FTP user.
#anon_upload_enable=YES
#
# Uncomment this if you want the anonymous FTP user to be able to create
# new directories.
#anon_mkdir_write_enable=YES
#
# Activate directory messages - messages given to remote users when they
# go into a certain directory.
dirmessage_enable=YES
#
# The target log file can be vsftpd_log_file or xferlog_file.
# This depends on setting xferlog_std_format parameter
xferlog_enable=YES
#
# Make sure PORT transfer connections originate from port 20 (ftp-data).
connect_from_port_20=YES
#
# If you want, you can arrange for uploaded anonymous files to be owned by
# a different user. Note! Using "root" for uploaded files is not
# recommended!
#chown_uploads=YES
#chown_username=whoever
#
# The name of log file when xferlog_enable=YES and xferlog_std_format=YES
# WARNING - changing this filename affects /etc/logrotate.d/vsftpd.log
#xferlog_file=/var/log/xferlog
#
# Switches between logging into vsftpd_log_file and xferlog_file files.
# NO writes to vsftpd_log_file, YES to xferlog_file
xferlog_std_format=YES
#
# You may change the default value for timing out an idle session.
#idle_session_timeout=600
#
# You may change the default value for timing out a data connection.
#data_connection_timeout=120
#
# It is recommended that you define on your system a unique user which the
# ftp server can use as a totally isolated and unprivileged user.
#nopriv_user=ftpsecure
#
# Enable this and the server will recognise asynchronous ABOR requests. Not
# recommended for security (the code is non-trivial). Not enabling it,
# however, may confuse older FTP clients.
#async_abor_enable=YES
#
# By default the server will pretend to allow ASCII mode but in fact ignore
# the request. Turn on the below options to have the server actually do ASCII
# mangling on files when in ASCII mode.
# Beware that on some FTP servers, ASCII support allows a denial of service
# attack (DoS) via the command "SIZE /big/file" in ASCII mode. vsftpd
# predicted this attack and has always been safe, reporting the size of the
# raw file.
# ASCII mangling is a horrible feature of the protocol.
ascii_upload_enable=YES
ascii_download_enable=YES
#
# You may fully customise the login banner string:
ftpd_banner=Welcome to OSTECHNIX FTP service.
#
# You may specify a file of disallowed anonymous e-mail addresses. Apparently
# useful for combatting certain DoS attacks.
#deny_email_enable=YES
# (default follows)
#banned_email_file=/etc/vsftpd/banned_emails
#
# You may specify an explicit list of local users to chroot() to their home
# directory. If chroot_local_user is YES, then this list becomes a list of
# users to NOT chroot().
#chroot_local_user=YES
#chroot_list_enable=YES
# (default follows)
#chroot_list_file=/etc/vsftpd/chroot_list
#
# You may activate the "-R" option to the builtin ls. This is disabled by
# default to avoid remote users being able to cause excessive I/O on large
# sites. However, some broken FTP clients such as "ncftp" and "mirror" assume
# the presence of the "-R" option, so there is a strong case for enabling it.
ls_recurse_enable=YES
#
# When "listen" directive is enabled, vsftpd runs in standalone mode and
# listens on IPv4 sockets. This directive cannot be used in conjunction
# with the listen_ipv6 directive.
listen=YES
#
# This directive enables listening on IPv6 sockets. To listen on IPv4 and IPv6
# sockets, you must run two copies of vsftpd with two configuration files.
# Make sure, that one of the listen options is commented !!
#listen_ipv6=YES
pam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES
use_localtime=YES
Now let us restart the vsftpd service and try to connect to ftp server.
[root@mainserver ~]# service vsftpd restart
Shutting down vsftpd:                                      [  OK  ]
Starting vsftpd for vsftpd:                                [  OK  ]
Connect to the ftp server.
Note: Root is not allowed to connect to ftp server by default for security purpose. So lets us create a new user called ostechnix.
[root@mainserver ~]# useradd ostechnix
[root@mainserver ~]# passwd ostechnix
Changing password for user ostechnix.
New password: 
BAD PASSWORD: it is based on a dictionary word
Retype new password: 
passwd: all authentication tokens updated successfully.
Connet to FTP server using the new user ostechnix.
[root@mainserver ~]# ftp 192.168.1.200
-bash: ftp: command not found
[root@mainserver ~]#
Oops! ftp package is not installed. So let us install ftp package first.
[root@mainserver ~]# yum install -y ftp
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package ftp.i686 0:0.17-51.1.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
 Package       Arch           Version                 Repository           Size
================================================================================
Installing:
 ftp           i686           0.17-51.1.el6           localrepo            55 k
Transaction Summary
================================================================================
Install       1 Package(s)
Total download size: 55 k
Installed size: 91 k
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
  Installing : ftp-0.17-51.1.el6.i686                                       1/1 
  Verifying  : ftp-0.17-51.1.el6.i686                                       1/1 
Installed:
  ftp.i686 0:0.17-51.1.el6                                                      
Complete!
[root@mainserver ~]#

Again connect to the FTP server.

[root@mainserver ~]# ftp 192.168.1.200
Connected to 192.168.1.200 (192.168.1.200).
220 Welcome to OSTECHNIX FTP service.
Name (192.168.1.200:root): ostechnix
331 Please specify the password.
Password:
500 OOPS: cannot change directory:/home/ostechnix
Login failed.
ftp>
It shows a error that the user cannot change to his $HOME directory. Type exit to return back from the ftp console and allow vsftpd daemon to change users into their $HOME directories. To do that update SELinux configuration using the command below.
[root@mainserver ~]# setsebool -P ftp_home_dir on
And finally connect to the FTP server.
[root@mainserver ~]# ftp 192.168.1.200
Connected to 192.168.1.200 (192.168.1.200).
220 Welcome to OSTECHNIX FTP service.
Name (192.168.1.200:root): ostechnix
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> pwd
257 "/home/ostechnix"
ftp>
Its working now. You can use your FTP server.

Connect to FTP server using Filezilla from Client:

Download and install Filezilla client software to any one of the client systems. Open the Filezilla client and enter the username and password which we have created earlier and click connect.

Connect to FTP server via browser from the client:

Open the browser and navigate to ftp://192.1168.1.200. Enter the username and password which we cretaed earlier.
If you want to browse ftp server using domain name(i.e ftp://ostechnix.com) instead of ip address, add the ftp server ip in the DNS server records. For more information to configure DNS server navigate to Setup DNS server in CentOS 6.3/RHEL 6.3/Scientific Linux 6.3.
Thats it. You can access your FTP server from any client now using Filezilla and as well as from your client web browser.
Have a good day!!!

Setup NFS Server in CentOS / RHEL / Scientific Linux 6.3/6.4/6.5

In this tutorial let us see how to install and configure NFS server and how to share files between NFS server and clients. Though i have tested these steps in CentOS 6.5 32 bit edition, it will work on RHEL/Scientific Linux 6.x too.

Scenario

NFS Server Operating System : CentOS 6.5 32 bit (Minimal server install)
NFS Client Operating System  : CentOS 6.5 32 bit (Minimal Desktop install)
NFS Server IP Address              : 192.168.1.200/24
NFS Client IP Address               : 192.168.1.29/24

1. Install NFS in Server

[root@server ~]# yum install nfs* -y

2. Start NFS service

[root@server ~]# /etc/init.d/nfs start
Starting NFS services:                                     [  OK  ]
Starting NFS mountd:                                       [  OK  ]
Stopping RPC idmapd:                                       [  OK  ]
Starting RPC idmapd:                                       [  OK  ]
Starting NFS daemon:                                       [  OK  ]
[root@server ~]# chkconfig nfs on

3. Install NFS in Client

[root@vpn client]# yum install nfs* -y

4. Start NFS service in client

[root@vpn client]# /etc/init.d/nfs start
Starting NFS services:                                     [  OK  ]
Starting NFS quotas:                                       [  OK  ]
Starting NFS mountd:                                       [  OK  ]
Stopping RPC idmapd:                                       [  OK  ]
Starting RPC idmapd:                                       [  OK  ]
Starting NFS daemon:                                       [  OK  ]
[root@vpn client]# chkconfig nfs on

5. Create shared directories in server

Let us create a shared directory called ‘/home/ostechnix’ in server and let the client users to read and write files in the ‘home/ostechnix’ directory.
[root@server ~]# mkdir /home/ostechnix
[root@server ~]# chmod 755 /home/ostechnix/

6. Export shared directory on server

Open /etc/exports file and add the entry as shown below
[root@server ~]# vi /etc/exports
/home/ostechnix 192.168.1.0/24(rw,sync,no_root_squash,no_all_squash)
where,
 /home/ostechnix  – shared directory
192.168.1.0/24      – IP address range of clients to access the shared folder
rw                          – Make the shared folder to be writable
sync                       – Synchronize shared directory whenever create new files/folders
no_root_squash   – Enable root privilege  (Users can read, write and delete the files in the shared directory)
no_all_squash     – Enable user’s authority
Now restart the NFS service.
[root@server ~]# /etc/init.d/nfs restart
Shutting down NFS daemon:                                  [  OK  ]
Shutting down NFS mountd:                                  [  OK  ]
Shutting down NFS services:                                [  OK  ]
Starting NFS services:                                     [  OK  ]
Starting NFS mountd:                                       [  OK  ]
Stopping RPC idmapd:                                       [  OK  ]
Starting RPC idmapd:                                       [  OK  ]
Starting NFS daemon:                                       [  OK  ]       -

7. Mount shared directories in client

Create a mount point to mount the shared directories of server.
To do that create a directory called ‘/nfs/shared’ (You can create your own mount point)
[root@vpn client]# mkdir -p /nfs/shared
Now mount the shared directories from server as shown below
[root@vpn client]# mount -t nfs 192.168.1.200:/home/ostechnix/ /nfs/shared/
This will take a while and shows a connection timed out error for me. Well, don’t panic, firwall might be restricting  the clients to mount shares from server. Simply stop the iptables to rectify the problem or you can allow the NFS service ports through iptables.
To do that open the /etc/sysconfig/nfs file and uncomment the lines which are marked in bold.
[root@server ~]# vi /etc/sysconfig/nfs
#
# Define which protocol versions mountd 
# will advertise. The values are "no" or "yes"
# with yes being the default
#MOUNTD_NFS_V2="no"
#MOUNTD_NFS_V3="no"
#
#
# Path to remote quota server. See rquotad(8)
#RQUOTAD="/usr/sbin/rpc.rquotad"
# Port rquotad should listen on.
RQUOTAD_PORT=875
# Optinal options passed to rquotad
#RPCRQUOTADOPTS=""
#
#
# Optional arguments passed to in-kernel lockd
#LOCKDARG=
# TCP port rpc.lockd should listen on.
LOCKD_TCPPORT=32803
# UDP port rpc.lockd should listen on.
LOCKD_UDPPORT=32769
#
#
# Optional arguments passed to rpc.nfsd. See rpc.nfsd(8)
# Turn off v2 and v3 protocol support
#RPCNFSDARGS="-N 2 -N 3"
# Turn off v4 protocol support
#RPCNFSDARGS="-N 4"
# Number of nfs server processes to be started.
# The default is 8. 
#RPCNFSDCOUNT=8
# Stop the nfsd module from being pre-loaded
#NFSD_MODULE="noload"
# Set V4 grace period in seconds
#NFSD_V4_GRACE=90
#
#
#
# Optional arguments passed to rpc.mountd. See rpc.mountd(8)
#RPCMOUNTDOPTS=""
# Port rpc.mountd should listen on.
MOUNTD_PORT=892
#
#
# Optional arguments passed to rpc.statd. See rpc.statd(8)
#STATDARG=""
# Port rpc.statd should listen on.
STATD_PORT=662
# Outgoing port statd should used. The default is port
# is random
STATD_OUTGOING_PORT=2020
# Specify callout program 
#STATD_HA_CALLOUT="/usr/local/bin/foo"
#
#
# Optional arguments passed to rpc.idmapd. See rpc.idmapd(8)
#RPCIDMAPDARGS=""
#
# Set to turn on Secure NFS mounts. 
#SECURE_NFS="yes"
# Optional arguments passed to rpc.gssd. See rpc.gssd(8)
#RPCGSSDARGS=""
# Optional arguments passed to rpc.svcgssd. See rpc.svcgssd(8)
#RPCSVCGSSDARGS=""
#
# To enable RDMA support on the server by setting this to
# the port the server should listen on
#RDMA_PORT=20049
Now restart the NFS service
[root@server ~]# /etc/init.d/nfs restart
Shutting down NFS daemon:                                  [  OK  ]
Shutting down NFS mountd:                                  [  OK  ]
Shutting down NFS services:                                [  OK  ]
Starting NFS services:                                     [  OK  ]
Starting NFS mountd:                                       [  OK  ]
Stopping RPC idmapd:                                       [  OK  ]
Starting RPC idmapd:                                       [  OK  ]
Starting NFS daemon:                                       [  OK  ]
Add the lines shown in bold in  ‘/etc/sysconfig/iptables’ file.
[root@server ~]# vi /etc/sysconfig/iptables
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
-A INPUT -m state --state NEW -m udp -p udp --dport 2049 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 2049 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 111 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 111 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 32769 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 32803 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 892 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 892 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 875 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 875 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 662 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 662 -j ACCEPT
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
Now restart the iptables service
[root@server ~]# service iptables restart
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
iptables: Unloading modules:                               [  OK  ]
iptables: Applying firewall rules:                         [  OK  ]
Again mount the share from client
[root@vpn client]# mount -t nfs 192.168.1.200:/home/ostechnix/ /nfs/shared/
Finally the NFS share is mounted without any connection timed out error.
To verify whether the shared directory is mounted, enter the mount command in client system.
[root@vpn client]# mount
/dev/mapper/vg_vpn-lv_root on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
/dev/sda1 on /boot type ext4 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
nfsd on /proc/fs/nfsd type nfsd (rw)
192.168.1.200:/home/ostechnix/ on /nfs/shared type nfs (rw,vers=4,addr=192.168.1.200,clientaddr=192.168.1.29)

8. Testing NFS

Now create some files or folders in the ‘/nfs/shared’ directory which we mounted in the previous step.
[root@vpn shared]# mkdir test
[root@vpn shared]# touch file1 file2 file3
Now go to the server and change to the ‘/home/ostechnix’ directory.
[root@server ~]# cd /home/ostechnix/
[root@server ostechnix]# ls
file1  file2  file3  test
[root@server ostechnix]#
Now the files and directories are listed which are created from the client. Also you can share the files from server to client and vice versa.

9. Automount the Shares

If you want to mount the shares automatically instead mounting them manually at every reboot, add the following lines shown in bold in the ‘/etc/fstab’ file of client system.
[root@vpn client]# vi /etc/fstab 
#
# /etc/fstab
# Created by anaconda on Wed Feb 27 15:35:14 2013
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/vg_vpn-lv_root /                       ext4    defaults        1 1
UUID=59411b1a-d116-4e52-9382-51ff6e252cfb /boot                   ext4    defaults        1 2
/dev/mapper/vg_vpn-lv_swap swap                    swap    defaults        0 0
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
192.168.1.200:/home/ostechnix/nfs/sharednfsrw,sync,hard,intr0 0

10. Verify the Shares

Reboot your client system and verify whether the share is mounted automatically or not.
[root@vpn client]# mount
/dev/mapper/vg_vpn-lv_root on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
/dev/sda1 on /boot type ext4 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
192.168.1.200:/home/ostechnix on /nfs/shared type nfs (rw,sync,hard,intr,vers=4,addr=192.168.1.200,clientaddr=192.168.1.29)
nfsd on /proc/fs/nfsd type nfsd (rw)
Thats it. Have a Good day!!