LINUX Interview Questions : PART 2

Linux Interview Questions : PART 1 : Click Here



in PART 2 - we are going to see the below Questions and answers:


7. What is hard link and soft link? How to create symbolic link?

8. What is INODE ? How to reduce inode utilization?

9. What is HARD and SOFT mount in NFS ?

10. Explain NFS mount options ?

11. CPU states in TOP or Explain o/p of TOP command

12. How to check architecture of Linux server OS


 

Question 7:  What is hard link and soft link? How to create symbolic link?

    

A.  Hard links cannot link directories.
    Cannot cross file system boundaries.

B.  Soft or symbolic links are just like hard links. It allows to associate multiple filenames with a single file. However, symbolic links allows:

    To create links between directories.
    Can cross file system boundaries.



How do I create symbolic link?

You can create symbolic link with ln command:

#ln -s /path/to/file1.txt /path/to/file2.txt

(inode number will be same for hard linked file )

#ln /mades/file1 /mades/file2 - ( create hard link)


Question 8: What is INODE ? How to reduce inode utilization?


An inode is a data structure on a traditional Unix-style file system such as UFS or ext3.
An inode stores basic information about a regular file, directory, or other file system object.

=> File type (executable, block special etc)
=> Permissions (read, write etc)
=> Owner
=> Group
=> File Size
=> File access, change and modification time

(remember UNIX or Linux never stores file creation time, this is favorite question asked in UNIX/Linux sys admin job interview)


How to reduce inode usage in File system?


For examble /opt filesystem's inode usage is high means we have to do below steps

# bdf -i /opt : check the FS usage

Create a test directory on your filesystem;

# mkdir /opt/test

Create a script that will create 10000 null files.

# cd /opt/test
# i=1
# while [ $i -lt 10000 ]
> do
> touch $i
> i=`expr $i + 1`
> done

Else you will be watching the terminal for years to get you the prompt or else CTRL + C will do :-D

once files are created do

#bdf -i /opt


Question 9 : What is HARD and SOFT mount in NFS ?



In HARD mount ...

If the NFS file system is hard mounted, the NFS daemons will try repeatedly to contact the server. The NFS daemon retries will not time out, will affect system performance, and you cannot interrupt them

If you just mount a file system without specifying hard or soft, the default is a hard mount. Hard mounts are preferable because of the stateless nature of NFS.

If a client sends an I/O request to the server (such as an ls -la), and the server gets rebooted, in client machine the process will keep on running.
This preserves data transfers in the event of a server failure

IN SOFT Mount :

A soft mount allows the client to stop trying an operation after a period of time. If the NFS server goes down at the time of data transfer , it will alert and the process will do down.Thsi may cause the data corruption.
A soft link will return with an error and fail.

you should only use soft mounts in the cases where client responsiveness is more important than data integrity.

In another word ..soft mount will allow automatic unmount if the filesystem is idle for a specified time period

Question 10 : Explain NFS mount options ?


Syntax to mount NFS FS:

#mount -t vfstype [-o options] NFS Servername:/exporteddirectory /mount point

or

#mount -t nfs -o options host:/remote/export /local/directory



Mount options explained below :

1. -0 initr

This option is used in non reliable network, or network having more network congestion. NFS request will be interrupted when server is not reachable.

2. -o hard

If hard option is specified during nfs mount, user cannot terminate the process waiting for NFS communication to resume. For ex ..if u ran ls -a command on ur NFS mounted directory but that time ur NFS server went down means .
The process wont get killed or stopped ..it will wait until the NFS server and mount poit become available.

3. -o soft

If soft option is specified during nfs mount, user will get error alert when NFS server is not reachable. This is just inverse of hard mount option. It wont wait for reply if the NFS server went down , it will alert us and the process will go down.

4. -o Nfsvers=value

If this option is specified during nfs mount NFS client uses particular NFS protocol version to communicate.

For example - TCP

# mount -t nfs -o tcp 192.168.1.4:/mnt/array1/RHEL5 /data/
# mount | grep -i tcp
 192.168.1.4:/mnt/array1/RHEL5 on /data type nfs (rw,tcp,addr=192.168.1.4)

The Difference between HARD and SOFT mount option explained in another POST. 




Question 11:  Explain TOP command output / Various states of CPU


# us -> User CPU time: The time the CPU has spent running users’ processes that are not niced.
# sy -> System CPU time: The time the CPU has spent running the kernel and its processes.
# ni -> Nice CPU time: The time the CPU has spent running users’ process that have been niced.
# wa -> iowait: Amount of time the CPU has been waiting for I/O to complete.
# hi -> Hardware IRQ: The amount of time the CPU has been servicing hardware interrupts.
# si -> Software Interrupts.: The amount of time the CPU has been servicing software interrupts




Question 12: How to check architecture of Linux OS


We can use below commands to check the architecture of server OS,


1. #getconf LONG_BIT

2.#uname -a

3.#grep flags /proc/cpuinfo

4.#arch

5.#file /bin or file bc







Post a Comment

2 Comments

  1. Salaam,

    A spot on observation on what probably is “the” underlying details of the LINUX Interview Questions. Too many people don’t even think about wherever there will be actual demand and more importantly what happens if this demand comes later (or maybe a lot later) than they expect

    I'm doing some research on people's experiences learning linux, and I would really like to hear from new users and people that are already familiar with Linux.

    Files under /proc directory named as Virtual files. Because /proc contains virtual files that’s why it is called virtual file system. These virtual files have unique qualities. Most of them are listed as zero bytes in size. Virtual files such as /proc/interrupts, /proc/meminfo, /proc/mounts, and /proc/partitions provide an up-to-the-moment glimpse of the system’s hardware.



    Very useful article, if I run into challenges along the way, I will share them here.

    Grazie,
    Kevin

    ReplyDelete