Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 75

technical-c- latest-18 may 2012

1Predict the output or error(s) for the following:


void main()
{
int const * p=5;
printf("%d",++(*p));
}
Answer:
Compiler error: Cannot modify a constant value.
Explanation: p is a pointer to a "constant integer".
But we tried to change the value of the "constant
integer".
 

2. main()

{
char s[ ]="man";
int i;
for(i=0;s[ i ];i++)
printf(" %c%c%c%c",s[ i ],*(s+i),*(i+s),i[s]);
}
Answer:
mmmm
aaaa
nnnn
Explanation: s[i], *(i+s), *(s+i), i[s] are all different
ways of expressing the same idea. Generally array
name is the base address for that array. Here s is
the base address. i is the index  number/
displacement from the base address. So, indirecting
it with * is same as s[i]. i[s] may be surprising. But
in the case of C it is same as s[i].
 

3. main()

{
float me = 1.1;
double you = 1.1;
if(me==you)
printf("I love U");
else
printf("I hate U");
}
Answer: I hate U
 

Explanation:  For floating point numbers (float,


double, long double) the values cannot be predicted
exactly. Depending on the number of bytes, the
precession with of the value represented varies.
Float takes 4 bytes and long double takes 10 bytes.
So float stores 0.9 with less precision than long
double.
Rule of Thumb:
Never compare or at-least be cautious when using
floating point numbers with relational operators (==
, >, <, <=, >=,!= ) .
 

4. main()

{
static int var = 5;
printf("%d ",var--);
if(var)
main();
}
Answer: 5 4 3 2 1
Explanation: When static storage class is given, it is
initialized once. The change in the value of a static
variable is retained even between the function calls.
Main is also treated like any other ordinary function,
which can be called recursively.
 

5. main()

{
int c[ ]={2.8,3.4,4,6.7,5};
int j,*p=c,*q=c;
for(j=0;j<5;j++) {
printf(" %d ",*c);
++q; }
for(j=0;j<5;j++){
printf(" %d ",*p);
++p; }
}
Answer:
2222223465
Explanation: Initially pointer c is assigned to both p
and q. In the first loop, since only q is incremented
and not c , the value 2 will be printed 5 times. In
second loop p itself is incremented. So the values 2
3 4 6 5 will be printed.
 

6.  main()

{
extern int i;
i=20;
printf("%d",i);
}
Answer:
Linker Error : Undefined symbol '_i'
Explanation: extern storage class in the following
declaration,
extern int i;
specifies to the compiler that the memory for i is
allocated in some other program and that address
will be given to the current program at the time of
linking. But linker finds that no other variable of
name i is available in any other program with
memory space allocated for it. Hence a linker error
has occurred .
 

7.  main()

{
int i=-1,j=-1,k=0,l=2,m;
m=i++&&j++&&k++||l++;
printf("%d %d %d %d %d",i,j,k,l,m);
}
Answer: 0 0 1 3 1
Explanation: Logical operations always give a result
of 1 or 0. And also the logical AND (&&) operator
has higher priority over the logical OR (||) operator.
So the expression ‘i++ && j++ && k++’ is executed
first. The result of this expression is 0 (-1 && -1 &&
0 = 0). Now the expression is 0 || 2 which evaluates
to 1 (because OR operator always gives 1 except for
‘0 || 0’ combination- for which it gives 0). So the
value of m is 1. The values of other variables are
also incremented by 1.
 

8.  main()

{
char *p;
printf("%d %d ",sizeof(*p),sizeof(p));
}
Answer: 1 2
Explanation: The sizeof() operator gives the number
of bytes taken by its operand. P is a character
pointer, which needs one byte for storing its value
(a character). Hence sizeof(*p) gives a value of 1.
Since it needs two bytes to store the address of the
character pointer sizeof(p) gives 2.
 

9.  main()

{
int i=3;
switch(i)
{
default:printf("zero");
case 1: printf("one");
break;
case 2:printf("two");
break;
case 3: printf("three");
break;
}
}
Answer : Three
Explanation: The default case can be placed
anywhere inside the loop. It is executed only when
all other cases doesn't match.
 

10.  main()

{
printf("%x",-1<<4);
}
Answer: fff0
Explanation: -1 is internally represented as all 1's.
When left shifted four times the least significant 4
bits are filled with 0's.The %x format specifier
specifies that the integer value be printed as a
hexadecimal value.
Poornam Info Vision Latest Selection Procedure

11.  main()

{
char string[]="Hello World";
display(string);
}
void display(char *string)
{
printf("%s",string);
}
Answer:
Compiler Error: Type mismatch in redeclaration of
function display
Explanation: In third line, when the function display
is encountered, the compiler doesn't know anything
about the function display. It assumes the
arguments and return types to be integers, (which is
the default type). When it sees the actual function
display, the arguments and type contradicts with
what it has assumed previously. Hence a compile
time error occurs.
 

12.  main()

{
int c=- -2;
printf("c=%d",c);
}
Answer:
c=2;
Explanation: Here unary minus (or negation)
operator is used twice. Same maths rules applies,
ie. minus * minus= plus.
Note: However you cannot give like --2. Because --
operator can only be applied to variables as a
decrement operator (eg., i--). 2 is a constant and
not a variable.
 

13.  #define int char

main()
{
int i=65;
printf("sizeof(i)=%d",sizeof(i));
}
Answer:
sizeof(i)=1
Explanation: Since the #define replaces the string
int by the macro char
 

14.  main()

{
int i=10;
i=!i>14;
Printf ("i=%d",i);
}
Answer:
i=0
Explanation: In the expression !i>14 , NOT (!)
operator has more precedence than ‘ >’ symbol. ! is
a unary logical operator. !i (!10) is 0 (not of true is
false). 0>14 is false (zero).
 

15.  #include<stdio.h>

main()
{
char s[]={'a','b','c',' ','c',''};
char *p,*str,*str1;
p=&s[3];
str=p;
str1=s;
printf("%d",++*p + ++*str1-32);
}
Answer:
77
Explanation: p is pointing to character ' '. str1 is
pointing to character 'a' ++*p. "p is pointing to ' '
and that is incremented by one." the ASCII value of
' ' is 10, which is then incremented to 11. The value
of ++*p is 11. ++*str1, str1 is pointing to 'a' that is
incremented by 1 and it becomes 'b'. ASCII value of
'b' is 98.
Now performing (11 + 98 – 32), we get 77("M"); So
we get the output 77 :: "M" (Ascii is 77).
 

16.  #include<stdio.h>

main()
{
int a[2][2][2] = { {10,2,3,4}, {5,6,7,8} };
int *p,*q;
p=&a[2][2][2];
*q=***a;
printf("%d----%d",*p,*q);
}
Answer:
SomeGarbageValue---1
Explanation:
p=&a[2][2][2] you declare only two 2D arrays, but
you are trying
to access the third 2D(which you are not declared) it
will print garbage values.
*q=***a starting address of a is assigned integer
pointer. Now q is pointing to starting address of a. If
you print *q, it will print first element of 3D array.
Poornam Info Vison whole Test Paper

17.  #include<stdio.h>

main()
{
struct xx
{
int x=3;
char name[]="hello";
};
struct xx *s;
printf("%d",s->x);
printf("%s",s->name);
}
Answer:
Compiler Error
Explanation: You should not initialize variables in
declaration
 

18.  #include<stdio.h>

main()
{
struct xx
{
int x;
struct yy
{
char s;
struct xx *p;
};
struct yy *q;
};
}
Answer:
Compiler Error
Explanation: The structure yy is nested within
structure xx. Hence, the elements are of yy are to
be accessed through the instance of structure xx,
which needs an instance of yy to be known. If the
instance is created after defining the structure the
compiler will not know about the instance relative to
xx. Hence for nested structure yy you have to
declare member.
 

19.  main()

{
printf(" ab");
printf("si");
printf(" ha");
}
Answer: hai
Explanation:
- newline
- backspace
- linefeed
20. main()
{
int i=5;
printf("%d%d%d%d%d%d",i++,i--,++i,--i,i);
}
Answer: 45545
Explanation: The arguments in a function call are
pushed into the stack from left to right. The
evaluation is by popping out from the stack. And the
evaluation is from right to left, hence the result.
 

20.  #define square(x) x*x

main()
{
int i;
i = 64/square(4);
printf("%d",i);
}
Answer: 64
Explanation: the macro call square(4) will
substituted by 4*4 so the expression becomes i =
64/4*4 . Since / and * has equal priority the
expression will be evaluated as (64/4)*4 i.e. 16*4 =
64
 

21.  main()

{
char *p="hai friends",*p1;
p1=p;
while(*p!='') ++*p++;
printf("%s %s",p,p1);
}
Answer: ibj!gsjfoet
Explanation: ++*p++ will be parse in the given
order
_ *p that is value at the location currently pointed
by p will be taken
_ ++*p the retrieved value will be incremented
_ when; is encountered the location will be
incremented that is p++ will be executed Hence, in
the while loop initial value pointed by p is ‘h’, which
is changed to ‘i’ by executing ++*p and pointer
moves to point, ‘a’ which is similarly changed to ‘b’
and so on. Similarly blank space is converted to ‘!’.
Thus, we obtain value in p becomes “ibj!gsjfoet” and
since p reaches ‘’ and p1 points to p thus p1doesnot
print anything.
 

22. #include <stdio.h>

#define a 10
main()
{
#define a 50
printf("%d",a);
}
Answer: 50
Explanation: The preprocessor directives can be
redefined anywhere in the program. So the most
recently assigned value will be taken.
 

23.  #define clrscr() 100

main()
{
clrscr();
printf("%d ",clrscr());
}
Answer: 100
Explanation: Preprocessor executes as a seperate
pass before the execution of the compiler. So
textual replacement of clrscr() to 100 occurs. The
input program to compiler looks like this :
main()
{
100;
printf("%d ",100);
}
Note:
100; is an executable statement but with no action.
So it doesn't give any problem
 

24.  main()

{
41printf("%p",main);
}8
Answer: Some address will be printed.
Explanation: Function names are just addresses
(just like array names are addresses). main() is also
a function. So the address of function main will be
printed. %p in printf specifies that the argument is
an address. They are printed as hexadecimal
numbers.
 

Poornam Info Vision Latest Company Profile


Poornam Info Vision Whole Test Papers with
answers
 

Linux Questions
When using useradd to create a new user account,
which of the following tasks is not done
automatically. Choose one:
a. Assign a UID. b. Assign a default shell. c. Create
the user’s home directory. d. Define the user’s home
directory.
You issue the following command useradd -m bobm
But the user cannot logon. What is the problem?
Choose one: a. You need to assign a password to
bobm’s account using the passwd command. b. You
need to create bobm’s home directory and set the
appropriate permissions. c. You need to edit the
/etc/passwd file and assign a shell for bobm’s
account. d. The username must be at least five
characters long.
You have created special configuration files that you
want copied to each user’s home directories when
creating new user accounts. You copy the files to
/etc/skel.
Which of the following commands will make this
happen? Choose one: a. useradd -m username b.
useradd -mk username c. useradd -k username d.
useradd -Dk username
Mary has recently gotten married and wants to
change her username from mstone to mknight.
Which of the following commands should you run to
accomplish this? Choose one: a. usermod -l mknight
mstone b. usermod -l mstone mknight c. usermod
-u mknight mstone d. usermod -u mstone mknight
After bob leaves the company you issue the
command userdel bob. Although his entry in the
/etc/passwd file has been deleted, his home
directory is still there. What command could you
have used to make sure that his home directory was
also deleted? Choose one: a. userdel -m bob b.
userdel -u bob c. userdel -l bob d. userdel -r bob
All groups are defined in the /etc/group file. Each
entry contains four fields in the following order.
Choose one: a. groupname, password, GID, member
list b. GID, groupname, password, member list c.
groupname, GID, password, member list d. GID,
member list, groupname, password
You need to create a new group called sales with
Bob, Mary and Joe as members. Which of the
following would accomplish this? Choose one: a. Add
the following line to the /etc/group file:
sales:44:bob,mary,joe b. Issue the command
groupadd sales. c. Issue the command groupadd -a
sales bob,mary,joe d. Add the following line to
the /etc/group file: sales::44:bob,mary,joe
You attempt to use shadow passwords but are
unsuccessful. What characteristic of the /etc/passwd
file may cause this? Choose one: a. The login
command is missing. b. The username is too long. c.
The password field is blank. d. The password field is
prefaced by an asterick.
You create a new user account by adding the
following line to your /etc/passwd file.
bobm:baddog:501:501:Bob
Morris:/home/bobm:/bin/bash Bob calls you and
tells you that he cannot logon. You verify that he is
using the correct username and password. What is
the problem? Choose one: a. The UID and GID
cannot be identical. b. You cannot have spaces in
the line unless they are surrounded with double
quotes. c. You cannot directly enter the password;
rather you have to use the passwd command to
assign a password to the user. d. The username is
too short, it must be at least six characters long.
Which of the following tasks is not necessary when
creating a new user by editing the /etc/passwd file?
Choose one: a. Create a link from the user’s home
directory to the shell the user will use. b. Create the
user’s home directory c. Use the passwd command
to assign a password to the account. d. Add the user
to the specified group.
You create a new user by adding the following line
to the /etc/passwd file bobm::501:501:Bob
Morris:/home/bobm:/bin/bash You then create the
user’s home directory and use the passwd command
to set his password. However, the user calls you and
says that he cannot log on. What is the problem?
Choose one: a. The user did not change his
password. b. bobm does not have permission to
/home/bobm. c. The user did not type his username
in all caps. d. You cannot leave the password field
blank when creating a new user.

Poornam Info Vision Selection Process


Written test (Aptitude, C, LINUX, General Technical
Awareness, Communication) Interviews (Technical and
HR rounds)
The recruitment process for Poornam Infovision consists

1. Written Test -Aptitude

2. Technical Interview

3. HR Interview
4. Essay Section

Poornam Info vision Written Test consists Aptitude and


Technical Question

1 Written Test

Quantitative Aptitude : 10 Questions

Logical Deductions

Statement Problems etc.,

C section  :10 Questions

Linux Section : 20 Questions

Technical Section : 20 Questions

Essay :200 words 1 Topic

Poornam Info Visions  Previously asked Questions in


Placements

1.APTITUDE SECTION: 10 QUESTIONS

I) In each of the following questions, a set of six


statements is given, followed by four answer choices.
Each of the answer choices has a combination of three
statements from the given set of six statements. You are
required to identify the answer choices in which the
statements are logically related.
i) A.All cats are goats
B. All Goats are dogs.
C. No goats are cows
D. No goats are dogs
E. All Cows are dogs
F. All dogs are cows
a) FAB
b) ABE
c) AFB
d) ABF

ii) A.Some lids are nibs


B. All hooks are lids.
C. All hooks are nibs
D. No lid is a nib
E. No lid is a hook
F. No nib is hook
a) EFD
b)BCA
c)DEA
d)CDA

iii)A.All MBA’s are logical


B.Sudir is rational.
C.Sudhir is a logical MBA
D.Sudhir is a man
E.Some men are MBA’s
F.All men are rational.
a) DEC
b) EAF
c) BCF
d) FDB

iv) A.Competitive examinations are tough to pass.


B.There is heavy competition in any field.
C. No student can pass MAT
D. Very few students can pass MAT.
E. MAT is a competitive examination
F. MAT is tough to pass
a) AEF
b) ABC
c) DFB
d) CDE

v) A.All Pens are knives


B. All knives are spoons
C. No knives are pens
D. No knives are spoons.
E. All pens are spoons.
F. All spoons are pens.
a) ABE
b) ABF
c) AFE
d) DBE 

II) Questions 5 and 6 are based on the following data: 


In a class of 150 students, 40 passed in Social Studies,
90 passed in Science and 30 failed in both the subjects.
vi) How many students passed in at most one subject
among Science and Social Science?
a) 100
b) 110
c) 140 
d) 150

vii) How many students passed in Science but failed in


Social Studies?
a) 70 
b) 10
c) 90 
d) 80 

Poornam Info Visions C section Technical Questions

2. C SECTION: 10 QUESTIONS

i) What will be the output for the following program?


void main()
{
int const *p=5;
printf("%d",++(*p));
}
a) 5
b) 6
c) Run time error
d) Compiler error
ii) What will be the output for the following program?
main()
{
int c[]={2.8,3.4,4,6.7,5};
int j,*p=c,*q=c;
for(j=0;j<5;j++) {
printf("%d",*c);
++q; }
for(j=0;j<5;j++) {
printf("%d",*p);
++p; }
}
a) 2 2 2 2 2 2 2 3 4 5
b) 2 2 2 2 2 2 3 4 6 5
c) 2 3 4 6 5 2 3 4 6 5 
d) 2 3 4 6 5 3 4 5 6 7

iii) What will be the output for the following program?


main()
{
extern int i;
i=20;
printf("%d",i);
}
a) 20
b) Grabage value
c) Linker error
d) Compiler error

iv) What will be the output for the following program?


main()
{
int i=-1,j=-1,k=0,l=2,m;
m=i++&&j++&&k++||l++;
printf("%d %d %d %d %d",i,j,k,l,m);
}
a) 0 0 1 3 0
b) 0 0 1 3 2
c) 0 0 1 3 1 
d) 1 1 2 3 1

v) What will be the output for the following program?


main()
{
char *p;
printf("%d %d",sizeof(*p),sizeof(p));
}
a) 1 1 
b) 2 1
c) 1 2
d) 2 2

vi) What will be the output for the following program? 


main()
{
int i=3;
switch(i)
{
default: printf("zero");
case 1: printf("one");
break;
case 2: printf("two");
break;
case 3: printf("three");
break;
}
}
a) zero
b) zero one two three
c) three
d) zero three

vii) What will be the output for the following program? 


main()
{
printf("%x",-1<<4);
}
a) ffff
b) 0000
c) 0fff
d) fff0

viii) What will be the output for the following program? 


main()
{
char String[]="Hello World";
display(string);
}
void display(char *string)
{
printf("%s",string);
}
a) Hello World
b) Linker error 
c) Compiler error
d) Hello

ix) What will be the output for the following program?


main()
{
struct xx
{
int x;
struct yy 
{
char s;
struct xx *p;
};
struct y *P;
};
}
a) Blank screen
b) Linker error
c) Compiler error
d) Infinite execution

x) What will be the output for the following program? 


#include<stdio.h>
main()
{
struct xx
{
int x=3;
char name[]="hello";
};
struct xx *s;
printf("%d",s->x);
printf("%s",s->name); 
}
a) 3 hello 
b) 3hello
c) Linker error
d) Compiler error 

3.LINUX SECTION: 20 QUESTIONS

i) You are trying to create four partitions on a linux


system and you get an error while creating the fourth
partition. Why?
a) Linux does not allow four partitions.
b) There is not enough disk space for the fourth
partition. 
c) The swap partition must be created first.
d) The last partition must be a swap partition.

ii) Which of the following is not a valid Linux command?


a) rm
b) mv
c) copy
d) more

iii) Which Linux command is used for renaming a file?


a) rm
b) mv
c) chmod
d) rename

Poornam Info Visions Technical part has 20 Questions

4. TECHNICAL SECTION: 20 QUESTIONS


i) What is the maximum decimal number that can be
accomodated in a byte?
a) 128
b) 256
c) 255
d) 512 
ii) The BIOS of a computer is stored in:
a) RAM
b) ROM
c) CACHE
d) HARD DISK

iii) Which of the folowing does not work over TCP? 


a) HTTP
b) SMTP
c) FTP
d) None of the above

iv) What is the number of control lines for a 16 output


decoder? 
a) 2
b) 4
c) 16
d) 10

v) Which IP Addressing class allows for the largest


number of hosts?
a) Class A
b) Class A and B
c) Class B
d) Class C

vi) Which IP Addressing class allows for the largest


number of hosts? 
Poornam Info Vision written test one section Essay
Writing

5. ESSAY SECTION :
Write an essay with minimum 200 words on the topic: "Is
the projection of violence on television responsible for the
prevalence of violence in our society?"
Linux and Unix System Administration
Interview Questions
 

1)  What is GRUB


GNU GRUB is a Multiboot boot loader. It was derived from GRUB, the
GRand Unified Bootloader,

which was originally designed and implemented by Erich Stefan


Boleyn.

Briefly, a boot loader is the first software program that runs when a
computer starts. It is

responsible for loading and transferring control to the operating


system kernel software

(such as the Hurd or Linux). The kernel, in turn, initializes the rest of
the operating

system (e.g. GNU)

2) Explain Linux Boot Process


Press the power button on your system, and after few moments you
see the Linux login prompt.

Have you ever wondered what happens behind the scenes from the
time you press the power button until the Linux login prompt appears?
The following are the 6 high level stages of a typical Linux boot
process.

a. BIOS
 BIOS stands for Basic Input/Output System
 Performs some system integrity checks
 Searches, loads, and executes the boot loader program.
 It looks for boot loader in floppy, cd-rom, or hard drive. You can
press a key (typically F12 of F2, but it depends on your system) during
the BIOS startup to change the boot sequence.
 Once the boot loader program is detected and loaded into the
memory, BIOS gives the control to it.
 So, in simple terms BIOS loads and executes the MBR boot
loader.

b. MBR
 MBR stands for Master Boot Record.
 It is located in the 1st sector of the bootable disk.
Typically /dev/hda, or /dev/sda
 MBR is less than 512 bytes in size. This has three components
1) primary boot loader info in 1st 446 bytes 2) partition table info in
next 64 bytes 3) mbr validation check in last 2 bytes.
 It contains information about GRUB (or LILO in old systems).
 So, in simple terms MBR loads and executes the GRUB boot
loader.

c. GRUB
 GRUB stands for Grand Unified Bootloader.
 If you have multiple kernel images installed on your system,
you can choose which one to be executed.
 GRUB displays a splash screen, waits for few seconds, if you
don’t enter anything, it loads the default kernel image as specified in
the grub configuration file.
 GRUB has the knowledge of the filesystem (the older Linux
loader LILO didn’t understand filesystem).
 Grub configuration file is /boot/grub/grub.conf
(/etc/grub.conf is a link to this). The following is sample grub.conf of
CentOS.

1 <span style="background-color: #dff10d; color:


2 #260af4;"><strong>#boot=/dev/sda
3 default=0
4 timeout=5
5 splashimage=(hd0,0)/boot/grub/splash.xpm.gz
6 hiddenmenu
7 title CentOS (2.6.18-194.el5PAE)
8           root (hd0,0)
          kernel /boot/vmlinuz-2.6.18-194.el5PAE ro
root=LABEL=/
9
          initrd /boot/initrd-2.6.18-
194.el5PAE.img</strong></span>
 As you notice from the above info, it contains kernel and initrd
image.
 So, in simple terms GRUB just loads and executes Kernel and
initrd images.

d. Kernel
 Mounts the root file system as specified in the “root=” in
grub.conf
 Kernel executes the /sbin/init program
 Since init was the 1st program to be executed by Linux Kernel, it
has the process id (PID) of 1. Do a ‘ps -ef | grep init’ and check the
pid.
 initrd stands for Initial RAM Disk.
 initrd is used by kernel as temporary root file system until kernel
is booted and the real root file system is mounted. It also contains
necessary drivers compiled inside, which helps it to access the hard
drive partitions, and other hardware.

e. Init
 Looks at the /etc/inittab file to decide the Linux run level.
 Following are the available run levels
o 0 – halt
o 1 – Single user mode
o 2 – Multiuser, without NFS
o 3 – Full multiuser mode
o 4 – unused
o 5 – X11
o 6 – reboot
 Init identifies the default initlevel from /etc/inittab and uses that to
load all appropriate program.
 Execute ‘grep initdefault /etc/inittab’ on your system to identify
the default run level
 If you want to get into trouble, you can set the default run
level to 0 or 6. Since you know what 0 and 6 means, probably you
might not do that.
 Typically you would set the default run level to either 3 or 5.

f. Runlevel programs
 When the Linux system is booting up, you might see various
services getting started. For example, it might say “starting sendmail
…. OK”. Those are the runlevel programs, executed from the run level
directory as defined by your run level.
 Depending on your default init level setting, the system will
execute the programs from one of the following directories.
o Run level 0 – /etc/rc.d/rc0.d/
o Run level 1 – /etc/rc.d/rc1.d/
o Run level 2 – /etc/rc.d/rc2.d/
o Run level 3 – /etc/rc.d/rc3.d/
o Run level 4 – /etc/rc.d/rc4.d/
o Run level 5 – /etc/rc.d/rc5.d/
o Run level 6 – /etc/rc.d/rc6.d/
 Please note that there are also symbolic links available for these
directory under /etc directly. So, /etc/rc0.d is linked to /etc/rc.d/rc0.d.
 Under the /etc/rc.d/rc*.d/ directories, you would see programs
that start with S and K.
 Programs starts with S are used during startup. S for startup.
 Programs starts with K are used during shutdown. K for kill.
 There are numbers right next to S and K in the program names.
Those are the sequence number in which the programs should be
started or killed.
 For example, S12syslog is to start the syslog deamon, which has
the sequence number of 12. S80sendmail is to start the
sendmail daemon, which has the sequence number of 80. So, syslog
program will be started before sendmail.

There you have it. That is what happens during the Linux boot
process.

3) Which files are called for user profile by default when a user
gets login
$HOME/.bash_profile, $HOME/.bash_bashrc
4) Which file needs to update if srequired to change default
runlevel 5 to 3
File is /etc/inittab and required to change below lines:
id:5:initdefault: to id:3:initdefault:
5) What command used for showing user info like Login Name,
Canonical Name, Home Directory,Shell etc..
 FINGER command can be used i.g; finger username
6) What is inode number
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

iNode number also called as index number, it consists following


attributes:

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)

File deletion time

Number of links (soft/hard)

Extended attribute such as append only or no one can delete file


including root user

(immutability)

Access Control List (ACLs)

Following command will be used to show inodes of file and folders:

ls -i

Following command will show complete info about any file or folders
with inode number

stat file/folder
Files/Folders can also be deleted using inode numbers with following
command:

find out the inode number using ‘ls -il’ command then run below
command

find . -inum inode_number -exec rm -i {} \;

7) How can we increase disk read performance in single


command
blockdev command

This is sample output – yours may be different.

# Before test

$ blockdev –getra /dev/sdb

256

$ time dd if=/tmp/disk.iso of=/dev/null bs=256k

2549+1 records in

2549+1 records out

668360704 bytes (668 MB) copied, 6,84256 seconds, 97,7 MB/s

real 0m6.845s

user 0m0.004s

sys 0m0.865s
# After test

$ blockdev –setra 1024 /dev/sdb

$ time dd if=/tmp/disk.iso of=/dev/null bs=256k

2435+1 records in

2435+1 records out

638390272 bytes (638 MB) copied, 0,364251 seconds, 1,8 GB/s

real 0m0.370s

user 0m0.001s

sys 0m0.370s

8) …. command to change user password expiration time


CHAGE

9) Command used to lock user password


usermod -L username

10) How many default number of Shells available and what are
their names?
SH, BASH, CSH, TCSH, NOLOGIN, KSH

11) Which file defines the attributes like UID, PASSWORD expiry,
HOME Dir create or not while adding user
/etc/login.defs
12) …… command used for changing authentication of linux
system to LDAP/NIS/SMB/KERBOS
authconfig

13) …… command used for changing the attributes of any file


chattr

14) What is the path of network (ethX) configuration files


/etc/sysconfig/network-scripts/ethX

15) How can we change speed and make full duplex settings for
eth0
We can do this with below given 2 methods:

ethtool -s eth0 speed 100 duplex full

ethtool -s eth0 speed 10 duplex half

OR

mii-tool -F 100baseTx-HD

mii-tool -F 10baseT-HD

16) File which stores the DNS configuration at client side


/etc/resolve.conf

17) Main configuration file and command used for exporting NFS
directories and it’s deamons
/etc/exports and exportfs -av , deamons are quotad, portmapper,
mountd, nfsd and nlockmgr/status
18) What is command to check ports running/used over local
machine
netstat -antp

19) What is the command to check open ports at remote machine


nmap

20) What is the difference between soft and hard links


Soft Links => 1) Soft link files will have different inode numbers then
source file

2) If original file deleted then soft link file be of no use

3) Soft links are not updated

4) Can create links between directories

5) Can cross file system boundaries

Hard Links => 1) Hard links will have the same inode number as
source file

2) Hard links can not link directories

3) Can not cross file system boundaries

4) Hard links always refers to the source, even if moved or removed

21) How to setup never expired user password


chage -E never username

22) Restricting insertion into file if full permission are assigned to all
chattr +i filename

23) Display or Kill all processes which are accessing any


folder/file
Display User who are using file/folder : fuser -u file/folder

Kill All Processes which are using file/folder: fuser -k file/folder

24) Kill any user’s all processes


killall -u username

25) How can we have daily system analysis and reports over mail
Use logwatch

26) How can we rotate logs using logrotate without performing


any operation  like move and gzip’ng over original file and then
creating new file (which is very lengthy process)
We can use “logrotate”‘s “copytruncate” option which will simply copy
original file and truncate original file 

27) Command to collect detailed information about the hardware


and setup of your system
dmidecode , sysreport

28) Command to check PCI devices vendor or version


Ans lspci

29) What is the difference between cron and anacron


Cron :
1) Minimum granularity is minute (i.e Jobs can be scheduled to be
executed

every minute)

2) Cron job can be scheduled by any normal user ( if not restricted by


super

user )

3) Cron expects system to be running 24 x 7. If a job is scheduled,


and

system is down during that time, job is not executed

4) Ideal for servers

5) Use cron when a job has to be executed at a particular hour and


minute

Anacron :

1) Minimum granularity is only in days

2) Anacron can be used only by super user ( but there are


workarounds to

make it usable by normal user )

3) Anacron doesn’t expect system to be running 24 x 7. If a job is


scheduled,
and system is down during that time, it start the jobs when the system

comes back up.

4) Ideal for desktops and laptops

5) Use anacron when a job has to be executed irrespective of hour


and

minute

30)  Default Port numbers used by


ssh,ftp,http,https,telnet,smtp,pop3,pop3s,imap,imaps
SSH 22, ftp 20/21, http 80, https 443, SMTP/SMPTS 25/465,
POP3/POP3S 110/995, IMAP/IMAPS 143/993

31)  How to setup ACLs in following case:


1) Create a file FILE1 and this should be read,write,executable for all
user but Read only  for user USER1

2) Copy FILE1 ACLs to FILE2 ACL

3) Delete a USER1’s rule for FILE1 which were setup in step 1)

Ans 1) touch FILE1 ; chmod 777 FILE1 ; setfacl -m u:USER1:r FILE1

2) getfacl FILE1 | setfacl –set-file=- FILE2

3) setfacl -x u:USER1 FILE1

32)  How to make USB bootable?


Write efidisk.img from RHEL 6 DVD images/ subdirectory to USB
dd if=efidisk.img of=/dev/usb (usb device name)

33)  How can we check disk/device status/failure/errors using


smartctl utility?
Try following to check:

Enable/Disable SMART on device/disk : smartctl -s on /dev/sda

Check device SMART health : smartctl -H /dev/sda

Check device SMART capabilities : smartctl -c /dev/sda

Enable/Disable automatic offline testing on device : smartctl -o


on/off /dev/sda

Show device SMART vendor-specific Attributes and values : smartctl


-A /dev/sda

Show device log [TYPE : error, selftest, selective,


directory,background,

scttemp[sts,hist]] : smartctl -l TYPE /dev/sda

Run test on device [TEST: offline short long conveyance select,M-N


pending,N

afterselect,[on|off] scttempint,N[,p] : smartctl -t /dev/sda

34)  What is the difference between ext2 vs ext3 vs ext4?


http://www.thegeekstuff.com/2011/05/ext2-ext3-ext4/

35)  Disable ping to avoid network/ICMP flood


Set following in /etc/sysctl.conf : net.ipv4.icmp_echo_ignore_all = 1

Then “sysctl -p”

or

echo “1” > /proc/sys/net/ipv4/icmp_echo_ignore_all

36)  What is SYN Flood, ICMP Flood


SYN Flood : A SYN flood occurs when a host sends a flood of
TCP/SYN packets, often with a
fake/forged sender address. Each of these packets is handled like a
connection request, causing the

server to spawn a half-open connection, by sending back


a TCP/SYN-ACK packet(Acknowledge), and
waiting for a packet in response from the sender address(response to
the ACK Packet). However,

because the sender address is forged, the response never comes.


These half-open connections

saturate the number of available connections the server is able to


make, keeping it from responding to

legitimate requests until after the attack ends

ICMP Flood : There are three types of ICMP Flood :

1) Smurf Attack : http://en.wikipedia.org/wiki/Smurf_attack


2) Ping Flood :  http://en.wikipedia.org/wiki/Ping_flood

3) Ping of Death : http://en.wikipedia.org/wiki/Ping_of_death

37)  What is the difference between Unix vs Linux Kernels?


Please find below given link :

http://www.thegeekstuff.com/2012/01/linux-unix-kernel/

38) How to setup Password less remote login/ssh?


Use “ssh-keygen -t dsa or rsa” at local system for creating public
and private keys
Then copy /root/.ssh/id_dsa.pub to remote_server by name
/root/.ssh/authorized_keys

Change permissions of /root/.ssh/authorized_keys file at


remote_server “chmod 0600 ~/.ssh/authorized_keys”

Now try to login from local system to remote_server “ssh


root@remote_server”

39) Command to see default kernel image file


“grubby –default-kernel”

40) How to create lvm mirror


lvcreate -L 50G -m1 -n LVMmirror vg0

41) Command to check last runlevel


who -r

42) What do you mean by File System?


File System is a method to store and organize files and directories on
disk. A file system can have different formats called file system types.
These formats determine how the information is stored as files and
directories.

43) What is the requirement of udev daemon?


Create and remove device nodes or files in /dev/ directory

44) What are block and character devices?


Both the devices are present in /dev directory

Block device files talks to devices block by block [1 block at a time (1


block = 512 bytes to 32KB)].

Examples: – USB disk, CDROM, Hard Disk (sda, sdb, sdc etc….)

Character device files talk to devices character by character.

Examples: – Virtual terminals, terminals, serial modems, random


numbers (tty{0,1,2,3……})

45) How to Convert ext2 to ext3 File System?


 tune2fs -j /dev/{device-name}
46) File required to modify for setting up kernel parameters
permanent
 /etc/sysctl.conf
47) Commands used to install, list and remove modules from
kernel
Installing/adding a module:
insmod mod_name

modprobe mod_name

List installed modules :  lsmod

Removing a module     : modprobe -r mod_name

48) How to create swap using a file and delete swap


Adding swap :

dd if=/dev/zero of=/opt/myswap bs=1024 count=4


mkswap /opt/myswap
swapon -a

For adding this myswap at boot time, add following in /etc/fstab file:
/opt/myswap       swap     swap   defaults   0 0
Deleting Swap :

Run “swapoff /opt/myswap” command

Remove the entry from /etc/fstab file

Remove /opt/myswap file (using rm command)

49) What vmstat show


vmstat (virtual memory statistics) is a computer system monitoring tool
that collects and displays summary information about operating
system memory, processes, interrupts, paging and block I/O

50) What is tmpfs File System


Reference : http://en.wikipedia.org/wiki/Tmpfs

tmpfs is a common name for a temporary file storage facility on many


Unix-like operating systems. It is intended to appear as a mounted file
system, but stored in volatile memory instead of a persistent storage
device. A similar construction is a RAM disk, which appears as a
virtual disk drive and hosts a disk file system.

Everything stored in tmpfs is temporary in the sense that no files will


be created on the hard drive; however, swap space is used as backing
store in case of low memory situations. On reboot, everything in tmpfs
will be lost.

The memory used by tmpfs grows and shrinks to accommodate the


files it contains and can be swapped out to swap space.

51) What is the difference between screen and script commands?


Screen is an screen manager with VT100/ANSI terminal emulation
and used to take GNU screen session remotely or locally and while
Script make typescript of terminal session

Screen : needs to be detached, should not be exited to access


remotely/locally

Script : creates a file and store all the terminal output to this file

52) How can we check which process is assigned to which


processor?
Ans Run “ps -elFL” and find out the PSR column which is showing the
processor number to the process

53) How can we check vendor, version, release date, size,


package information etc… of any installed rpm?
 
rpm -qi package-name , for example:

rpm -qi ypbind-1.19-12.el5

Download Linux Admin Interview Questions &


Answers.
Q) Q) What is Linux and why is it so popular?
Answer - Linux is an operating system that uses UNIX like
Operating system.......

Q) Q) What is LILO?
Answer - LILO is Linux Loader is a boot loader for Linux. It is used
to load Linux into the memory and start the Operating system.......

Q) Q) What is the difference between home directory and working


directory?

Answer - Home directory is the default working directory when a


user logs in. On the other hand, working directory is the user’s
current directory.......

Q) Q) What is the difference between internal and external


commands?

Answer - Internal commands are commands that are already


loaded in the system. They can be executed any time and are
independent.......

Q) Explain the difference between a static library and a dynamic


library.

Answer - Static libraries are loaded when the program is compiled


and dynamically-linked libraries are loaded in while......

Q) What is LD_LIBRARY_PATH?

Answer - LD_LIBRARY_PATH is an environment variable. It is


used for debugging a new library or a non standard library.......

Q) What is the file server in Linux server?


Answer - File server is used for file sharing. It enables the
processes required fro sharing.......

Q) What is NFS? Q) What is its purpose?

Answer - NFS is Network File system. It is a file system used for


sharing of files over a network.......

How do I send email with linux?

Answer - Email can be sent in Linux using the mail command. ......

Q) Explain RPM (Red Hat Package Manager) features.

Answer - RPM is a package managing system (collection of tools


to manage software packages).......

Q) What is Kernel? Q) Explain the task it performs.

Answer - Kernel is used in UNIX like systems and is considered to


be the heart of the operating system.......

Q) What is Linux Shell? Q) What is Shell Script?

Answer - Linux shell is a user interface used for executing the


commands. Shell is a program the user......

Q) What are Pipes? Q) Explain use of pipes.

Answer - A pipe is a chain of processes so that output of one


process (stdout) is fed an input (stdin) to another.......

Q) Explain trap command; shift Command, getopts command of


linux.
Answer - Trap command: controls the action to be taken by the
shell when a signal is received. ......

Q) What Stateless Linux server? Q) What feature it offers?

Answer - A stateless Linux server is a centralized server in which


no state exists on the single workstations. ......

Q) What does nslookup do? Q) Explain its two modes.

Answer - Nslookup is used to find details related to a Domain


name server. Details like IP addresses of a machine, MX
records,......

Q) What is Bash Shell?

Answer - Bash is a free shell for UNIX. It is the default shell for
most UNIX systems. It has a combination of the C and Korn shell
features. ......

Q) Explain some Network-Monitoring Tools in Linux: ping,


traceroute, tcpdump, ntop

Answer - Network monitoring tools are used to monitor the


network, systems present on the network, traffic etc.......

How does the linux file system work?

Answer - Linux file structure is a tree like structure. It starts from


the root directory, represented by '/', and then expands into sub-
directories.......

Q) What are the process states in Linux?

Answer - Process states in Linux.......


Q) What is a zombie?

Answer - Zombie is a process state when the child dies before the
parent process. In this case the structural information of the
process is still in the process table.......

Q) Explain each system calls used for process management in


linux.

Answer - System calls used for Process management......      

Q) Which command is used to check the number of files and disk


space used and the each user’s defined quota?

repquota command is used to check the status of the user’s quota


along with the disk space and number of files used. This
command gives a summary of the user’s quota that how much
space and files are left for the user. Every user has a defined
quota in Linux. This is done mainly for the security, as some users
have only limited access to files. This provides a security to the
files from unwanted access. The quota can be given to a single
user or to a group of users.

Q) What is the name and path of the main system log?

By default the main system log is /var/log/messages. This file


contains all the messages and the script written by the user. By
default all scripts are saved in this file. This is the standard
system log file, which contains messages from all system
software, non-kernel boot issues, and messages that go to
'dmesg'. dmesg is a system file that is written upon system boot.
Q) How secured is Linux? Q) Explain.

Security is the most important aspect of an operating system. Due


to its unique authentication module, Linux is considered as more
secured than other operating systems. Linux consists of PAM.
PAM is Pluggable Authentication Modules. It provides a layer
between applications and actual authentication mechanism. It is a
library of loadable modules which are called by the application for
authentication. It also allows the administrator to control when a
user can log in. All PAM applications are configured in the
directory "/etc/pam.d" or in a file "/etc/pam.conf". PAM is
controlled using the configuration file or the configuration
directory.

Q) Can Linux computer be made a router so that several


machines may share a single Internet connection? How?

Yes a Linux machine can be made a router. This is called "IP


Masquerade." IP Masquerade is a networking function in Linux
similar to the one-to-many (1: Many) NAT (Network Address
Translation) servers found in many commercial firewalls and
network routers. The IP Masquerade feature allows other
"internal" computers connected to this Linux box (via PPP,
Ethernet, etc.) to also reach the Internet as well. Linux IP
Masquerading allows this functionality even if the internal
computers do not have IP addresses.
The IP masquerading can be done by the following steps:

1. The Linux PC must have an internet connection and a


connection to LAN. Typically, the Linux PC has two network
interfaces-an Ethernet card for the LAN and a dial-up PPP
connection to the Internet (through an ISP).
2. All other systems on your LAN use the Linux PC as the default
gateway for TCP/IP networking. Use the same ISP-provided DNS
addresses on all systems.

3. Enable IP forwarding in the kernel. By default the IP forwarding


is not enabled. To ensure that IP forwarding is enabled when you
reboot your system, place this command in the /etc/rc.d/rc.local
file.

4. Run /sbin/iptables-the IP packet filter administration program-to


set up the rules that enable the Linux PC to masquerade for your
LAN.

Q) What is the minimum number of partitions you need to install


Linux?

Minimum 2 partitions are needed for installing Linux. The one is /


or root which contains all the files and the other is swap. Linux file
system is function specific which means that files and folders are
organized according to their functionality. For example, all
executables are in one folder, all devices in another, all libraries in
another and so on. / or ‘root’ is the base of this file system. All the
other folders are under this one. / can be consider as C: .Swap is
a partition that will be used as virtual memory. If there is no more
available RAM a Linux computer will use an area of the hard disk,
called swap, to temporarily store data. In other words it is a way of
expanding your computers RAM.

Which command is used to review boot messages?

dmesg command is used to review boot messages. This


command will display system messages contained in the kernel
ring buffer. We can use this command immediately after booting
to see boot messages. A ring buffer is a buffer of fixed size for
which any new data added to it overwrites the oldest data in it. Its
basic syntax is

dmesg [options]

Invoking dmesg without any of its options causes it to write all the
kernel messages to standard output. This usually produces far too
many lines to fit into the display screen all at once, and thus only
the final messages are visible. However, the output can be
redirected to the less command through the use of a pipe, thereby
allowing the startup messages to be viewed on one screen at a
time
dmesg | less

Which utility is used to make automate rotation of a log?

logrotate command is used to make automate rotation of log.


Syntax of the command is:
logrotate [-dv] [-f|] [-s|] config_file+
It allows automatic rotation, compression, removal, and mailing of
log files. This command is mainly used for rotating and
compressing log files. This job is done every day when a log file
becomes too large. This command can also be run by giving on
command line. We can done force rotation by giving –f option with
this command in command line. This command is also used for
mailing. We can give –m option for mailing with this command.
This option takes two arguments one is subject and other is
recipient name.

Q) What are the partitions created on the mail server hard drive?

The main partitions are done firstly which are root, swap and boot
partition. But for the mail server three different partitions are also
done which are as follows:
1. /var/spool- This is done so that if something goes wrong with
the mail server or spool than the output cannot overrun the file
system.
2. /tmp- putting this on its own partition prevents any user item or
software from overrunning the system files.
3. /home- putting this on its own is useful for system upgrades or
reinstalls. It allow not to wipe off the /home hierarchy along with
other areas.

Q) What are the fields in the/etc/passwd file?

It contains all the information of the users who log into the system.
It contains a list of the system's accounts, giving for each account
some useful information like user ID, group ID, home directory,
shell, etc. It should have general read permission as many
utilities, like ls use it to map user IDs to user names, but write
access only for the superuser (root). The main fields of
/etc/passwd file are:
1. Username: It is used when user logs in. It should be between 1
and 32 characters in length.
2. Password: An x character indicates that encrypted password is
stored in /etc/shadow file.
3. User ID (UID): Each user must be assigned a user ID (UID).
UID 0 (zero) is reserved for root and UIDs 1-99 are reserved for
other predefined accounts. Further UID 100-999 are reserved by
system for administrative and system accounts/groups.
4. Group ID (GID): The primary group ID (stored in /etc/group file)
5. User ID Info: The comment field. It allow you to add extra
information about the users such as user's full name, phone
number etc. This field use by finger command.
6. Home directory: The absolute path to the directory the user will
be in when they log in. If this directory does not exists then users
directory becomes /
7. Command/shell: The absolute path of a command or shell
(/bin/bash). Typically, this is a shell.
Which commands are used to set a processor-intensive job to use
less CPU time?

nice command is used for changing priority of the jobs.


Syntax: nice [OPTION] [COMMAND [ARG]...]
Range of priority goes from -20 (highest priority) to 19
(lowest).Priority is given to a job so that the most important job is
executed first by the kernel and then the other least important
jobs. This takes less CPU times as the jobs are scheduled and
are given priorities so the CPU executes fast. The priority is given
by numbers like -20 describe the highest priority and 19 describe
the least priority.

How to change window manager by editing your home directory?

/.xinitrc file allows changing the window manager we want to use


when logging into X from that account. The dot in the file name
shows you that the file is a hidden file and doesn't show when you
do a normal directory listing. For setting a window manager we
have to save a command in this file. The syntax of command is:
exec windowmanager.After this, save the file. Next time when you
run a startx a new window manager will open and become
default. The commands for starting some popular window
managers and desktop environments are:
-KDE = startkde
-Gnome = gnome-session
-Blackbox = blackbox
-FVWM = fvwm
-Window Maker = wmaker
-IceWM = icewm

Q) How documentation of an application is stored?


When a new application is installed its documentation is also
installed. This documentation is stored under the directory named
for application. For example if my application name is App1 then
the path of the documentation will be /user/doc/App1. It contains
all the information about the application. It contains date of
creating application, name of application and other important
module of the application. We can get the basic information of
application from the documentation.

Q) How shadow passwords are given?

pwconv command is used for giving shadow passwords. Shadow


passwords are given for better system security. The pwconv
command creates the file /etc/shadow and changes all passwords
to ‘x’ in the /etc/passwd file. First, entries in the shadowed file
which don't exist in the main file are removed. Then, shadowed
entries which don't have `x' as the password in the main file are
updated. Any missing shadowed entries are added. Finally,
passwords in the main file are replaced with `x'. These programs
can be used for initial conversion as well to update the shadowed
file if the main file is edited by hand.

Q) How do you create a new user account?

useradd command is used for creating a new user account. When


invoked without the
-D option, the useradd command creates a new user account
using the values specified on the command line and the default
values from the system. The new user account will be entered
into the system files as needed, and initial files copied, depending
on the command line options. This command uses the system
default as home directory. If –m option is given then the home
directory is made.
Q) Which password package is installed for the security of central
password?

Shadow password packages are used for security of central


passwords. Security is the most important aspect of every
operating system. When this package is not installed the user
information including passwords is stored in the /etc/passwd file.
The password is stored in an encoded format. These encoded
forms can be easily identified by the System crackers by
randomly encoding the passwords from dictionaries. The Shadow
Package solves the problem by relocating the passwords to
another file (usually /etc/shadow). The /etc/shadow file is set so
that it cannot be read by just anyone. Only root will be able to
read and write to the /etc/shadow file.

Q) Which shell do you assign to a POP3 mail-only account?

POP3 mail only account is assigned to the /bin/false shell.


However, assigning bash shell to a POP3 mail only gives user
login access, which is avoided. /bin/nologin can also be used.
This shell is provided to the user when we don’t want to give shell
access to the user. The user cannot access the shell and it reject
shell login on the server like on telnet. It is mainly for the security
of the shells. POP3 is basically used for downloading mail to mail
program. So for illegal downloading of emails on the shell this
account is assigned to the /bin/false shell or /bin/nologin. These
both shells are same they both do the same work of rejecting the
user login to the shell. The main difference between these two
shells is that false shell shows the incorrect code and any unusual
coding when user login with it. But the nologin shell simply tells
that no such account is available. So nologin shell is used mostly
in Linux.

Q) Which daemon is responsible for tracking events on Linux


system?
syslogd is responsible for tracking system information and save it
to the desired log files. It provides two system utilities which
provide system logging and kernel message trapping. Internet
and UNIX domain sockets support enable this utility package to
support both local and remote logging. Every logged message
contains at least a time and a hostname field, normally a program
name field, too. So to track these information this daemon is
used. syslogd mainly reacts to the set of signals given by the
user. These are the signals given to syslogd: SIGHUP: This lets
syslogd perform a re-initialization. All open files are closed, the
configuration file (default is /etc/syslog.conf) will be reread and the
syslog facility is started again. SIGTERM: The syslogd will die.
SIGINT, SIGQUIT: If debugging is enabled these are ignored,
otherwise syslogd will die. SIGUSR1: Switch debugging on/off.
This option can only be used if syslogd is started with the - d
debug option. SIGCHLD: Wait for Childs if some were born,
because of waiting messages.

Q) Which daemon is used for scheduling of the commands?

The crontab command is used for scheduling of the commands to


run at a later time. SYNTAX
crontab [ -u user ] file
crontab [ -u user ] { -l | -r | -e }

Options
-l List - display the current crontab entries.

-r Remove the current crontab.

-e Edit the current crontab using the editor specified by the


VISUAL or EDITOR environment variables.
When user exits from the editor, the modified crontab will be
installed automatically. Each user can have their own crontab,
and though these are files in /var, they are not intended to be
edited directly. If the –u option is given than the crontab gives the
name of the user whose crontab is to be tweaked. If it is given
without this then it will display the crontab of the user who is
executing the command.

Q) How environment variable is set so that the file permission can


be automatically set to the newly created files?

umask command is used to set file permission on newly created


files automatically.
Syntax
umask [-p] [-S] [mode]
It is represented in octal numbers. We can simply use this
command without arguments to see the current file permissions.
To change the permissions, mode is given in the arguments. The
default umask used for normal user is 0002. The default umask
for the root user is 0022. For calculating the original values, the
values shown by the umask must be subtracted by the default
values. It is mainly used for masking of the file and directory
permission. The /etc/profile script is where the umask command is
usually set for all users. The –S option can be used to see the
current default permissions displayed in the alpha symbolic
format.
For example, umask 022 ensures that new files will have at most
755 permissions (777 NAND 022).
The permissions can be calculated by taking the NAND of original
value with the default values of files and directories.     

Update V1.1.

1.When do you need a virtual hosting ?


The term Virtual Host refers to the practice of maintaining more
than one server on one machine, as differentiated by their
apparent hostname. For example, it is often desirable for
companies sharing a web server to have their own domains, with
web servers accessible
as www.company1.com and www.company2.com, without
requiring the user to know any extra path information.
2.In which port telnet is listening?
23
3.How to get the listening ports which is greater than
6000 using netstat ?
4.How to block and openrelay ?
Open relays are e-mail servers that are configured to accept and
transfer e-mail on behalf of any user anywhere, including
unrelated third parties.
The qmail-smtpd daemon will consult the rcpthosts control file to
determine valid destination addresses, and reject anything else.
5.Q) What is sandwitch configuration in qmail ?
Qmail + Clam + Spamassassin- This is normally called Sandwitch
configuration in qmail.
6.Advantages of Qmail ?
More secure, better designed, modular, faster, more reliable,
easier to configure, don't have to upgrade it every few months or
worry about being vulnerable to something due to some obscure
feature being enabled
qmail supports host and user masquerading, full host hiding,
virtual domains, null clients, list-owner rewriting, relay control,
double-bounce recording, arbitrary RFC 822 address lists, cross-
host mailing list loop detection, per-recipient checkpointing,
downed host backoffs, independent message retry schedules, etc.
qmail also includes a drop-in ``sendmail'' wrapper so that it will
be used transparently by your current UAs.
7.Q) What is the difference between POP3 and IMAP ?
The Difference
POP3 works by reviewing the inbox on the mail server, and
downloading the new messages to your computer. IMAP
downloads the headers of the new messages on the server, then
retrieves the message you want to read when you click on it.
When using POP3, your mail is stored on your PC. When using
IMAP, the mail is stored on the mail server. Unless you copy a
message to a "Local Folder" the messages are never copied to
your PC.
Scenarios of Use
POP3
 You only check e-mail from one computer.
 You want to remove your e-mail from the mail server.
IMAP
 You check e-mail from multiple locations.
 You use Webmail.
8.How to drop packets using iptables ?
Iptables -A INPUT -s xx.xx.xx.xx -d xx.xx.xx.xx -j DROP
9.Daily routines of Linux Administrators ?
*.Check the health of servers
*.Check for updates
*.Check the Backup
*.Check with the trouble ticketing system for any unread ticket.
*.Troubleshoot if there any problem
*.Installation of new servers, if needed.
*.Report to the Boss
10.How to take the Dump of a MySQL Database ?
Mysqldump databasename > dumpname
11.How to know the CPU usage of each process ?
Top, uptime
12.How to bind another IP in a NIC ?
Copy the contents eth0 to eth1, and change the ipaddress.
Restart the network. .
13.Transparently proxy all web-surfing through Squid box
iptables -t nat -A PREROUTING -i eth1 -tcp --dport 80 -j DNAT
--to
iptables -t nat -A PREROUTING -i eth1 -tcp --dport 80 -j DNAT
--to
14.Transparently redirect web connections from outside
to the DMZ web server.
iptables -t nat -A PREROUTING -i eth0 -d 192.168.1.1 -dport 80 -j
DNAT –to
15 Howto Activate the forwarding
echo 1 >/proc/sys/net/ipv4/ip_forward
16.Kill spoofed packets
for f in /proc/sys/net/ipv4/conf/*/rp_filter; do
echo 1 > $f
done.
$iptables -A LDROP --proto tcp -j LOG --log-level info \ --log-
prefix “TCP Drop”

- See more at:


http://www.01world.in/p/linux.html#sthash.xnWJLd62.dpuf

You might also like