Friday, 2 May 2014

Frequently Asked Linux Interview Questions



PART-1

  1. How did you install Linux server on your machine.
  2. How do you configure Linux Kick start installation?
  3. What services do you require to share something?
  4. NFS configuration, options……what do you know about root squash?
  5. What protocols are used in NFS?
  6. What are services are required for NFS share to mount on a client.
  7. Tell me something about LVM. How would you know that system in LVM enabled.
  8. How many Raids are you familiar with? Tell me in brief about RAID 1 & 5.
  9. how do you find what RAID on the system in configured.
  10. Tell me about some security aspects about NFS client share.
  11. Have you heard about semaphore?
  12. How would you know about NFS registered services on a machine?
  13. What is port?
  14. What are the differences between TCP & UDP?
  15. In system where is 100% memory utilized, how would you check whether the system has performance issue or not? And what does it indicates to you when the system is showing 100% utilization.
  16. What causes normally the load average to go up?
  17. What are differences between module and kernel?
  18. What is inter-process communication?

PART-2


  1. What is your day to day activity in you current organization.
  2. How can you recognize LUN in your Linux machine?
  3. What is GRUB?
  4. What is difference between regular and General file system
  5. If generals are corrupted in your system, how would you recover them
  6. What are differences among RPM, UP2DATE and YUM.
  7. How will you set kernel parameter? Permanent/Temporary.
  8. how do you check  open files in your system and which kernel parameter is used by kernel parameter.
  9. How do you steup Printer in your system.
  10. How would you check configured Printers in your system?
  11. What is Sticky Bit and where is it by default set in your system
  12. what does TOP command do and what parameter it contains for memory.
  13. Have you worked on Backup Tool like VERITAS Netbackup.
  14. How would you configure backup client on your system.
  15. How would you judge system performance?
  16. How would you check system load average?
  17. How to know CPU is bottlenecked and CPU is HIGH and what remedies would you like to use to overcome this issue.
  18. What is difference between real time and user process?
  19. Tell me about iostat command and its parameter.
  20. What will you give solution about HIGH I/O wait is your machine.
  21. How can you design Hardware configuration (Dev/Test/Prod).
  22. Why we use default gateway in your system.
  23. Tell me some applications which use TCP/UDP protocols.
  24. How will you troubleshoot if use is not able to login in Linux machine
  25. How can you lock and unlock user in Linux.
  26. What cluster services are used in Linux cluster?
  27. How can you check commands run by last user.
  28. How can you partition in Linux system at run time.
  29. What is use of partprobe command in Linux?
  30. How will you setup ssh pass-through.
  31. What is usage of passphrase?
  32. What is difference between grep and find.
  33. How will you find out a particular string in a file by using grep and find.
  34. What is usage of redirection operator (> & >>).
  35. Shell Scripting----- $$, $! ,$@, $0,$?
  36. How can you pass argument to script.


PART-3

  1. How can you configure Linux virtual machine?
  2. How can you check xen enabled kernel and OS?
  3. What would be effect if grub not in OS.
  4. How to upgrade kernel in Linux machine.
  5. What is RPM and what are usage if –U and –F options with rpm command.
  6. what are zombie processes and how can you detect them into your system
  7. How can you kill zombie processes?
  8. What is the usage of nslookup command?
  9.  where can you set priority for resolving naming resolution in Linux machine.(nsswitch.conf)
  10. How can you find out whether system is NIS enabled or not.
  11. What is difference between CRON and AT.
  12. What is swap and when we use it.
  13. Command to check swap in your system.
  14. What is daemon?
  15.  What are the daemons used for logs in Linux.
  16.  What is HARD and SOFT link and why we use them?
  17. How to check inode in your sysem.
  18. Why we use lsof.
  19. What is superblock and inode
  20. what is usage of modprob.conf.
  21. How can load and unload modules in your system.
  22. How can you share data through NFS.
  23. What is PXE and how will you setup it.
  24. What is subnet mask?
  25. How can you boot Linux machine in single use mode.
  26. How can you check the type of file system without mounting them?



PART-4

  1. What is heartbeat
  2. How can you reset group password.
  3. How can you encrypt the group password.
  4. How can you create script to run specific command on 1000 boxes.
  5. Do you know about Veritas cluster?
  6. How can you rename volume group.
  7. What is difference between apache1.3 and apache2.0
  8. How can you compile the kernel?
  9. How can you reload NFS configuration file without restating services.
  10. How can you temporary share NFS without making entry into /etc/exports?
  11. What is multipath and how can you configure it for different Storage.
  12. What is bonding and what is use of it.
  13. How can you check the file system?
  14. How will you extend and reduce LVM.
  15.  What is NFS Stale?
  16. How will you troubleshoot if kernel is panic after up gradation?
  17. What is ARP and what is its use.
  18. What are major and minor numbers?
  19. Tell me about different type of files in Linux and give some example of block and character devices.
100.    How can you change nice value of process?



    

Wednesday, 30 April 2014

NFS Stale File Handle Error and Solution


Sometime NFS can result in to weird problems. For example NFS mounted directories sometimes contain stale file handles. If you run command such as ls or vi you will see an error:
$ ls
.: Stale File Handle

NFS Stale:
A file handle becomes stale whenever the file or directory referenced by the handle is removed by another host, while your client still holds an active reference to the object. A typical example occurs when the current directory of a process, running on your client, is removed on the server (either by a process running on the server or on another client).

How do I fix this problem?

a) The best solution is to remount directory from the NFS client using mount command.
umount -f /mnt/local
# mount -t nfs nfsserver:/path/to/share /mnt/local

Difference between Samba and CIFS


SAMBA was originally SMB Server - but the name had to be changed due to SMB Server being an actual product. SMB was the predecessor to CIFS. SMB "server message block" and CIFS "common internet file system" are protocols. Samba implements CIFS network protocol. This is what allows Samba to communicate with (newer) MS Windows systems. Typically you will see it referred to SMB/CIFS. However, CIFS is the extension of the SMB protocol so if someone is sharing out SMB via Samba to a legacy system still using NetBIOS it will typically connect to the Samba server via port 137, 138, 139 and CIFS is strictly port 445

Tuesday, 29 April 2014

How to extract the RPM package


We can extract the content of RPM package first into cpio archive using utility rpm2cpio on standard output. if a – argument is given using cpio command, an rpm stream is read from standard in. The syntax is as follows.

SYNTAX:

$ rpm2cpio <RPM package> | cpio –idvm

Example:  

[root@syncsrv01 jitendrakumar]# ls -ltr
total 292
-rw-------. 1 jitendrakumar domain admins   1675 Aug 23  2013 ssh_key
-rwxr-xr-x. 1 root          root             879 Nov 26 15:46 root_expir_alert
-rw-r--r--. 1 root          root          290624 Apr 29 15:48 ntfs-3g-2011.4.12- 5.el6.i686.rpm   
                                                                      
[root@syncsrv01 jitendrakumar]# rpm2cpio ntfs-3g-2011.4.12-5.el6.i686.rpm | cpio   -idvm                                                                           
./bin/lowntfs-3g
./bin/ntfs-3g
./bin/ntfs-3g.probe
./bin/ntfs-3g.secaudit
./bin/ntfs-3g.usermap
./bin/ntfsmount
./lib/libntfs-3g.so.81
./lib/libntfs-3g.so.81.0.0
./sbin/mount.lowntfs-3g
./sbin/mount.ntfs
./sbin/mount.ntfs-3g
./sbin/mount.ntfs-fuse
./usr/bin/ntfs-3g
./usr/bin/ntfsmount
./usr/share/doc/ntfs-3g-2011.4.12
./usr/share/doc/ntfs-3g-2011.4.12/AUTHORS
./usr/share/doc/ntfs-3g-2011.4.12/COPYING
./usr/share/doc/ntfs-3g-2011.4.12/CREDITS
./usr/share/doc/ntfs-3g-2011.4.12/ChangeLog
./usr/share/doc/ntfs-3g-2011.4.12/NEWS
./usr/share/doc/ntfs-3g-2011.4.12/README
./usr/share/hal/fdi/policy/10osvendor/20-ntfs-config-write-policy.fdi
./usr/share/man/man8/mount.lowntfs-3g.8.gz
./usr/share/man/man8/mount.ntfs-3g.8.gz
./usr/share/man/man8/ntfs-3g.8.gz
./usr/share/man/man8/ntfs-3g.probe.8.gz
./usr/share/man/man8/ntfs-3g.secaudit.8.gz
./usr/share/man/man8/ntfs-3g.usermap.8.gz
1304 blocks

[root@syncsrv01 jitendrakumar]# ll
total 308
drwxr-xr-x. 2 root          root            4096 Apr 29 15:49 bin
drwxr-xr-x. 2 root          root            4096 Apr 29 15:49 lib
-rw-r--r--. 1 root          root          290624 Apr 29 15:48 ntfs-3g-2011.4.12-5.el6.i686.rpm
-rwxr-xr-x. 1 root          root             879 Nov 26 15:46 root_expir_alert
drwxr-xr-x. 2 root          root            4096 Apr 29 15:49 sbin
-rw-------. 1 jitendrakumar domain admins   1675 Aug 23  2013 ssh_key
drwxr-xr-x. 4 root          root            4096 Apr 29 15:49 usr


The extracted rpm data are

bin lib  sbin user

Note:
In this example, output of rpm2cpio command piped to cpio command with following options:
§  i: Restore archive
§  d: Create leading directories where needed
§  m: Retain previous file modification times when creating files
§  v: Verbose i.e. display progress


Security Modes/Type in Samba Setup in Linux

If you have read any of the Samba content  you probably will have noticed that within the smb.conf configuration file a line that begins with security =. This is a very important part of Samba setup and generally the section that gives users the most problems. Although the security mode would seem fairly straight-forwardit is certainly worth explaining.
In this article I will discuss what the security mode feature does and what the different modes are. By the end of this article there should be no confusion as to which mode your Samba setup should use.
What are security modes?
I like to think of security modes as a means to inform the server just how a client will authenticate. You know about authentication from many sources. You can authenticate at a local level, as part of a domain, using Active Directory, and more. How you authenticate is generally dictated by your IT department (or by yourself if you are personal or home user). Because of the different types of authentication, Samba needs a way to know how this authentication is going to happen.
Now, from a Windows perspective (and the reason why Samba exists) there are only two types of security level: Share level and User level. But because Windows has multiple ways of authentication Samba needs to break the user level down further. So, as far as Samba is concerned, these levels are called modes and there are five modes: user, share, domain, ADS, and server. Let's take a look at each of these.
user
The security = user mode is really the easiest to understand. From the Samba server perspective, the only things that matter (with regard to user mode) is username/password and the name of the client machine. This mode works very simply: If the Samba server accepts the username/password of the client then that client is able to mount shares on the server.
share
The security = share mode the client will authenticate itself against a share on the Samba server. Unlike user, when security = shareauthenticates against a share, that means that client only has access to that share. When using this mode the client sends a password along with each share request. If the password authenticates, the client has access to the share. If not, no access is granted. The authentication process is like this:
1.    The client sends a session setup request that includes a valid username.
2.    Samba records this username.
3.    Client issues a tree connection request and the share the client wishes to connect with.
4.    The users password is the then checked against the username. If password matches, the client is given access.
domain
The security = domain provides a means for storing all username/passwords in a centralized, shared account. This account is then shared between domain controllers. So when Samba uses this mode of security it has a domain security trust account and forces all authentication requests to be passed through the domain controller. When using this mode the configuration requires a second parameter. So the configuration will look like:
security = domain
workgroup = DOMAIN_NAME
You also have to join the domain using the net rpc join -U ADMINISTRATOR%PASSWORD command. Where ADMINISTRATOR is the name of the administrator account and PASSWORD is the password for that account.
ads
As you might expect, this is the Active Directory mode. Samba added ADS functionality at release 3. Using ADS mode is only possible if the Active Directory server is run in native mode. When running in ADS mode Samba will need NT-compatible authentication data - in other words Kerberos. So your Samba server will need to have a working Kerberos system installed. When using ADS mode, your Samba configuration adds another line like so:
realm = YOUR.KERBEROS.REALM
security = ADS
server
The last mode is security = server. This mode is generally not used any more because it basically sends username/password authentication to another machine. If this other machine is down, there will be no authentication. This mode presents numerous problems, which is why it is often not used. One of the more serious problems is that once a connection to the password server is made, that connection can be left open for extended periods of time - thus a severe security issue.


Append files to an Archive TAR file


The simplest way to append the files into existing archive is the “--append” or “-r” operation using tar command.

Syntax:
tar –rvf <Tar Archived File>  <filename>
OR
tar –append –file=< Tar Archived File>  <filename>

Example1:
Here we are adding filename “five” into archive file “test.tar”.

[root@mail01 jitendrakumar]# tar -rvf test.tar five
five
 [root@mail01 jitendrakumar]# tar -tvf test.tar
-rw-r--r-- root/root         0 2014-04-29 10:58 two
-rw-r--r-- root/root         0 2014-04-29 10:58 three
-rw-r--r-- root/root         0 2014-04-29 10:58 foure
-rw-r--r-- root/root         0 2014-04-29 10:58 one
-rw-r--r-- root/root         0 2014-04-29 10:59 five

Example2:
 Here we are adding filename “six” into archive file “test.tar”.

[root@mail01 jitendrakumar]# tar --append --file=test.tar six
[root@mail01 jitendrakumar]# tar -tvf test.tar
-rw-r--r-- root/root         0 2014-04-29 10:58 two
-rw-r--r-- root/root         0 2014-04-29 10:58 three
-rw-r--r-- root/root         0 2014-04-29 10:58 foure
-rw-r--r-- root/root         0 2014-04-29 10:58 one
-rw-r--r-- root/root         0 2014-04-29 10:59 five
-rw-r--r-- root/root         0 2014-04-29 11:06 six



Monday, 28 April 2014

List the content of tar, tar.gz and tar.bz2 compressed files

tar is an archiving program designed to store and extract files from an archive file known as a tarfile. You can create a tar file or compressed tar file tar. However sometime you need to list the contents of a tar or tar.gz file on screen before extracting the all files. Following commands will help you to view the content of tarfile.



  • To list the content of tar file.

            # tar –tvf  file.tar


  • To list the content of a tar.gz file.

            # tar –ztvf  file.tar.gz



  •  To List the content of a tar.bz2 file.
# tar –jtvf file.tar.bz2

Where:

§  t: List the contents of an archive
§  v: Verbosely list files processed (display detailed information)
§  z: Filter the archive through gzip so that we can open compressed (decompress) .gz tar file
§  j: Filter archive through bzip2, use to decompress .bz2 files.
§  f filename: Use archive file called filename