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

13/50

Page

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

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?

Select an option to see the answer and solution.

What this program is not able to connect with any client program?
#include<stdio.h>
#include<sys/types.h>
#include<sys/un.h>
#include<sys/socket.h>
 
int main()
{
    struct sockaddr_un add_server, add_client;
    int fd_server, fd_client;
    int len;
    char ch;
    fd_server = socket(AF_UNIX,SOCK_STREAM,0);
    if(fd_server == -1)
        perror("socket");
    add_server.sun_family = AF_UNIX;
    strcpy(add_server.sun_path,"demo_sock");
    if( bind(fd_server,(struct sockaddr*)&add_server,sizeof(add_server)) != 0)
        perror("bind");
    len = sizeof(add_client);
    fd_client = accept(fd_server,(struct sockaddr*)&add_client,&len);
    printf("Examveda\n"); 
    return 0;
}

Select an option to see the answer and solution.

What is the output of this program?
#include<stdio.h>
#include<fcntl.h>
#include<sys/stat.h>
#include<semaphore.h>
 
int main()
{
    sem_t* sem_id;
    int value;
    sem_id = sem_open("sem_value",O_CREAT,0666,0);
    if(sem_id == SEM_FAILED)
        perror("sem_open");
    if(sem_getvalue(sem_id,&value) == -1)
        perror("sem_getvalue");
    printf("%d\n",value);
    sem_wait(sem_id);
    printf("Examveda\n");
    if(sem_close(sem_id) == -1)
        perror("sem_close");
    return 0;
}

Select an option to see the answer and solution.

Which one of the following is not true?

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("Example\n");
    pthread_exit("Bye");
}
int main()
{ 
    pthread_t pt;
    void *res_t;
    if(pthread_create(&pt,NULL,fun_t,NULL) != 0)                
        perror("pthread_create");
    return 0;
}

Select an option to see the answer and solution.

The process which terminates before the parent process exits becomes

Select an option to see the answer and solution.

Which one of the following is not a valid shell variable?

Select an option to see the answer and solution.

Which call to use to set the resource count of semaphore?

Select an option to see the answer and solution.

The command "make demo" will

Select an option to see the answer and solution.

The command 'ulimit'

Select an option to see the answer and solution.

Pipes are used rather than temporary files for communication between the various stages of compilation in gcc when

Select an option to see the answer and solution.

What is the output of this pogram?
#! /usr/bin/awk -f
BEGIN {
    system("date")
    print "example"
}

Select an option to see the answer and solution.

What is the output of the program?
#! /usr/bin/awk -f
BEGIN {
    a[1]="example"
    a[2]="example"
    for(i=1;i<3;i++) {
        print a[i]
    }
}

Select an option to see the answer and solution.

Effective group id can be set using following permission

Select an option to see the answer and solution.

What is makefile?

Select an option to see the answer and solution.

What is the output of the program?
#! /usr/bin/awk -f
BEGIN {
    a=int(2.5)
    print (a*20)
}

Select an option to see the answer and solution.

What is phony target in the makefile?

Select an option to see the answer and solution.

Which of the following commands can be used to change default permissions for files and directories at the time of creation

Select an option to see the answer and solution.

What is the use of strace command?

Select an option to see the answer and solution.

This program will print the
#include<stdio.h>
#include<sys/time.h>
#include<sys/resource.h>
 
int main()
{
    struct rlimit limit;
    getrlimit(RLIMIT_FSIZE,&limit);
    printf("%lu\n",limit.rlim_cur);
    printf("%lu\n",limit.rlim_max);
    return 0;
}

Select an option to see the answer and solution.