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. What is the output of this program?

  1.    #include<stdio.h>
  2.  
  3.    int main()
  4.    {
  5.        int fd_socket;
  6.        fd_socket = socket(AF_UNIX,SOCK_STREAM,0);
  7.        printf("%dn",fd_socket);
  8.        return 0;
  9.    }

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

View Answer

Answer: d [Reason:] To use socket(), the header files sys/types.h and sys/socket.h are required. Output: [ aidlo]# gcc -o san san.c san.c: In function ‘main’: san.c:6:21: error: ‘AF_UNIX’ undeclared (first use in this function) san.c:6:21: note: each undeclared identifier is reported only once for each function it appears in san.c:6:29: error: ‘SOCK_STREAM’ undeclared (first use in this function) [ aidlo]#

2. In this program, the third argument of the socket() is used for _____ potocol.

  1.    #include<stdio.h>
  2.    #include<sys/types.h>
  3.    #include<sys/socket.h>
  4.    int main()
  5.    {
  6.        int fd_socket;
  7.        if(socket(AF_UNIX,SOCK_STREAM,0) == -1)
  8.            perror("socket");
  9.        return 0;
  10.    }

a) TCP/IP
b) UDP
c) both TCP/IP and UDP
d) none of mentioned

View Answer

Answer: a [Reason:] None.

3. By this program the soket “san_sock” will create

  1.    #include<stdio.h>
  2.    #include<sys/types.h>
  3.    #include<sys/un.h>
  4.    #include<sys/socket.h>
  5.  
  6.    int main()
  7.    {
  8.        struct sockaddr_un add_server;
  9.        int fd_server;
  10.        fd_server = socket(AF_UNIX,SOCK_STREAM,0);
  11.        if(fd_server == -1)
  12.            perror("socket");
  13.        add_server.sun_family = AF_UNIX;
  14.        strcpy(add_server.sun_path,"san_sock");
  15.        if( bind(fd_server,(struct sockaddr*)&add_server,sizeof(add_server)) != 0)
  16.            perror("bind");
  17.        return 0;
  18.    }

a) in the /tmp directory
b) in the /usr directory
c) in the present working directory
d) none of the mentioned

View Answer

Answer: c [Reason:] None. Output: [ aidlo]# ls san.c [ aidlo]# gcc -o san san.c [ aidlo]# ./san [ aidlo]# ls san san.c san_sock [ aidlo]#

4. What is the length of of the queue for pending connections in this program?

  1.    #include<stdio.h>
  2.    #include<sys/types.h>
  3.    #include<sys/un.h>
  4.    #include<sys/socket.h>
  5.  
  6.    int main()
  7.    {
  8.        struct sockaddr_un add_server;
  9.        int fd_server;
  10.        fd_server = socket(AF_UNIX,SOCK_STREAM,0);
  11.        if(fd_server == -1)
  12.            perror("socket");
  13.        add_server.sun_family = AF_UNIX;
  14.        strcpy(add_server.sun_path,"server_sock2");
  15.        if( bind(fd_server,(struct sockaddr*)&add_server,sizeof(add_server)) != 0)
  16.            perror("bind");
  17.        if( listen(fd_server,3) != 0)
  18.            perror("listen");
  19.        return 0;
  20.    }

a) 0
b) 1
c) 2
d) 3

View Answer

Answer: d [Reason:] The second argument of listen() specifies the length for the queue for pending connections.

5. What is the output of the program?

  1.    #include<stdio.h>
  2.    #include<sys/types.h>
  3.    #include<sys/un.h>
  4.    #include<sys/socket.h>
  5.  
  6.    int main()
  7.    {
  8.        struct sockaddr_un add_server, add_client;
  9.        int fd_server, fd_client;
  10.        int len;
  11.        char ch;
  12.        fd_server = socket(AF_UNIX,SOCK_STREAM,0);
  13.        if(fd_server == -1)
  14.            perror("socket");
  15.        add_server.sun_family = AF_UNIX;
  16.        strcpy(add_server.sun_path,"san_sock");
  17.        if( bind(fd_server,(struct sockaddr*)&add_server,sizeof(add_server)) != 0)
  18.            perror("bind");
  19.        if( listen(fd_server,3) != 0)
  20.            perror("listen");
  21.        len = sizeof(add_client);
  22.        fd_client = accept(fd_server,(struct sockaddr*)&add_client,&len);
  23.        printf("Aidlon"); 
  24.        return 0;
  25.    }

a) the program will print the string “Aidlo”
b) the process will remain block
c) segmentation fault
d) none of the mentioned

View Answer

Answer: b [Reason:] There is no peding request in the queue for listening socket “san_sock”. Output: [ aidlo]# gcc -o san san.c [ aidlo]# ./san ^Z [4]+ Stopped ./san [ aidlo]#

6. What is the output of this program?

  1.    #include<stdio.h>
  2.    #include<sys/types.h>
  3.    #include<sys/socket.h>
  4.  
  5.    int main()
  6.    {
  7.        int fd;
  8.        fd = socket(AF_UNIX,SOCK_STREAM,0);
  9.        printf("%dn",fd);
  10.        return 0;
  11.    }

a) 0
b) 1
c) 2
d) 3

View Answer

Answer: d [Reason:] The socket() returns the lowest available file descriptor and in this program i.e. 3. Output: [ aidlo]# gcc -o san san.c [ aidlo]# ./san 3 [ aidlo]#

7. What is the output of this program?

  1.    #include<stdio.h>
  2.    #include<sys/types.h>
  3.    #include<sys/un.h>
  4.    #include<sys/socket.h>
  5.    #include<errno.h>
  6.  
  7.    int main()
  8.    {
  9.        struct sockaddr_un addr;
  10.        int fd;
  11.        fd = socket(AF_UNIX,SOCK_STREAM,0);
  12.        if (fd == -1)
  13.            perror("socket");
  14.        addr.sun_family = AF_UNIX;
  15.        strcpy(addr.sun_path,"san_sock");
  16.        if (bind(4,(struct sockaddr*)&addr,sizeof(addr)) == -1)
  17.            printf("Sanfoudnryn");
  18.        return 0;
  19.    }

a) this program will print the string “Aidlo”
b) this program will not print the string “Aidlo”
c) segmentation fault
d) none of the mentioned

View Answer

Answer: a [Reason:] The first argument of the bind() is not a valid file descriptor in this program. Output: [ aidlo]# gcc -o san san.c [ aidlo]# ./san Sanfoudnry [ aidlo]#

8. What this program is not able to connect with any client program?

  1.    #include<stdio.h>
  2.    #include<sys/types.h>
  3.    #include<sys/un.h>
  4.    #include<sys/socket.h>
  5.  
  6.    int main()
  7.    {
  8.        struct sockaddr_un add_server, add_client;
  9.        int fd_server, fd_client;
  10.        int len;
  11.        char ch;
  12.        fd_server = socket(AF_UNIX,SOCK_STREAM,0);
  13.        if(fd_server == -1)
  14.            perror("socket");
  15.        add_server.sun_family = AF_UNIX;
  16.        strcpy(add_server.sun_path,"san_sock");
  17.        if( bind(fd_server,(struct sockaddr*)&add_server,sizeof(add_server)) != 0)
  18.            perror("bind");
  19.        len = sizeof(add_client);
  20.        fd_client = accept(fd_server,(struct sockaddr*)&add_client,&len);
  21.        printf("Aidlon"); 
  22.        return 0;
  23.    }

a) the listen() is missing
b) the connect() is missing
c) the read() and write() are missing
d) none of the mentioned

View Answer

Answer: a [Reason:] None.

9. What is the output of this program?

  1.    #include<stdio.h>
  2.    #include<sys/types.h>
  3.    #include<sys/un.h>
  4.    #include<sys/socket.h>
  5.  
  6.    int main()
  7.    {
  8.        struct sockaddr_un add_server, add_client;
  9.        int fd_server, fd_client;
  10.        int len;
  11.        char ch;
  12.        fd_server = socket(AF_UNIX,SOCK_STREAM,0);
  13.        if(fd_server == -1)
  14.            perror("socket");
  15.        add_server.sun_family = AF_UNIX;
  16.        strcpy(add_server.sun_path,"san_sock");
  17.        if( bind(fd_server,(struct sockaddr*)&add_server,sizeof(add_server)) != 0)
  18.            perror("bind");
  19.        len = sizeof(add_client);
  20.        fd_client = connect(fd_server,(struct sockaddr*)&add_client,&len);
  21.        printf("Aidlon"); 
  22.        return 0;
  23.    }

a) this program will print the string “Aidlo”
b) segmentation fault
c) error
d) none of the mentioned

View Answer

Answer: c [Reason:] The syntax of the connect() is wrong. connect() should be used in client program only. Ouptut: [ aidlo]# gcc -o san san.c san.c: In function ‘main’: san.c:20:46: warning: passing argument 3 of ‘connect’ makes integer from pointer without a cast [enabled by default] /usr/include/sys/socket.h:129:12: note: expected ‘socklen_t’ but argument is of type ‘int *’ [ aidlo]#

10. What is the output of this program?

  1.     #include<stdio.h>
  2.     #include<sys/types.h>
  3.     #include<netinet/in.h>
  4.     #include<sys/socket.h>
  5.     #include<errno.h>
  6.  
  7.     int main()
  8.     {
  9.         struct sockaddr_in addr;
  10.         int fd;
  11.         fd = socket(AF_UNIX,SOCK_STREAM,0);
  12.         if (fd == -1)
  13.             perror("socket");
  14.         addr.sun_family = AF_UNIX;
  15.         strcpy(addr.sun_path,"san_sock");
  16.         if (bind(4,(struct sockaddr*)&addr,sizeof(addr)) == -1)
  17.             printf("Sanfoudnryn");
  18.         return 0;
  19.     }

a) error
b) “Aidlo”
c) segmentation fault
d) none of the mentioned

View Answer

Answer: a [Reason:] The structure used for AF_UNIX if sockaddr_un. Output: [ aidlo]# gcc -o san san.c san.c: In function ‘main’: san.c:14:6: error: ‘struct sockaddr_in’ has no member named ‘sun_family’ san.c:15:2: warning: incompatible implicit declaration of built-in function ‘strcpy’ [enabled by default] san.c:15:13: error: ‘struct sockaddr_in’ has no member named ‘sun_path’ [ aidlo]#

Linux MCQ Set 2

1. The major number identifies the _____ associated with the device.
a) driver
b) protocol
c) port
d) none of the mentioned

View Answer

Answer: a [Reason:] None.

2. The minor number range should be
a) 0 to 15
b) 0 to 63
c) 0 to 255
d) none of the mentioned

View Answer

Answer: c [Reason:] None.

3. Which one of the following is not true?
a) dynamic allocation of major numbers is not possible
b) major number can not be shared among drivers
c) dynamic allocation of major numbers is not possible & also major number can not be shared among drivers
d) none of the mentioned

View Answer

Answer: c [Reason:] None.

4. In linux kernel 2.4, we can have
a) 256 character drivers only
b) 256 block drivers only
c) 256 character drivers and 256 block drivers at the same time
d) none of the mentioned

View Answer

Answer: c [Reason:] c

5. In we use a driver for N number of files, then we have to create ____ device files.
a) N
b) 1
c) N-1
d) None of the mentioned

View Answer

Answer: a [Reason:] None.

6. If we use a driver for various device files, then
a) minor number will be different for every device file
b) minor number will be same for every device file
c) minor number can not be allocated for any device file
d) none of the mentioned

View Answer

Answer: a [Reason:] None.

7. The connection between the device file and device driver is based on the
a) name of device file
b) number of device file
c) name & number of device file
d) none of the mentioned

View Answer

Answer: b [Reason:] None.

8. In linux kernel 2.1, the minor numbers were used to
a) represnt the sub-functionalitites of the driver
b) identify the driver
c) represent the device files
d) none of the mentioned

View Answer

Answer: a [Reason:] None.

9. The kernel identifies the driver with its
a) module
b) major number
c) device file
d) none of the mentioned

View Answer

Answer: b [Reason:] None.

10. In linux, a device driver can work without the
a) major number
b) minor number
c) device file name
d) none of the mentioned

View Answer

Answer: d [Reason:] None.

Linux MCQ Set 3

1. Operating system kernel must be located in
a) /
b) /boot
c) either in / or in /boot
d) none of the mentioned

View Answer

Answer: c [Reason:] None.

2. Which one of the following is a mount point for a temporarily mounted filesystem?
a) /mnt directory
b) /media directory
c) /dev directory
d) none of the mentioned

View Answer

Answer: a [Reason:] None.

3. What is /root?
a) root filesystem
b) home directory of the root user
c) the directory which contains all the directories of the filesystem
d) none of the mentioned

View Answer

Answer: b [Reason:] None.

4. System binaries are stored in
a) /sbin directory
b) /usr/sbin directory
c) /usr/local/sbin directory
d) all of the mentioned

View Answer

Answer: d [Reason:] None.

5. The /dev directory contains the
a) device drivers
b) device files
c) kernel modules of device drivers
d) none of the mentioned

View Answer

Answer: b [Reason:] None.

6. The contents of root filesystem is responsible to
a) boot the system
b) recover the system
c) repair the system
d) all of the mentioned

View Answer

Answer: d [Reason:] None.

7. Static files of the bootloader are installed in
a) /boot directory
b) /root directory
c) /bin directory
d) /sbin directory

View Answer

Answer: a [Reason:] None.

8. Linux filesystem contains mainly
a) ordinary files
b) device files
c) directory files
d) all of the mentioned

View Answer

Answer: d [Reason:] None.

9. In linux filesystem, the passwords of different users are stored in
a) /etc/passwd file
b) /bin/passwd file
c) /etc/shadow file
d) /bin/shadow file

View Answer

Answer: c [Reason:] Passwords are visible in encrypted format in the file.

10. Superuser can change the _______ permissions of any file.
a) owner
b) group
c) other
d) all of the mentioned

View Answer

Answer: d [Reason:] None.

Linux MCQ Set 4

1. When we install a new package in linux system, then
a) all the files of the packages are installed in a single directory
b) different files are installed at different locations of the file system
c) package works just after extraction, installation is not required
d) none of the mentioned

View Answer

Answer: b [Reason:] None.

2. Host specific configuration files are installed in
a) /etc directory
b) /lib directory
c) /root directory
d) /bin directory

View Answer

Answer: a [Reason:] None.

3. The directory /media is the
a) mount point for removable media
b) mount point for filesystem
c) mount point for removable media & filesystem
d) none of the mentioned

View Answer

Answer: a [Reason:] None.

4. What is /bin/sh ?
a) bourne shell
b) hard or symbolic link to the real shell command
c) bash shell
d) both bash shell and bourne shell

View Answer

Answer: b [Reason:] None.

5. The /boot directory stores the data that is used
a) before the kernel begins executing user mode programs
b) after the kernel begins executing user mode programs
c) before the bootloader is loaded in the RAM
d) none of the mentioned

View Answer

Answer: a [Reason:] None.

6. Which one of the directory does not contain binary files?
a) /bin
b) /sbin
c) /etc
d) none of the mentioned

View Answer

Answer: c [Reason:] None.

7. Kernel modules are present in
a) /lib directory
b) /root directory
c) /boot directory
d) none of the mentioned

View Answer

Answer: a [Reason:] None.

8. The directory /opt is reserved for
a) installation of add-on application software packages
b) optional booting files
c) optional user specific files
d) none of the mentioned

View Answer

Answer: a [Reason:] None.

9. The directory /srv contains
a) site-specific data which is served by the system
b) all the system files
c) all the service files provided by the specific user
d) none of the mentioned

View Answer

Answer: a [Reason:] None.

10. Any file or directory present in the ______ directory may not be reserved between the invocation of the program.
a) /var
b) /tmp
c) /etc
d) all of the mentioned

View Answer

Answer: b [Reason:] None.

Linux MCQ Set 5

1. Write the command to display the current date in the form dd/mm/yyyy.
a) date +%d/%m/%Y
b) date +”%d/%m/%Y”
c) date +/%d/%m/20%y
d) date +”/%d/%m/20%y”

View Answer

Answer: a [Reason:] None.

2. The command syntax to display the file ‘sample.txt’ one page at a time is
a) man sample.txt>more
b) cat sample.txt<more
c) cat sample.txt|more
d) none of the mentioned

View Answer

Answer: c [Reason:] None.

3. Which one shows the name of the operating system?
a) uname -n
b) uname -r
c) uname -o
d) uname –m

View Answer

Answer: c [Reason:] None.

4. How do you add (append) a file “file1” to the example.tar file
a) no you cannot add a file to example.tar
b) tar -cvf example.tar file1
c) tar -rvf file1 example.tar
d) tar -evf file1 example.tar

View Answer

Answer: c [Reason:] None.

5. How to execute ls command inside a vi editor?
a) !ls
b) :ls
c) :!ls
d) we can’t execute

View Answer

Answer: c [Reason:] None.

6. Which command gives the first byte where the difference is in the file1 & file2?
a) diff
b) cmp
c) comm
d) ls -a

View Answer

Answer: b [Reason:] None.

7. To open a file file1 with cursor at line number 4
a) vi +num file1
b) vi +set num file1
c) vi + “set num” file1
d) vi +/se nu file1

View Answer

Answer: a [Reason:] None.

8. sed is a command typically used for
a) Perform complex calculations
b) Perform FIFO based non-blocking I/O
c) Modify/print selective contents of a file
d) None of the mentioned

View Answer

Answer: c [Reason:] None.

9. What communication command provides communication to another user logged on by writing to the bottom of their terminal?
a) talk
b) write
c) chat
d) transmit

View Answer

Answer: a [Reason:] None.

10. Which screen manipulation command sets the screen back to normal?
a) tput cup
b) tput smso
c) tput rmso
d) tput blink

View Answer

Answer: c [Reason:] None.

11. Which command will you use to see the available routes?
a) show route
b) route status
c) netstat -r
d) none of the mentioned

View Answer

Answer: c [Reason:] None.

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