Vidyalelo
Computer Science · all questions

Linux
practice.

Practice every MCQ with options. Use Show answers when you want the correct option and solution.

996

Questions

20/50

Page

Pick an option on a question to see the right answer and solution.

What is the output of this program?
#include<stdio.h>
#include<sys/types.h>
#include<sys/socket.h>
 
int main()
{
    int fd;
    fd = socket(AF_UNIX,SOCK_STREAM,0);
    printf("%d\n",fd);
    return 0;
}

Select an option to see the answer and solution.

If one of the thread in multithreaded process is blocked on an I/O, which of the following is true?

Select an option to see the answer and solution.

Ctrl-Z key combination

Select an option to see the answer and solution.

In the output of this program, the string "/* Linux */" will be added at the . . . . . . . . of the source file.
#include<stdio.h>
#include<stdlib.h>
#include<fcntl.h>
 
int main()
{
    int fd;
    fd = open("test.c",O_RDWR|O_APPEND);
    write(fd,"/* Linux */",11);
    return 0;
}

Select an option to see the answer and solution.

What is the return value ($?) of this code:
os = Unix
[$osName = UnixName] && exit 2
[${os}Name = UnixName] && exit 3

Select an option to see the answer and solution.

What is the output of this program?
#include<stdio.h>
#include<pthread.h>
 
void *fun_t(void *arg);
void *fun_t(void *arg)
{       
    printf("%d\n",a);
    pthread_exit("Bye");
}
int main()
{
    int a;  
    pthread_t pt;
    void *res_t;         
    a = 10;
    if(pthread_create(&pt,NULL,fun_t,NULL) != 0)
        perror("pthread_create");
    if(pthread_join(pt,&res_t) != 0)
        perror("pthread_join");
    return 0;
}

Select an option to see the answer and solution.

After running this program, as your press 4, what will be the output of the program?
#!/bin/bash
echo "How many times you want to print 'Example'"
read value
for ((i=0;i<$value;i++))
do
echo "Example";
done
exit 0

Select an option to see the answer and solution.

Which of the following commands allows definition and assignment of environment variables under bash

Select an option to see the answer and solution.

The directory /proc/[PID]/tasks contains

Select an option to see the answer and solution.

What is the output of this program?
#include<stdio.h>
#include<fcntl.h>
 
int main()
{
    int fd;
    char buff[512];
    if( mkfifo("/tmp/test_fifo",0666) == -1)
        perror("mkfifo");       
    fd = open("/tmp/test_fifo",O_RDONLY);
    read(fd,buff,512);
    printf("%s\n",buff);
    return 0;
}

Select an option to see the answer and solution.

Which is an example for character special file?

Select an option to see the answer and solution.

Which one of the following statement is not true?

Select an option to see the answer and solution.

Which command searches the string in file opened in vi editor?

Select an option to see the answer and solution.

What is the output of this program?
#! /usr/bin/awk -f
BEGIN {
    print "20"<"9" ? "true":"false"	      
}

Select an option to see the answer and solution.

What is the output of the program?
#! /usr/bin/awk -f
#This filename is text.awk
BEGIN {
    print FILENAME
}

Select an option to see the answer and solution.

The file /proc/cpuinfo is a collection of

Select an option to see the answer and solution.

Which command is used to mount file system read only.

Select an option to see the answer and solution.

Which one of the following in true about this program?
#include<stdio.h>
#include<stdlib.h>
#include<string.h>                              
 
int main()
{
    char *ptr;
    printf("%p\n",ptr);
    ptr = (char *)malloc(sizeof(char));
    printf("%p\n",ptr);
    return 0;
}

Select an option to see the answer and solution.

If a file with execute permissions set, but with unknown file format is executed

Select an option to see the answer and solution.

If we use a driver for various device files, then

Select an option to see the answer and solution.