WISH YOU A HAPPY NEW YEAR - 2015 Blogger WidgetsHi Friends.....This Is Naresh Pirati >>>>> WELCOME TO MY NEW BLOG WORLD>>>>>>>You Can DOWNLOAD Interview Questions ,Puzzles and Text Books from This BLOG>>>>>>>>>>> Thank You For Visiting My BLOG I Hope you Will VIstit Again For New Updates

Linux




LINUX INTERVIEW QUESTIONS 





1. What is a context switch?
a) Kernel switches from executing one process to another.
b) Process switches from kernel mode to user mode.
c) Process switches from user mode to kernel mode.
d) None of the above
View Answer
Answer:a
2. Pid of init process
a) 0                      
b) 1
c) 32767           
d) none of the above
View Answer
Answer:b
3. What is the default maximum number of processes that can exist in Linux?
a) 32768   
b) 1024             
c) 4096   
d) unlimited
View Answer
Answer:a
4. How do you get parent process identification number?
a) waitpid
b) getpid()
c) getppid()
d) parentid()
View Answer
Answer:c
5. Parent process id of a deamon process is_________________.
View Answer
Answer:1
6. The process which terminates before the parent process exits becomes
a) Zombie
b) Orphan
c) Child
d) None of the above
View Answer
Answer:a
7. Return value of fork() system call can be:
a) -1,<0,0
b) -1,>0,0
View Answer
Answer:b
8. If the fork() system call returns -1, then it means?
a) No new child process is created
b) The child process is an orphan
c) The child process is in Zombie
View Answer
Answer:a
9. Fork returns _____ to parent process on success
a) 0
b) child process id
c) parent process id
d) none
View Answer
Answer:b
10. How many times printf() will be executed in the below mentioned program?
    main() {
        int i;
        for (i = 0; i < 4; i++)
        fork();

        printf(“my pid = %d\n”, getpid());
    }
a) 4
b) 8
c) 16
d) 32
View Answer
Answer:c
11. What is the output of the below code?
    void exit_handler1();
    void exit_handler2();
    int main() {
        int pid;
        atexit(exit_handler1);
        atexit(exit_handler2);
        pid = fork();
        if(pid == 0) {
           _exit(0);
        } else {
            sleep(2);
            exit(0);
        }
        return 0;
    }
a) Only child executes the exit_handler 1 and 2.
b) Only parent executes the exit_handler 1 and 2.
c) Both parent and child executes the exit_handler 1 and 2.
d) Neither parent nor child executes the exit_handler 1 and 2.
View Answer
Answer:b
12. What is output of the following program?
    
    int main() {
        fork();
        fork();
        fork();
        if (wait(0) == -1)
            printf(“leaf child\n”);
    }
a) “leaf child” will be printed 1 times
b) “leaf child” will be printed 3 times
c) “leaf child” will be printed 4 times
d) “leaf child” will be printed 8 times
View Answer
Answer:c
13. Which niceness value among the following indicate most favorable scheduling?
a) 0  
b)  20 
c)  5   
d)  -19
View Answer
Answer:d
14. The maximum time slice that can be given to a process in Linux (where tick is 10ms) is
a) 150ms
b) 10ms
c) 300 ms
d) 600ms
View Answer
Answer:d
15. Nice can be used by an ordinary process to
a) increase the priority of a process
b) decrease the priority of a process
c) increase or decrease the priority of a process
View Answer
Answer:b
16. Which one can be a real time schedule policy?
a) SCHED_FIFO
b) SCHED_SPF
c) SCHED_OTHER
d) SCHED_FILO
View Answer
17. In Linux kernel-2.6 Real time priority ranges from
a) 0 to 99
b) 0 to 139
c) -20 to 19
d) 100 to 139
View Answer
Answer:a
18. Solaris real time class priority is
a) 0-59
b) 60-99
c) 100-159
d) 160-169
View Answer
Answer:c
19. Solaris System class priority is
a) 0-59
b) 60-99
c) 100-159
d) 160-169
View Answer
Answer:b
Memory Management
1. On x86-32 Linux, at which address the code segment of the program starts?
a) 0×00000000
b) 0×08048000
c) 0×80000000
d) 0xbfff0000
View Answer
Answer:b
2. On x86-32 Linux, at which address the user stack resides normally?
a) 0×00000000
b) 0x3fff0000
c) 0x7fff0000
d) 0xbfff0000
View Answer
Answer:d
3. A system has 512MB of physical memory. Which among the following is not a suitable virtual memory size for this system architecture?
a) 512MB
b) 256M
c) 4GB
d) None of the above
View Answer
Answer:d
4. LRU stands for
a) Last received Unit  
b) Least recently Used
c) Least recently usable
d) Lost Recoverd unit
View Answer
Answer:b
5. Mm_struct maintains?
a) memory files
b) open files
c) pipe
d) active memory regions
View Answer
Answer:d
6. Which sytem call can be used by a user process to lock a memory so that it cannot be swapped out?
View Answer
Answer:memlock()
7. Is page table per process entity?
a) Yes
b) No
View Answer
Answer:a
8. Among these files which has an ELF format
a) shared objects
b) core
c) executables
d) all of the above
View Answer
Answer:d
9. What is the use of strace command?
View Answer
Answer:strace can be used to check the system calls called by the program. So, this can be used for debugging and benchmarking purposes
10. If one of the thread in multithreaded process is blocked on an I/O, which of the following is true?
a) The entire process with block if their is no kernel supported threads
b) Other threads of the process will continue to execute even if there is no kernel supported threads
c) It depends on specific implementatation
d) All of the above
View Answer
Answer:a
File Management 1
1. Each process has unique
a) fd table
b) file table
c) inode table
d) data block table
View Answer
Answer:a
2. File descriptor table indexes which kernel structure?
a) struct file
b) strruct fs_struct
c) files_struct
d) struct inode
View Answer
Answer:a
3. What is the default number of files open per user process?
a) 0
b) 1
c) 2
d) 3
View Answer
Answer:d
4. The file system information is stored in
a) Boot block
b) Super Block
c) Inode Table
d) Data Block
View Answer
Answer:b
5. Switch table is used by
a) device special file
b) directory file
c) fifo
d) link file.
View Answer
Answer:a
6. What is the use of fcntl function?
a) locking a file
b) reading the file descriptor flag
c) changing the file status flag
d) all the above
View Answer
Answer:d
7. Which function can be used instead of the dup2 to duplicate the file descriptor?
a) read()
b) open()
c) stat()
d) fcntl()
View Answer
Answer:d
8. printf() uses which system call
a) open
b) read
c) write
d) close
View Answer
Answer:c
9. read() system call on success returns
a) 0
b) -1
c) number of character
d) none
View Answer
Answer:c
10. Which system call is used to create a hard link?
a) hardlink
b) link
c) symlink
d) ln
View Answer
Answer:b
11. namei() is
a) ANSI C library function
b) C library function
c) System call
d) kernel routine
View Answer
Answer:d
12. dup2(1,0)
a) closes the stdout and copies the stdin descriptor to stdout
b) closes the stdin and copies the stdout descriptor to stdin
c) will produce compilation error
d) None of the above
View Answer
Answer:b
File Management 2
1. Given a code snippet below?
#define PERMS (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)
int main() {
int fd1, fd2;
umask(0);
fd1 = open(“file1”, O_CREAT | O_RDWR, PERMS)
umask(S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
fd2 = open(“file2”, O_CREAT | O_RDWR, PERMS)
return 0;
}
The newly created files file1 and file2 will have the permissions respectively
a) rw-rw-rw- r——–
b) r——– rw-rw-rw-
c) rw-rw-rw- rw——-
d) None of the above
View Answer
Answer:c
2. Below is the code
int main() {
int fd1, fd2;
struct stat buff1, buff2;
fd1 = open(“1.txt”, O_RDWR);
fd2 = open(“2.txt”, O_RDWR | O_APPEND);
lseek(fd1, 10000, SEEK_SET);
write(fd1, “abcdefghij”, 10);
write(fd2, “abcdefghij”, 10);
fstat(fd1, &buff1);
fstat(fd2, &buff2);
printf(“ %d %d”, buff1.st_size, buff2.st_size);
return 0;
}
Before running the program, the file 1.txt and 2.txt size is 20 each. What is the output?
a) 30 30
b) 100020 20
c) 100030 30
d) 100010 30
View Answer
Answer:d
3. What is stored in logfile as per below mentioned code if we execute ./a.out > logfile?
int main() {
int fd;
close(1);
fd = open(“logfile”,O_RDWR, 0744);
write(fd, “Hello”, 5);
printf(“World\n”);
return 0;
}
a) Hello
b) HelloWorld
c) World
d) None
View Answer
Answer:b
4. For the below mentioned code,
int main() {
int fd;
fd = open(“logfile”, O_CREAT|O_RDWR, 0600);
lseek(fd, 5, SEEK_CUR);
write(fd, “Hello”, 5);
return 0;
}
What is the logfile size now if it’s initially was 1024 bytes?
a) 5
b) 1024
c) 1029
d) 1034
View Answer
Answer:b
5. Code snippets
str1=”45678\n”
str2=”123\n”
f1 = fopen(file1,RDWR,RWX)
f2 = fopen(file1,RDWR,RWX)
write(f1,str1,len_str1)
write(f2,str2,len_str2)
o/p:
a) 12378
b) 123(newline)8(newline)
c) 123(newline)78(newline)
d) 45678(newline)123(newline)
View Answer
Answer:b
6. Code snippets
str1=”45678\n”
str2=”123\n”
f1 = fopen(file1,RDWR,RWX)
f2 = dup(f1)
write(f1,str1,len_str1)
write(f2,str2,len_str2)
o/p:
a) 12378
b) 123(newline)8(newline)
c) 123(newline)78(newline)
d) 45678(newline)123(newline)
View Answer
Answer:d
7. Code snippet (file1 size is 2024)
f1 = fopen (file1, RDWR, RWX)
lseek(f1,1024,SEEK_SET)
write(f1,buf,10)
What is offset now.
a) 1024
b) 1034
c) 2034
d) 2054
View Answer
Answer:b
Signal Handling
1. If a signal is received by a process, when will it be processed?
a) It is processed immediately
b) It is processed when process is switching to kernel mode
c) It is processsed in the next timeslice given to the process
View Answer
Answer:b
2. Which signal is generated when we press control-C?
a) SIGINT
b) SIGTERM
c) SIGKILL
d) SIGSEGV
View Answer
Answer:a
3. Which signal is generated when we press ctrl-Z?
a) SIGKILL 
b) SIGSTOP       
c) SIGABRT       
d) SIGINT
View Answer
Answer:d
4. Which signal is sent when the Child process terminates?
a) SIGINIT
b) SIGKILL
c) SIGSTOP
d) SIGCHLD
View Answer
Answer:b
5. Which of the following signal cannot be handled or ignored?
a) SIGINT
b) SIGCHLD
c) SIGKILL
d) SIGALRM
View Answer
Answer:c
6. Another signal that cannot be caught is:
a) SIGPIPE
b) SIGHUP
c) SIGSTOP
d) SIGUSR1
View Answer
Answer:c
7. When real interval timer expires which signal is generated?
a) SIGINT
b) SIGCHLD
c) SIGKILL
d) SIGALRM
View Answer
Answer:d
8. Signals are handled using which system call?
a) kill
b) signal
c) both
d) none
View Answer
Answer:b
9. Default action of SIGSEGV is
a) Terminate
b) Core dump
c) Stop
d) Cont
View Answer
Answer:b
10. The kill system call is used to
a) Send shutdown messages to all by superuser
b) Send a signal to a process
c) Kill processes
d) Stop the processes
View Answer
Answer:b
11. What is the output of the below code?
    void sig_handler ( int signum) {
        printf(“Handled the signal\n”);
    }
    int main() {
        int pid;
        signal (SIGKILL, sig_handler);
        pid = fork();
        if (pid==0) {
            kill(getppid(), SIGKILL);
            exit(0);
        } else {
            sleep(20);
        }
        return 0;
    }
a) Error child cannot send a SIGKILL signal to parent.
b) Parent goes to the signal handler, prints handled the signal and goes back to sleep
c) Parent goes to the signal handler, prints handled the signal and exits
d) Parent exits without going to the signal handler
View Answer
Answer:d
IPC – 1
1. Which is true regarding pipes?
a) half duplex
b) full duplex
c) message boundaries are preserved
d) Unordered data
View Answer
Answer:a
2. The persistancy of a FIFO is
a) process
b) kernel
c) file system
d) none
View Answer
Answer:c
3. Advantage of FIFO over pipe is
a) related processes can communicate
b) unrelated processes can communicate
c) none
View Answer
Answer:b
4. What mkfifo() creats?
a) pipe   
b) unnamed pipe
c) named pipe   
d) msg queue
View Answer
Answer:c
5. System V IPC common attributes are
a) key
b) id
c) owner
d) all the above
View Answer
Answer:d
6. Which one of the following is not system V IPC ?
a) Shared Memory
b) Semaphores
c) FIFO
d) Message Queues
View Answer
7. Which system call is used to create Sys V message Queue.
a)  msgget   
b)  shemget
c)  semget
d)  msgctl
View Answer
Answer:a
8. Which is not the correct option for removing a message queue
a) ipcrm -Q
b) ipcrm -q
c) ipcrm -m
d) None
View Answer
Answer:c
9. Message queues are created in
a) userspace
b) kernelspace
c) both
d) none
View Answer
Answer:b
IPC – 2
1. Command used to check shared memory is
a) ipcs
b) ipcs  -m
c) ipcs  -s
d) ipcs  -q
View Answer
Answer:b
2. Which is Fastest IPC?
a) Message Queue
b) shared memory
c) Socket
d) all
View Answer
Answer:b
3. What is the persistancy level of Shared memory segments?
a) signal
b) process
c) file system
d) kernel
View Answer
Answer:d
4. The structure which keeps the information about shared memory in  the kernel is
a) struct ipc_perm
b) struct semid_ds
c) struct shmid_ds
d) struct msgid_ds
View Answer
Answer:c
5. One process requires M resource to complete a job. What should be the minimum number of resources available for N processes so that at least one process can continue to execute without blocking/waiting?
a) M * N
b) M * N – 1
c) M * N + 1
d) M
View Answer
Answer:d
6. Semaphore P( ) operation usually does the following:
a) descrements the semaphore count and the process sleeps if needed
b) increments the semaphore count
c) wakes up a sleeping process
View Answer
Answer:a
7. Which call to use to set the resource count of semaphore?
a) semget( )
b) semctl( )
c) sem_setcount( )
d) sem_set_count( )
View Answer
Answer:d
8. Race condition can be avoided by using
a) semaphore
b) mutex
c) Socket
d) both a & b
View Answer
Answer:d
9. A server which is handling one client at a time is called as
a) single server
b) multiserver
c) concurrent server
d) iterative server
View Answer
Answer:d
10. A server which is handling many clients at a time is called as
a) single server
b) multiserver
c) concurrent server
d) iterative server
View Answer
Answer:c
11. A communication end-point is identified by
a) IP address
b) port number
c) both a and b
d) none
View Answer
Answer:c
Linux Systems
1. UNIX/Linux kernel is?
a) Monolithic
b) micro
c) Exo
d) nano
View Answer
Answer:a
2. Monolithic kernel
a) is highly extensiblity
b) has less run time overhead
c) smaller than micro level
d) Suitable for real time system
View Answer
Answer:b
3. Runlevel system command is used for?
a) getting the present and previous runlevel of the system
b) setting the runlevel attribute of the system in the inittab file
c) can be used to restart or reboot the system
d) all of the above
View Answer
Answer:d
4. Pick the run level to run Linux in multi user mode with networking?
a) 0
b) 3
c) 5
d) 6
View Answer
Answer:b
5. Section 2 of manpage describes
a) Commands
b) System calls
c) Function calls
d) Drivers
View Answer
Answer:b
6. System call can be implemented using which assembly instruction(s) on x86 processors?
a) int 0×80
b) sysenter
c) both a & b
d) None
View Answer
Answer:c
7. Which of the following exec call is a system call?
a) execl
b) execlp
c) execve
d) execvp
View Answer
Answer:c
8. x86 architecture uses big endian or little endian addressing mechanism?
View Answer
Answer::little-endian
9. ______________ timer is decremented only when the process is executing
a) ITIMER_REAL
b) ITIMER_VIRTUAL
c) ITIMER_PROF
d) None of the above
View Answer
Answer:b
10. Daemon process is a?
a) group leader
b) session leader
c) orphan process
d) all the above
View Answer
Answer:d
11. The terminal used by a Daemon process is:
a) any terminal
b) no terminal
b) root terminal
d) system console
View Answer
Answer:b
12. shared memory can be used for?
a) read only operations
b) append
c) read or read write operations
d) write only
View Answer

Answer:c

No comments: