Generic selectors
Exact matches only
Search in title
Search in content
Search in posts
Search in pages
Filter by Categories
nmims post
Objective Type Set
Online MCQ Assignment
Question Solution
Solved Question
Uncategorized

Linux MCQ Set 1

1. In Linux, the static library has the extension of
a) .a
b) .b
c) .c
d) .d

View Answer

Answer: a [Reason:] None.

2. The library contains the
a) pre-compiled object files
b) source files
c) header files
d) none of the mentioned

View Answer

Answer: a [Reason:] None.

3. Libraries can be linked with ____ to create executables.
a) other libraries
b) other object files
c) both other libraries and object files
d) none of the mentioned

View Answer

Answer: c [Reason:] None.

4. In Linux, the static libraries can be created by
a) ar command
b) as command
c) ap command
d) aq command

View Answer

Answer: a [Reason:] None.

5. If a program is linked against a static library then
a) machine code of the used function is copied in the executable
b) used function definition is copied into the preprocessd code
c) used function definition is provided at the time of compiling
d) none of the mentioned

View Answer

Answer: a [Reason:] None.

6. To use the static library in the program
a) header file must be provided to in the source code
b) path for the library must be specified
c) header file must be provided to in the source code & path for the library must be specified
d) none of the mentioned

View Answer

Answer: c [Reason:] None.

7. Which gcc option is used to specify the library?
a) -c
b) -l
c) -a
d) -o

View Answer

Answer: b [Reason:] None.

8. In linux, the static libraries are mostly installed in
a) /usr/lib
b) /usr/local/lib
c) both /usr/lib and /usr/local/lib
d) none of the mentioned

View Answer

Answer: c [Reason:] None.

9. Which one of the following command can list the symbols defined in a library?
a) mn
b) nm
c) nn
d) mm

View Answer

Answer: b [Reason:] None.

10. The archive(ar) utility in linux can
a) create a new static library
b) insert the object files into the static library
c) replace the object files into the static library
d) all of the mentioned

View Answer

Answer: d [Reason:] None.

Linux MCQ Set 2

1. SVR4 was developed by
a) Sun Microsystems
b) AT&T
c) University of Berkeley
d) Sun and AT&T jointly

View Answer

Answer: d [Reason:] None.

2. Which of these is not a Unix Flavor?
a) BSD
b) MAC
c) AIX
d) IRIX

View Answer

Answer: b [Reason:] None.

3. Which of the following statement is FALSE ?
a) Unix supports multiple users
b) Linux is an open source operating system and the source code is shared
c) Shell takes care of inter process communication
d) Shell provides the feature of I/O Redirection

View Answer

Answer: c [Reason:] None.

4. Which of the following UNIX flavor is from IBM?
a) BSD
b) Solaris
c) HP-UX
d) AIX

View Answer

Answer: d [Reason:] None.

5. x86-32 uses which programming model?
a) IP16
b) IP32
c) ILP16
d) ILP32

View Answer

Answer: d [Reason:] None.

6. What are the sizes of (Integer/Long/Pointer) in LP64 programming model?
a) 8/8/8
b) 4/4/8
c) 4/8/8
d) 4/8/4

View Answer

Answer: c [Reason:] None.

7. Which among the following is used to write small programs to control Unix functionalities?
a) Shell Commands
b) Shell Script
c) Filters
d) C Language

View Answer

Answer: b [Reason:] None.

8. What control character signals the end of the input file?
a) ctrl + a
b) ctrl + b
c) ctrl + c
d) ctrl + d

View Answer

Answer: d [Reason:] None.

9. How do you get help about the command “cp”?
a) help cp
b) man cp
c) cd ?
d) none of the mentioned

View Answer

Answer: b [Reason:] None.

Linux MCQ Set 3

1. The $ variables in a shell script context designates
a) The runtime of the script
b) Number of command line arguments
c) PID of the shell running the script
d) The exit status of the shell script

View Answer

Answer: c [Reason:] None.

2. Which variable is used to display number of arguments specified in command line
a) $0
b) $#
c) $*
d) $?

View Answer

Answer: b [Reason:] None.

3. Which variable contains last background job process id
a) $*
b) $?
c) $$
d) $!

View Answer

Answer: d [Reason:] None.

4. Which command can be used to test various file attributes
a) if
b) file
c) test
d) type

View Answer

Answer: c [Reason:] None.

5. * Specifies
a) one or more character
b) zero or more charecter
c) nothing
d) none of the mentioned

View Answer

Answer: b [Reason:] None.

6. ? Specifies
a) one or more character
b) zero or more charecter
c) one character
d) none of the mentioned

View Answer

Answer: c [Reason:] None.

7. Which of the following file set in the current directory are identified by the regular expression a?b*
a) afcc, aabb
b) aabb, axbc
c) abbb, abxy
d) abcd, axbb

View Answer

Answer: b [Reason:] None.

8. What command would send the output of cmd1 to the input of cmd2?
a) cmd1 | cmd2
b) cmd1 || cmd2
c) cmd1 && cmd2
d) cmd1 ; cmd2

View Answer

Answer: a [Reason:] None.

9. What is the output of the following command for bash shell:
echo linux $0
a) linux echo
b) linux linux
c) linux bash
d) linux

View Answer

Answer: c [Reason:] None.

10. Which variable will display the list of the positional parameters?
a) $#
b) $*
c) $?
d) $$

View Answer

Answer: b [Reason:] None.

Linux MCQ Set 4

1. If a program executing in background attempts to read from STDIN
a) It is terminated
b) It’s execution is suspended
c) STDIN is made available to it
d) None of the mentioned

View Answer

Answer: b [Reason:] None.

2. Which command is used to bring the background process to forground?
a) bg
b) fg
c) background
d) forground

View Answer

Answer: b [Reason:] None.

3. How to run a process in the background?
a) &
b) *
c) ?
d) |

View Answer

Answer: a [Reason:] None.

4. Which command can be executed by a user who is already logged into the system, in order to change to the root user? (type the command without any parameters)
a) su
b) root
c) chroot
d) user

View Answer

Answer: a [Reason:] None.

5. Process information in the current shell can be obtained by using
a) kill
b) bg
c) fg
d) ps

View Answer

Answer: d [Reason:] None.

6. Which signal is sent by the command “kill -9 ” ?
a) INT
b) TERM
c) KILL
d) STOP

View Answer

Answer: c [Reason:] None.

7. Which of the following values for STAT column of ps command is not true:
a) status R means running
b) Status S means sleeping
c) Status E means exited
d) Status Z means zombie

View Answer

Answer: c [Reason:] None.

8. When a child process exits before the parent process exits, which of the following is true:
a) the child process becomes defunct
b) the parent process becomes defunct
c) if the parent process does not handle SIGCHLD, the child process becomes a zombie
d) none of the mentioned

View Answer

Answer: c [Reason:] None.

9. A user issues the following command sequence:

    $ a.out &
    $ bash
    $ a.out &

If the user kills the bash process, then which of the following is true?
a) the second a.out process is also terminated
b) the second a.out process becomes a defunct process
c) the first a.out process becomes a zombie process
d) init process becomes parent of second a.out process

View Answer

Answer: d [Reason:] None.

10. The signal sent to a process when the Ctrl-C key is pressed is
a) KILL
b) TSTP
c) TERM
d) INT

View Answer

Answer: d [Reason:] None.

11. we can change the priority of a running process using
a) nice
b) renice
c) priority cannot be changed for a running process
d) only superuser can change the priority

View Answer

Answer: b [Reason:] None.

12. nohup is used to
a) automatically hang up the process after logout
b) continue the process after logout
c) create backgroung process
d) manually hang up the process after logout

View Answer

Answer: b [Reason:] None.

Linux MCQ Set 5

1. What is the output of this program?

  1.    #include<stdio.h>
  2.    #include<fcntl.h>
  3.  
  4.    int main()
  5.    {
  6.        pid_t fd;
  7.        char ch;
  8.        int count;
  9.        fd = open("san.c",O_RDONLY);
  10.        do{
  11.            count = read(fd,&ch,1);
  12.            printf("%c",ch);
  13.        }while(count);
  14.        return 0;
  15.    }

a) it will print nothing
b) it will print the source code of the source file “san.c”
c) segmentation fault
d) none of the mentioned

View Answer

Answer: b [Reason:] none. Output: [ aidlo]# gcc -o san san.c [ aidlo]# ./san

  1. #include<stdio.h>
  2. #include<fcntl.h>
  3.  
  4. int main()
  5. {
  6.         int fd, count;
  7.         char ch;
  8.         fd = open("san.c",O_RDONLY);
  9.         do{
  10.                 count = read(fd,&ch,1);
  11.                 printf("%c",ch);
  12.         }while(count);
  13. }

[ aidlo]#

2. What is the output of this program?

  1.    #include<stdio.h>
  2.    #include<fcntl.h>
  3.  
  4.    int main()
  5.    {
  6.        int fd, count;
  7.        fd = open("aidlo.txt",O_WRONLY|O_CREAT);
  8.        count = write(fd,"Linux System Programming",5);
  9.        if(count != 5)
  10.            perror("write");
  11.        return 0;
  12.    }

a) it will create a file “aidlo.txt” in the present working directory
b) it will write the string “Linux System Programming” in the file “aidlo.txt”
c) all of the mentioned
d) none of the mentioned

View Answer

Answer: a [Reason:] This program will write only “Linux” in the file “aidlo.txt” because we are writing only 5 bytes with “write” system call. Output: [ aidlo]# gcc -o san san.c [ aidlo]# ls san san.c [ aidlo]# ./san [ aidlo]# ls san san.c aidlo.txt [ aidlo]# vim aidlo.txt [ aidlo]#

3. What is the output of this program?

  1.    #include<stdio.h>
  2.    #include<fcntl.h>
  3.  
  4.    int main()
  5.    {     
  6.        int fd, count;
  7.        fd = open("san.c",O_RDONLY);
  8.        count = write(fd,"Linux",5);
  9.        if(count != 5)
  10.            perror("write");
  11.        return 0;
  12.    }

a) it will write the string “Linux” in the beginning of source file “san.c”
b) it will write the string “Linux” in the end of the source file “san.c”
c) segmentation fault
d) none of the mentioned

View Answer

Answer: d [Reason:] This program will write nothing in the source file “san.c” because we are opening the file in read only mode. Output: [ aidlo]# gcc -o san san.c [ aidlo]# ./san write: Bad file descriptor [ aidlo]#

4. What is the output of this program?

  1.    #include<stdio.h>
  2.    #include<stdlib.h>
  3.    #include<fcntl.h>
  4.  
  5.    int main()
  6.    {
  7.        int fd, count;
  8.        char ch, *buff;
  9.        buff = (char *)malloc(sizeof(char)*10);
  10.        fd = open("san.c",O_RDONLY);
  11.        count = read(fd,buff,5);
  12.        printf("%dn",count);
  13.        return 0;
  14.    }

a) 5
b) 10
c) 0
d) -1

View Answer

Answer: a [Reason:] The “read” system call returns the number of bytes successfully read. Output: [ aidlo]# gcc -o san san.c [ aidlo]# ./san 5 [ aidlo]#

5. In the output of this program, the string “/* Linux */” will be added at the ____ of the source file.

  1.    #include<stdio.h>
  2.    #include<stdlib.h>
  3.    #include<fcntl.h>
  4.  
  5.    int main()
  6.    {
  7.        int fd;
  8.        fd = open("san.c",O_RDWR|O_APPEND);
  9.        write(fd,"/* Linux */",11);
  10.        return 0;
  11.    }

a) end
b) beginning
c) second line
d) third line

View Answer

Answer: a [Reason:] The write system call writes at the end of the file because the file is opened with O_APPEND flag. Output: [ aidlo]# gcc -o san san.c [ aidlo]# ./san [ aidlo]# vim san.c [ aidlo]#

6. What is the output of this program?

  1.    #include<stdio.h>
  2.    #include<stdlib.h>
  3.    #include<fcntl.h>
  4.  
  5.    int main()
  6.    {
  7.        int fd;
  8.        char *buff;
  9.        buff = (char *)malloc(sizeof(char)*5);
  10.        fd = open("aidlo.txt",O_RDWR|O_CREAT); 
  11.        write(fd,"Linux",5);
  12.        read(fd,buff,5);
  13.        printf("%sn",buff);
  14.    }

a) it will print nothing
b) it will print the string “Linux”
c) segmentation fault
d) none of the mentioned

View Answer

Answer: a [Reason:] We have to use “lseek” system call if we want to read the file from the beginning just after writing into it. Output: [ aidlo]# gcc -o san san.c [ aidlo]# ls san san.c [ aidlo]# ./san

[ aidlo]# ls san san.c aidlo.txt [ aidlo]# vim aidlo.txt [ aidlo]#

7. What is the output of this program?

  1.    #include<stdio.h>
  2.    #include<fcntl.h>
  3.  
  4.    int main()
  5.    {
  6.        int fd, count;
  7.        char ch;
  8.        fd = open("aidlo.txt",O_RDWR|O_CREAT);
  9.        write(fd,"s",1);
  10.        lseek(fd,0,SEEK_SET);
  11.        write(fd,"d",1);
  12.        lseek(fd,0,0);
  13.        read(fd,&ch,1);
  14.        printf("%cn",ch);
  15.        return 0;
  16.    }

a) d
b) s
c) sd
d) none of the mentioned

View Answer

Answer: d [Reason:] Because of “lseek” system call the character “s” is overwritten by character “d” in the file “aidlo.txt”. Output: [ aidlo]# gcc -o san san.c [ aidlo]# ./san d [ aidlo]#

8. What is the output of this program?

  1.    #include<stdio.h>
  2.    #include<fcntl.h>
  3.  
  4.    int main()
  5.    {
  6.        int fd, count;
  7.        char ch[10];
  8.        fd = open("aidlo.txt",O_RDWR|O_CREAT);
  9.        write(fd,"linux",5);
  10.        lseek(fd,2,SEEK_END);
  11.        write(fd,"san",3);
  12.        lseek(fd,0,0);
  13.        count = read(fd,ch,10);
  14.        printf("%sn",ch);
  15.        return 0;
  16.    }

a) linux
b) linuxsan
c) linux san
d) none of the mentioned

View Answer

Answer: a [Reason:] The lseek function allows the file offset to be set beyond the end of the file and if the data is latter written this point, subsequent reads of the data in the gap returns NULL. Output: [ aidlo]# gcc -o san san.c [ aidlo]# ./san linux [ aidlo]#

9. What is the output of this program?

  1.    #include<stdio.h>
  2.    #include<stdlib.h>
  3.    #include<fcntl.h>
  4.  
  5.    int main()
  6.    {
  7.        int fd, new_fd;
  8.        char *buff;
  9.        buff = (char *)malloc(sizeof(char)*8);
  10.        fd = open("san.c",O_RDONLY);
  11.        new_fd = dup(fd);
  12.        close(fd);
  13.        read(new_fd,buff,8);
  14.        printf("%sn",buff);
  15.    }

a) this program will not print anything
b) this program will print “#include”
c) this program will give the segmentation fault
d) this program will give the syntax error

View Answer

Answer: b [Reason:] The “dup” system creates the a copy of the file descriptor. Output: [ aidlo]# gcc -o san san.c [ aidlo]# ./san #include [ aidlo]#

10. What is the output of this program?

  1.     #include<stdio.h>
  2.     #include<fcntl.h>
  3.  
  4.     int main()
  5.     {
  6.         int fd, fd2, ret;
  7.         fd = open("san.c",O_RDONLY);
  8.         ret = close(fd2);
  9.         printf("%dn",ret);
  10.     }

a) 0
b) 1
c) -1
d) none of the mentioned

View Answer

Answer: c [Reason:] The “close” system call closes a file descriptor but in the program “fd2” in not a file descriptor. Hence close system call returns -1. Output: [ aidlo]# gcc -o san san.c [ aidlo]# ./san -1 [ aidlo]#

.woocommerce-message { background-color: #98C391 !important; }