Friday, September 9, 2016

NFS Interview questions and answers

Q:1 Why to use NFS ?
Ans: A Network File System (NFS) allows remote machine to mount file systems over a network and interact with those file systems as though they are mounted locally. This enables system administrators to consolidate resources onto centralized servers over the network.
 
  Q:2 What is the default port of NFS server ?
Ans: By default NFS uses 2049 TCP port.
 
  Q:3 What are different versions of NFS Server ?
Ans: Currently, there are three versions of NFS. NFS version 2 (NFSv2) is older and widely supported. NFS version 3 (NFSv3) supports safe asynchronous writes and is more robust at error handling than NFSv2; it also supports 64-bit file sizes and offsets, allowing clients to access more than 2Gb of file data.
 
NFS version 4 (NFSv4) works through firewalls and on the Internet, no longer requires an rpcbind service, supports ACLs, and utilizes stateful operations. Red Hat Enterprise Linux 6.X & Centos 6.X supports NFSv2,NFSv3, and NFSv4 clients. When mounting a file system via NFS, Red Hat Enterprise Linux uses NFSv4 by default, if the server supports it.

Q:4 What are configuration files of NFS server ?
Ans: '/etc/exports' is the main configuration file that controls which file systems are exported to remote hosts and specifies options.
'/etc/sysconfig/nfs' is the file through which we can fix ports for RQUOTAD_PORT, MOUNTD_PORT, LOCKD_TCPPORT, LOCKD_UDPPORT and STATD_PORT
Q:5 What are different options used in /etc/exports file ?
Ans: Below are list of options used in /etc/exports file :
  • ro: The directory is shared read only; the client machine will not be able to write to it. This is the default.
  • rw: The client machine will have read and write access to the directory.
  • root_squash: By default, any file request made by user root on the client machine is treated as if it is made by user nobody on the server. (Exactly which UID the request is mapped to depends on the UID of user "nobody" on the server, not the client.)
  • no_root_squash : if this option is used , then root on the client machine will have the same level of access to the files on the system as root on the server. This can have serious security implications, although it may be necessary if you want to perform any administrative work on the client machine that involves the exported directories. You should not specify this option without a good reason.
  • no_subtree_check : If only part of a volume is exported, a routine called subtree checking verifies that a file that is requested from the client is in the appropriate part of the volume. If the entire volume is exported, disabling this check will speed up transfers.
  • sync : Replies to the NFS request only after all data has been written to disk. This is much safer than async, and is the default in all nfs-utils versions after 1.0.0.
  • async : Replies to requests before the data is written to disk. This improves performance, but results in lost data if the server goes down.
  • no_wdelay : NFS has an optimization algorithm that delays disk writes if NFS deduces a likelihood of a related write request soon arriving. This saves disk writes and can speed performance
  • wdelay : Negation of no_wdelay , this is default
  • nohide : Normally, if a server exports two filesystems one of which is mounted on the other, then the client will have to mount both filesystems explicitly to get access to them. If it just mounts the parent, it will see an empty directory at the place where the other filesystem is mounted. That filesystem is "hidden". Setting the nohide option on a filesystem causes it not to be hidden, and an appropriately authorised client will be able to move from the parent to that filesystem without noticing the change.
  • hide : Negation of nohide This is the default
Q:6 How to list available nfs share on local machine & remote machine ?
Ans: 'showmount -e localhost' : Shows the available shares on your local machine
'showmount -e ': Lists the available shares at the remote server.
 
Q:7 What is pNFS ?
Ans: Parallel NFS (pNFS) as part of the NFS v4.1 standard is available as of Red Hat Enterprise Linux 6.4. The pNFS architecture improves the scalability of NFS, with possible improvements to performance. That is, when a server implements pNFS as well, a client is able to access data through multiple servers concurrently. It supports three storage protocols or layouts: files, objects, and blocks.
 
Q:8 What is the difference between Hard mount & Soft mount in nfs ?
Ans:  Difference between soft mount and hard mount is listed below :
  •  Soft Mount : Consider we have mounted a NFS share using 'soft mount' . When a program or application requests a file from the NFS filesystem, NFS client daemons will try to retrieve the data from the NFS server. But, if it doesn’t get any response from the NFS server (due to any crash or failure of NFS server), the NFS client will report an error to the process on the client machine requesting the file access. The advantage of this mechanism is “fast responsiveness” as it doesn’t wait for the NFS server to respond. But, the main disadvantage of this method is data corruption or loss of data. So, this is not a recommended option to use.
  • Hard Mount : Suppose we have mounted the NFS share using hard mount, it will repeatedly retry to contact the server. Once the server is back online the program will continue to execute undisturbed from the state where it was during server crash. We can use the mount option “intr” which allows NFS requests to be interrupted if the server goes down or cannot be reached. Hence the recommended settings are hard and intr options.
  Q:9 How to check iostat of nfs mount points ?
Ans: Using command 'nfsiostat' we can list iostat of nfs mount points. Use the below command :
# nfsiostat
: specifies the amount of time in seconds between each report. The first report contains statistics for the time since each file system was mounted. Each subsequent report contains statistics collected during the interval since the previ-ous report.
: If the parameter is specified, the value of determines the number of reports generated at seconds apart. if the interval parameter is specified without the parameter, the command generates reports continuously.
: If one or more names are specified, statistics for only these mount points will be displayed. Otherwise, all NFS mount points on the client are listed.
 
Q:10 How to check nfs server version ?
Ans: 'nfsstat -o all' command shows all information about active versions of NFS.
 
Q:11 What is portmap?
Ans: The portmapper keeps a list of what services are running on what ports. This list is used by a connecting machine to see what ports it wants to talk to access certain services.
 
Q:12 How to reexport all the directories of '/etc/exports' file ?
Ans: Using the command ' exportfs -r ' , we can reexport or refresh entries of '/etc/exports' file without restarting nfs service.

Q:13 How to retrieve a list of clients connected to the NFS server ?

To retrieve a list of clients connected to the NFS server, use the showmount command
from a shell prompt. To also show the directories the clients are connected to, use the
showmount -a command.


Q:14What is meaning of "no_root_squash" option ?

Treat remote root user as local root. Do not map requests from root to the anony-
mous user and group ID.


Q:15  Can we grant access by Username and password for nfs share?
No, access is granted only for IP address.

Q:16 What is the role of "all_squash" option?
Treat all client users as anonymous users. Map all user and group IDs to the anonymous user and group ID.

Q:17 - What is the role of "root_squash" option?
All requests from the user root are translated or mapped as if they came from the user anonymous (default).

Q: 18- Explain option "all_squash"?
The UID and GID of exported files are mapped to the user anonymous. It is good for public directories.

Q:19 - Explain "exportfs" command?
The exportfs command is used to maintain the current table of exported file systems for NFS.

Q:20 - Explain command "/usr/sbin/exportfs -f"?
It will flush everything out of the kernels export table. Any clients that are active will get new entries added by mountd when they make their next request.

Q:21What is the role of "all_squash" option?
ANS:Treat all client users as anonymous users. Map all user and group IDs to the anonymous user and group ID.

Q:22 - What is the role of "root_squash" option?
ANS:All requests from the user root are translated or mapped as if they came from the user anonymous (default).

Q:23 - Explain option "all_squash"?
ANS:The UID and GID of exported files are mapped to the user anonymous. It is good for public directories.

Q:24 - Explain "exportfs" command?
ANS:The exportfs command is used to maintain the current table of exported file systems for NFS.

Q:25 - Explain command "/usr/sbin/exportfs -f"?
ANS:It will flush everything out of the kernels export table. Any clients that are active will get new entries added by mountd when they make their next request.

Q:26 - Which option is used with exportfs command to display the current export list, also displays the list of export options?
ANS:exportfs -v

Q:27 - Which option is used with exportfs command to re-export all directories?
ANS:exportfs -r

Q:28 - How you will export directory (/data) to host 192.168.1.51, allowing asynchronous writes without adding the entry in /etc/exports file?
 ANS:# exportfs -o async 192.168.1.51:/data

Q:29 - Is rpc.mountd daemon supports TCP_WRAPPERS?
ANS:Yes, The rpc.mountd daemon is protected by the tcp_wrappers. You have to give the clients access to rpc.mountd if they should be allowed to use NFS Server.

Q:30 - Explain "nfsstat" command?
ANS:The nfsstat command displays the statistics about NFS client and NFS server activity.

Q:31 - What do you understand by "nfsstat -o all -234" command?
ANS:It will Show all information about all versions of NFS.

Q:32 - What do you understand by "nfsstat --nfs --server -3" command?
ANS:It will show statistics for NFS version 3 server.

Q:33 - Can NFS share mounted on Window XP and Justify your answer?
ANS:No, Window XP operating system doesn’t support nfs protocol.

Q:34 - 192.168.1.51:/data is exported by NFS Server and i want to add this NFS share to client /etc/fstab file. How you will add this entry in /etc/fstab file?
ANS:# device                      mount-point     fs-type     options      dump   fsckorder
192.168.1.51:/data            /mnt           nfs               defaults             0         0

Q: 35- Explain "Soft Mounting" option at NFS Client?

ANS:if a file request fails, the NFS client will report an error to the process on the client machine requesting the file access. if it cannot be satisfied (for example, the server is down), then it quits. This is called soft mounting.


Q:36 - Explain "Hard Mounting" option at NFS Client?
ANS:If a file request fails, the NFS client will report an error to the process on the client machine requesting the file access. if it cannot be satisfied, then it will not quit until the request is satisfied. This is called Hard mounting.

Q:37-How you will check "portmap" service is running or not?
ANS:rpcinfo -p

Linuix File Systems

FILE SYSTEM HIERARCHY

File System is a mechanism used in the O/S environment for storing the data in a systamatical order into a storage device.      

UNIX/LINUX follows hierarchy file system standard (HFS) . In this file system all other directories mounted under the directory called root ( / ) .

                 /       -->  Root (Top of the directory)


                /root  -->  Super User (or) Administrator home directory, it represented by " ~ "(tilde) symbol .                                           


Structure Of  Linux






                                  


                    "/"  this directory is called as root directory
                       
                      It is the top of filesystem structure





File System Hierarchy


In Linux, everything is a file or a directory


/


It is a top level directory and it is a parent directory for  all other directories. It is called a ROOT directory and it is denoted by forward slash " / "
-----------------------------------------------------------------------
/root


It is the home directory for root user .It provides working environment for root user
--------------------------------------------------------  
/home
All users(except root) ome directories will be here by default


/sbin - root user commands
/bin  - normal user commands
====================
/boot
The /boot/ Directory contains static files required to boot the system, for example, the Linux kernel. These files are essential for the system to boot properly.
Eg: vmlinuz - the Linux kernel.
    initrd.img – a temporary file system, used prior to loading the kernel.


/etc/ Directory
The /etc/ directory is reserved for configuration files that are local to the machine. It should contain no binaries; any binaries should be moved to /bin/ or /sbin/.


/srv/
The /srv/ directory contains site-specific data served by a Red Hat Enterprise Linux system. This directory gives users the location of data files for a particular service, such as FTP, WWW, or CVS. Data that only pertains to a specific user should go in the /home/ directory.


The /sys/ Directory
The /sys/ directory utilizes the new sysfs virtual file system specific to the 2.6 kernel. With the increased support for hot plug hardware devices in the 2.6 kernel, the /sys/ directory contains information similar to that held by /proc/, but displays a hierarchical view of device information specific to hot plug devices.


The /mnt/ Directory
The /mnt/ directory is reserved for temporarily mounted file systems, such as NFS file system mounts. For all removable storage media, use the /media/ directory. Automatically detected removable media will be mounted in the /media directory.


It is the default mount directory for any partition , It is empty by default.



The /opt/ Directory
The /opt/ directory is normally reserved for software and add-on packages that are not part of the default installation. A package that installs to /opt/ creates a directory bearing its name, for example /opt/packagename/. In most cases, such packages follow a predictable subdirectory structure; most store their binaries in /opt/packagename/bin/ and their man pages in /opt/packagename/man/.


It is optional directory for /usr , it contains all third party softwares.
-------------------------------------------------------------------------------
/dev/ Directory
The /dev/ directory contains device nodes that represent the following device types:


   devices attached to the system;
   virtual devices provided by the kernel.


It contains device files// HDD,CDROM,USB Media,
------------------------------------------------------------------------------------
/lib/ Directory
The /lib/ directory should only contain libraries needed to execute the binaries in /bin/ and /sbin/. These shared library images are used to boot the system or execute commands within the root file system. It is similar to dll files in windows.
--------------------------------------------------------------------------------------
/media/ Directory
The /media/ directory contains subdirectories used as mount points for all removable media such as USB storage media, DVDs, CD-ROMs, and Zip disks.
--------------------------------------------------------------------------------------
/proc/ Directory
The /proc/ directory contains special files that either extract information from the kernel or send information to it. Examples of such information include system memory, CPU information, and hardware configuration.
--------------------------------------------------------------------------------------
The /usr/ Directory
The /usr/ directory is for files that can be shared across multiple machines. The /usr/ directory is often on its own partition and is mounted read-only. At a minimum, /usr/ should contain the following subdirectories:


/usr/bin
   This directory is used for binaries.
/usr/etc
   This directory is used for system-wide configuration files.
/usr/games
   This directory stores games.
/usr/include
   This directory is used for C header files.
/usr/kerberos
   This directory is used for Kerberos-related binaries and files.
/usr/lib
   This directory is used for object files and libraries that are not designed to be directly utilized by shell scripts or users.
/usr/libexec
   This directory contains small helper programs called by other programs.
/usr/sbin
   This directory stores system administration binaries that do not belong to /sbin/.
/usr/share
   This directory stores files that are not architecture-specific.
/usr/src
   This directory stores source code.
/usr/tmp linked to /var/tmp
   This directory stores temporary files.


The /usr/ directory should also contain a /local/ subdirectory. As per the FHS, this subdirectory is used by the system administrator when installing software locally, and should be safe from being overwritten during system updates. The /usr/local directory has a structure similar to /usr/, and contains the following subdirectories:


   /usr/local/bin
   /usr/local/etc
   /usr/local/games
   /usr/local/include
   /usr/local/lib
   /usr/local/libexec
   /usr/local/sbin
   /usr/local/share
   /usr/local/src


Red Hat Enterprise Linux's usage of /usr/local/ differs slightly from the FHS. The FHS states that /usr/local/ should be used to store software that should remain safe from system software upgrades. Since the RPM Package Manager can perform software upgrades safely, it is not necessary to protect files by storing them in /usr/local/.
Instead, Red Hat Enterprise Linux uses /usr/local/ for software local to the machine. For instance, if the /usr/ directory is mounted as a read-only NFS share from a remote host, it is still possible to install a package or program under the /usr/local/ directory.




   Contains binaries, libraries, documentation, and source-code for second level programs.
   /usr/bin contains binary files for user programs. If you can’t find a user binary under /bin, look under /usr/bin. For example: at, awk, cc, less, scp
   /usr/sbin contains binary files for system administrators. If you can’t find a system binary under /sbin, look under /usr/sbin. For example: atd, cron, sshd, useradd, userdel
   /usr/lib contains libraries for /usr/bin and /usr/sbin
   /usr/local contains users programs that you install from source. For example, when you install apache from source, it goes under /usr/local/apache2
--------------------------------------------------------------------------------------------------



The /var/ Directory
Since the FHS requires Linux to mount /usr/ as read-only, any programs that write log files or need spool/ or lock/ directories should write them to the /var/ directory. The FHS states /var/ is for variable data, which includes spool directories and files, logging data, transient and temporary files.
Below are some of the directories found within the /var/ directory:


   /var/account/
   /var/arpwatch/
   /var/cache/
   /var/crash/
   /var/db/
   /var/empty/
   /var/ftp/
   /var/gdm/
   /var/kerberos/
   /var/lib/
   /var/local/
   /var/lock/
   /var/log/
   /var/mail linked to /var/spool/mail/
   /var/mailman/
   /var/named/
   /var/nis/
   /var/opt/
   /var/preserve/
   /var/run/
   /var/spool/
   /var/tmp/
   /var/tux/
   /var/www/
   /var/yp/


System log files, such as messages and lastlog, go in the /var/log/ directory. The /var/lib/rpm/ directory contains RPM system databases. Lock files go in the /var/lock/ directory, usually in directories for the program using the file. The /var/spool/ directory has subdirectories that store data files for some programs. These subdirectories may include:


   /var/spool/at/
   /var/spool/cron/
   /var/spool/cups/
   /var/spool/exim/
   /var/spool/lpd/
   /var/spool/mail/
   /var/spool/mailman/
   /var/spool/mqueue/
   /var/spool/news/
   /var/spool/postfix/
   /var/spool/repackage/
   /var/spool/rwho/
   /var/spool/samba/
   /var/spool/squid/
   /var/spool/squirrelmail/
   /var/spool/up2date/
   /var/spool/uucp/
   /var/spool/uucppublic/
   /var/spool/vbox/

Linux, CCNA and MCSE Questions: User Managment

Linux, CCNA and MCSE Questions: User Managment