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

32/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<pthread.h>
#include<semaphore.h>
 
void *fun_t(void *arg);
void *fun_t(void *arg)
{
    sem_post(&st);
    pthread_exit("Bye");
}
int main()
{
    pthread_t pt;
    sem_t st;
    void *res_t;        
    if(pthread_create(&pt,NULL,fun_t,NULL) == -1)
        perror("pthread_create");
    if(sem_init(&st,0,0) != 0)
        perror("sem_init");
    if(sem_wait(&st) != 0)
        perror("sem_wait");
    printf("Example\n");
    if(pthread_join(pt,&res_t) == -1)
        perror("pthread_join");
    if(sem_destroy(&st) != 0)
        perror("sem_destroy");
    return 0;
}

Select an option to see the answer and solution.

Sysfs represents the

Select an option to see the answer and solution.

In awk, the built-in variable FS is

Select an option to see the answer and solution.

What is the output of this program?
#!/bin/bash
a=10
b=a<0&&$a<100 ))
echo $b
exit 0

Select an option to see the answer and solution.

What is the output of this program?
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<sys/types.h>
#include<sys/ipc.h>
#include<sys/msg.h>

struct data_st{
    long int id;
    char buff[11];
};
int main()
{
    int m_id,ret;
    struct data_st data1, data2;
    m_id = msgget((key_t)181,0666|IPC_CREAT);
    if(m_id == -1)
        perror("msgget");
    data1.id = 1;
    strcpy(data1.buff,"Example");
    ret = msgsnd(m_id,&data1,11,0);
    printf("%d\n",ret);
    if(msgrcv(m_id,&data2,11,1,0) == -1)
        perror("msgrcv");
    if(msgctl(m_id,IPC_RMID,0) != 0)
        perror("msgctl");
    return 0;
}

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)
{
    sleep(1);
}
int main()
{
    pthread_t pt;
    void *res_t;
    if(pthread_create(&pt,NULL,fun_t,NULL) != 0)
        perror("pthread_create");
    if(pthread_join(pt,&res_t) != 0)
        perror("pthread_join");
    printf("%s\n",res_t);
     return 0;
}

Select an option to see the answer and solution.

If user tries to remove (rm) a readonly file (444 permission), what will happen?

Select an option to see the answer and solution.

The user can define a command for GDB with the command

Select an option to see the answer and solution.

On Linux, initrd is a file

Select an option to see the answer and solution.

Which one of the following is not a valid makefile directive?

Select an option to see the answer and solution.

Which command is used to delete the character before the cursor location in vi editor?

Select an option to see the answer and solution.

In sysfs, each represented bus type has two directories named as

Select an option to see the answer and solution.

Which of the following files need to be referred for user's secondary group?

Select an option to see the answer and solution.

What is job number?

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, count;
    fd = open("demo.txt",O_WRONLY|O_CREAT);
    count = write(fd,"Linux System Programming",5);
    if(count != 5)
        perror("write");
    return 0;
}

Select an option to see the answer and solution.

When a device is removed from the system

Select an option to see the answer and solution.

The following commands gives the output like this
#cat file1 file2
#cat: file1: No such file or directory
If we execute the command “cat file1 file2 1>2 2>&1” the output would be

Select an option to see the answer and solution.

Which among the following interacts directly with system hardware?

Select an option to see the answer and solution.

Which one of the following is not a platform specific code?

Select an option to see the answer and solution.

Which one of the following directory contains every physical device that has been discovered by the bus types registered with the kernel?

Select an option to see the answer and solution.