InfoHeap
Tech
Navigation
  • Home
  • Tutorials
    • CSS tutorials & examples
    • CSS properties
    • Javascript cookbook
    • Linux/Unix Command Line
    • Mac
    • PHP
      • PHP functions online
      • PHP regex
    • WordPress
  • Online Tools
    • Text utilities
    • Online Lint Tools
search

Ubuntu tutorials

  • How to add a user on Linux with sudo access
  • How to check if a user has password on Linux
  • How to install ViewVC for svn repository on Ubuntu Linux
  • How to setup ssl (https) for your site on Ubuntu Linux
  • Install rabbitmq on Ubuntu Linux
  • LXC (Linux Containers) - quick start tutorial on Ubuntu
  • Linux - command to check swap size
  • Linux - how to add a user using useradd
  • Linux - how to create a large file like 1GB
  • Linux - how to create swap partition
  • Linux - how to remove user from a group
  • Linux - number of cpus (lscpu)
  • Linux du - find disk usage of directories or files
  • NFS client and server handy commands
  • Setup svn repository on AWS Ubuntu with apache auth
  • Ubuntu - check if a service is upstart based
  • Ubuntu - dpkg and apt-get beginner tutorial
  • Ubuntu - find file to package
  • Ubuntu - find where will a package be installed from
  • Ubuntu - how to auto start services on boot using update-rc.d (sysv init)
  • Ubuntu - how to find boot autostart status of a service
  • Ubuntu - reload iptables rules during boot
  • Use x2go to access remote Ubuntu Linux
 
  • Home
  • > Tutorials
  • > Linux

NFS client and server handy commands

By admin on Aug 4, 2015

In case you are using NFS server, here are some handy commands you can use while working in production. These were tested in Ubuntu Linux.

Install nfs server

To install nfs server

$ sudo apt-get install nfs-common 
$ sudo apt-get install nfs-kernel-server 

Add the following line to /etc/hosts.allow

rpcbind mountd nfsd statd lockd rquotad : 127.0.0.1

export a directory

Create the directory to be exported.

$ sudo mkdir -p /myexport/dir1 

Add the following line to /etc/exports

/myexport/dir1 *(rw,sync,no_subtree_check,no_root_squash)

Note that this will allow any client to mount the exported directory on server if port 2049 is accessible from client to server. You may want to set appropriate client IPs here.

Now run the following to export the directory:

$ exportfs -ar

show what exports are available on a server

Use showmount to show what exports are available on localhost

showmount -e localhost

show what exports are available on a server from client

Use showmount on client machine to show what exports are available from nfs server

showmount -e nfsserver1.com
Export list for nfsserver1.com:
/myexport/dir1 *

Mount directory from client

Mount directory from client

$ mkdir -p /mnt1/nfsserver1.com/myexport/dir1
$ mount -t nfs nfsserver1.com:/myexport/dir1 /mnt1/nfsserver1.com/myexport/dir1

Displaying clients connected to server

Use netstat to list all connections and grep for NFS port.

MYIP=`ifconfig eth0 | grep "inet addr:" |awk -F":" '{print $2}' | awk '{print $1}'`
$ netstat -an | grep $MYIP:2049
tcp        0      0 172.30.0.30:2049        10.197.76.130:899       ESTABLISHED

Note: In case you want to automount the file during startup, add the following line in /etc/fstab

nfsserver1.com:/myexport/dir1 /mnt1/nfsserver1.com/myexport/dir1 nfs rw

After that mount and unmount can be done directly using

mount /mnt1/nfsserver1.com/myexport/dir1
or
umount /mnt1/nfsserver1.com/myexport/dir1

Suggested posts:

  1. Linux screen – quick start guide
  2. Alexa rank – how reliable is it?
  3. Setup xdebug for remote wordpress debugging
  4. How to migrate wordpress from root to sub directory
  5. Linux rsync tutorial
  6. Docker how to add a user to group docker on Linux
  7. Linux how to modify a user using usermod
  8. Linux – how to enable password login on ssh server
Share this article: share on facebook share on linkedin tweet this submit to reddit
Posted in Tutorials | Tagged Linux, Tutorials, Ubuntu Linux
  • Browse content
  • Article Topics
  • Article archives
  • Contact Us
Popular Topics: Android Development | AngularJS | Apache | AWS and EC2 | Bash shell scripting | Chrome developer tools | Company results | CSS | CSS cookbook | CSS properties | CSS Pseudo Classes | CSS selectors | CSS3 | CSS3 flexbox | Devops | Git | HTML | HTML5 | Java | Javascript | Javascript cookbook | Javascript DOM | jQuery | Kubernetes | Linux | Linux/Unix Command Line | Mac | Mac Command Line | Mysql | Networking | Node.js | Online Tools | PHP | PHP cookbook | PHP Regex | Python | Python array | Python cookbook | SEO | Site Performance | SSH | Ubuntu Linux | Web Development | Webmaster | Wordpress | Wordpress customization | Wordpress How To | Wordpress Mysql Queries | InfoHeap Money

Copyright © 2025 InfoHeap.

Powered by WordPress