ABHIONLINUX
Site useful for linux administration and web hosting

Showing posts with label Linux Interview Questions. Show all posts
Showing posts with label Linux Interview Questions. Show all posts

2009/11/01

Linux Interview Questions

How to change the modification time of a file use the following command:
touch -m

What is the default link count for files and directories in Linux?
The default link count:
files - 1
directory - 2

How to find only the number of lines in a files?
$ cat > f1

$ wc -l f1
4 f1

What is the difference between echo "$SHELL" and echo '$SHELL'?

$ echo "$SHELL"
/bin/bash


Code:
$ echo '$SHELL'
$SHELL

To check/list the attribute set for a file use the " lsattr " command.
# chattr +i my-file
# lsattr my-file
----i-------- my-file

How to set an append only attribute to a file in linux?
#chattr +a

How to lock the password for a user in linux?
# passwd -l
Password changed.


How to check the kernel version in linux?
$ uname -r
2.6.27-7-generic


How to check the used and free memory in linux?
$ free -m
total used free shared buffers cached
Mem: 1769 757 1011 0 20 302
-/+ buffers/cache: 434 1334
Swap: 7632 0 7632

How to set an immutable attribute to a file in linux?
#chattr +i

How to compare 2 files in linux?
Code:
#cmp

The -l option gives the detailed list of byte number.
Code:
#cmp -l


How to sort a file?
The command "sort" is used for alphabetically or numerically sort a file.

For eg: see the content of the file test
$ cat test
z
a
w
l
c

Inorder to sort the file we can use he sort command

$ sort test
a
c
l
w
z

One more ex: for a file containing numbers:

$ cat num
9
3
6
4

$ sort num
3
4
6
9
_________________



How to read the contents of a zip file without unzipping it?

Code:
zcat < file.gz >


How to suspend a running job and place it in the background?

Key combination " ctrl + z " will suspend a job and put it in the background.

Code:
ctrl+z


How to determine which shell you are using?

The name and path to the shell you are using is saved to the SHELL environment variable. You can then use the echo command to print out the value of any variable by preceding the variable's name with $. Therefore, typing echo $SHELL will display the name of your shell.

Code:
echo $SHELL


What are the process states in Linux?

As a process executes it changes state according to its circumstances.
Linux processes have the following states:

Running : The process is either running or it is ready to run .
Waiting : The process is waiting for an event or for a resource.
Stopped : The process has been stopped, usually by receiving a signal.
Zombie : The process is dead but have not been removed from the process table.



Which command is used to check and repair the file system?

fsck is used to check the file system and repair damaged files.

Code:
# /etc/fsck /dev/file-system



What is LILO?

LILO - Linux Loader

Definition:
The first- and second-stage boot loaders combined are called Linux Loader (LILO). It loads the kernel into the memory and helps the system to boot.


What is a PID?

PID - Process Indentification number

Definition:
It is a number used by Unix/Linux kernels to identify a process.

Use ps command to see PID.


What is a zombie process?

Zombies are dead processes. You cannot kill the Zombie process as they are already dead. A process state becomes zombie when the child process dies before the parent process. The only way to remove all the zombie process is by killing its parent process.


How to list/display the last 5 lines of a file " myfile.txt "?

Lets create a file " myfile.txt "

Example:
Code:
:~/test$ cat > myfile.txt
1
2
3
4
5
6
7
8
9
Ctrl+d

To list the last 5 lines, use the following command.
tail -5 myfile.txt

The tail utility displays the end of a file. The -5 option tells the tail command to display the last 5 lines.

Example:
Code:
:~/test$ tail -5 myfile.txt
5
6
7
8
9



How to delete a file which starts with " - "? Eg: -foo

Let try creating a new file " -foo ".

Example:
Code:
:~/test$ echo "Testing" > -foo
:~/test$ ls -l
-rw-r--r-- 1 telson telson 8 2009-05-21 22:28 -foo


In the above example we create a new file " -foo ".
Now lets try deleting it.

Code:
:~/test$ rm -foo
rm: invalid option -- 'o'
Try `rm --help' for more information.


It seems we are unable to remove the file " -foo ", with the above given command.

How to remove the file " -foo "?

There is 2 ways to remove this file.

rm ./-foo
rm -- -foo

You may use any of the above commands.

Example:
Code:
:~/test$ rm -- -foo
:~/test$ ls -l
total 0


What is the difference between Hard Link and Soft Link in Linux?

Hard Link is a mirror copy of the original file. Hard links share the same inode.
Any changes made to the original or Hard linked file will reflect the other.
Even if you delete any one of the files, nothing will happen to the other.
Hard links can't cross file systems.

Soft Link is a symbolic link to the original file. Soft Links will have a different Inode value.
A soft link points to the original file. If you delete the original file, the soft link fails. If you delete the soft link, nothing will happen.
Soft links can cross file systems.



What is the difference between Telnet and SSH?

Both Telnet and SSH is used for remote Log-In and to trasnfer data.

Telnet -> Telecommunication network
It is not secure and anyone can use it. It uses ASCII format.
Information sent and received can be easily read by anyone (Hackers) in that network.

SSH -> Secure Shell
It is highly secure.
Information passed accross the network is encrypted.
Hackers will not be able to read your data.

So its highly recommended to use SSH to transafer data's securly.



What is Raid? What are the different Raid types and different Raid Levels?

RAID stands for Redundant Array of Independent (or Inexpensive) Disks. It is a set of Technology standards to improve Performence and Fault tolerance.
There are two types of raid :
Software Raid
Hardware Raid

Hardware Raid is most commenly used.

Raid Levels:
Raid 0 - stripping
Raid 1 - Mirroring
Raid 2 - Stripping and Mirroring
Raid 3 - Officially Not Defined
Raid 4 - Striping with Differential Parity
Raid 5 - Striping with Distributional Parity
Raid 10 - A mix of RAID 1 and RAID 0

2009/09/05

Interview Question Linux (samples)

Part 1:

1. Two Diffrent ways to configure Apache and how ?
2. Name virtual host or IP virtual host is good ? Why?
3. What is SMARTHOST in sendmail ?
4. How can we disable a users login ?
5. Can we change the primary group of a user after creating a user?
6. How you secure a linux box?
7. Situavation in a big company - They have 2mbps leased line and 1mbps line, you have to give the 2mbps line to developers and 1 mpbs line to sales peoples with any controllers? How can you handle this situvation ?
8. Port numbers for telnet and pop3?
9. Diffrence between Hardlink and Softlink?
10.File systems in Linux?
11.What will you do when a file system corrupt. How you handle it?
--------------------------------------------------------------------------

Part 2:
1. How to take apache core dump?
2. Difference between IMAP and POP3?
3. Ext2 and Ext3 ?
4. How to point abc.com to a serverlet page ?
5. How to handle segmentation faults in apache?
6. Tcpdump ?
7. Difference between TCP and UDP ?
8. SSL ? what is its significance?
9. Which service is using UDP protocol ?
10.Which is using TCP protocol ?
11. .htaccess importance ?
12.Which one you opt - changes in apache config or change in .htaccess ?
13. Difference between RAID1 and RAID 5?
14. What is lost+found in linux ?
--------------------------------------------------------------------

Part 3:
1. Why do we need Apache, Does the Tomcat can handle the same ?
2. How can we integrate Apache with Tomcat ?
3. Versions that you are using for Apache,Tomcat,Mysql ?
4. Working of Nagios ?
5. How to add a new server to Nagios for monitorng ?
6. How to create a repository in SVN ?
7. Why we remove the work folder in Tomcat while deploying new war files ?
8. Mysql replication, advantages, which all files need to be edited for replication ?
9. What is a contest ?
10.Difference between Mysql and Sql ?
11.Why and what we do for OUT OF MEMORY error ?
12.Configuration files for Tomcat ?
13.How can we increase the memory in Tomcat ?
14.Is there any diffrence between Tomcat and JBoss ?
15.How can we do Virtual hosting in Tomcat ?
16.Memory Heap ?
--------------------------------------------------------------------------------

Questions in Operating systems:

28. Describe four general strategies for dealing with deadlocks.

29. For single unit resources, we can model resource allocation and requests as a directed graph connecting processes and resources. Given such a graph, what is involved in deadlock detection.

30. Is the following system of four processes with 2 resources deadlocked?

Current allocation matrix

P1 1 3
P2 4 1
P3 1 2
P4 2 0

Current request matrix
P1 1 2
P2 4 3
P3 1 7
P4 5 1

Availability Vector
1 4

If the availability vector is as below, is the system above still deadlocked?
2 3

Is the system deadlocked if the availability is
2 4

31. Assuming the operating system detects the system is deadlocked, what can the operating system do to recover from deadlock?

32. What must the banker's algorithm know a priori in order to prevent deadlock?

33. Describe the general strategy behind dealock prevention, and give an example of a practical deadlock prevention method.

34. Filesystems can support sparse files, what does this mean? Give an example of an application's file organisation that might benefit from a file system's sparse file support.

35. Give an example of a scenario that might benefit from a file system supporting an append-only access write.

36. Give a scenario where choosing a large filesystem block size might be a benefit; give an example where it might be a hinderance.

37. Give an example where contiguous allocation of file blocks on disks can be used in practice.

38. What file access pattern is particularly suited to chained file allocation on disk?

39. What file allocation strategy is most appropriate for random access files?

40. Compare bitmap-based allocation of blocks on disk with a free block list.

41. How can the block count in an inode differ from the (file size / block size) rounded up to the nearest integer. Can the block count be greater, smaller, or both.

42. Why might the direct blocks be stored in the inode itself?

43. Given that the maximum file size of combination of direct, single indirection, double indirection, and triple indirection in an inode-based filesystem is approximately the same as a filesystem soley using triple indirection, why not simply use only triple indirection to locate all file blocks?

44. What is the maximum file size supported by a file system with 16 direct blocks, single, double, and triple indirection? The block size is 512 bytes. Disk block numbers can be stored in 4 bytes.

45. The berkely fast filesystem (and Linux Ext2fs) use the idea of block groups. Describe what this idea is and what improvements block groups have over the simple filesystem layout of the System V file system (s5fs).

46. What is the reference count field in the inode? You should consider its relationship to directory entries in you answer.

47. The filesystem buffer cache does both buffering and caching. Describe why buffering is needed. Describe how buffering can improve performance (potentially to the detriment of file system robustness). Describe how the caching component of the buffer cache improves performance.

48. What does flushd do on a UNIX system?

49. Why might filesystems managing external storage devices do write-through caching (avoid buffering writes) even though there is a detrimental affect on performance.

50. Describe the difference between external and internal fragmentation. Indicate which of the two are most likely to be an issues on a) a simple memory memory mangement machine using base limit registers and static partitioning, and b) a similar machine using dynamic partitioning.

51. List and describe the four memory allocation algorithms covered in lectures. Which two of the four are more commonly used in practice?

52. Base-limit MMUs can support swapping. What is swapping? Can swapping permit an application requiring 16M memory to run on a machine with 8M of RAM?

53. Describe page-based virtual memory. You should consider pages, frames, page tables, and Memory Management Units in your answer.

54. Give some advantages of a system with page-based virtual memory compared to a simply system with base-limit registers that implements swapping.

55. Describe segmentation-based virtual memory. You should consider the components of a memory address, the segment table and its contents, and how the final physical address is formed in your answer.

56. What is a translation look-aside buffer? What is contained in each entry it contains?

57. Some TLBs support address space identifiers (ASIDS), why?

58. Describe a two-level page table? How does it compare to a simple page table array?

59. What is an inverted page table? How does it compare to a two-level page table?

60. What are temporal locality and spatial locality?

61. What is the working set of a process?

62. How does page size of a particular achitecture affect working set size?

63. What is thrashing? How might it be detected? How might one recover from it once detected?

64. Enumerate some pros and cons for increasing the page size.

65. Describe two virtual memory page fetch policies. Which is less common in practice? Why?

66. What operating system event might we observe and use as input to an algorithm that decides how many frames an application receives (i.e. an algorithm that determines the application's resident set size)?

67. Name and describe four page replacement algorithms. Critically compare them with each other.

-------------------------------------------------------------------
GOOGLE - Round 1 & 2
http://google.com

1.Introduction.
2.Current work setup.
3.Most challenging job that done in life.
4.Job that i can't handle in my life.
5.Difference between windows and linux.
6.Why the need for varoius linux distributions live Debian, redhat,fedora etc.
7.Different package management in linux.
8.Purpose of Load balancer
9.How to implement load balancer
10.If a call from a loadbalancer to an application server, then the reply to that call from loadbalancer to the client or directly to the client.
11.Difference between http and https.
12.Steps in SSL.
13.How the browser knows the site is https or not.
14.Kernal compilation.
15.What is GPL license
16.Whats the purpose of master-master db replication.
17.In an organization there are 1000 pupils, they need different levels of access, how we can implement it. If an marketing guy in travel needs to access local network as well as VPN, how we can implement.

GOOGLE - Round 3
http://google.com

1. Ports and Tcp/UDP for the following services
ssh,http,imap,pop3,ldap,imaps
2. You are asked to setup a few hundrends of machine for a conference how you setup?
3. One person can get internet in home, but when he comes in office, internet
not working. What all things will check? He has his ip and able to ping....etc...
4. Working of DHCP?
5. DHCP comes in which layer?
6. You are asked to copy some official and personal files from an old laptop to a new one
will you copy?
7. What is google?
8. What all things we can see in command "ifconfig"

GOOGLE - Round 4
http://google.com

1. mgetty
2. Booting preocess of linux in depth.
3. Kernal --> vmlinux --> authentication process --> initrd
4. Suppose we are copying a file over scp with 2 machines. How they transfer. How the bits
or bytes are getting copyied?
5. PAM
6. Operating System in depth.
7. Why you choose Systems Administration jobs

GOOGLE - Round 5
http://google.com

1. package managment in linux.
2. Working of apt-get full.
3. Working of mail server in depth.
4. DB replication, if 2 persons commiting at same time, which will take in action
5. Working of google search engine.
6. If i get cores of cores of dollars, how i start a company like GOOGLE.






Grid Computing
Round robin DNS
Load balancer



Just search for answers and you can post a reply to this post.