21. Which option of rm command is used to remove a directory with all its subdirectories
22. What is the output of this program?
#include<stdio.h>
#include<stdlib.h>
int main()
{
int ret;
int *ptr;
ptr = (int *)malloc(sizeof(int)*10);
free(ptr);
free(ptr);
return 0;
}
#include<stdio.h>
#include<stdlib.h>
int main()
{
int ret;
int *ptr;
ptr = (int *)malloc(sizeof(int)*10);
free(ptr);
free(ptr);
return 0;
}
23. What is the job of -Werror option in gcc?
24. What is the output of this program?
#!/bin/bash
a=1; b=2; c=3
d=$(( ++a**b*c++ + a ))
echo $d
exit 0
#!/bin/bash
a=1; b=2; c=3
d=$(( ++a**b*c++ + a ))
echo $d
exit 0
25. What is the output of this program?
#! /usr/bin/awk -f
BEGIN {
a=6
do {
print "example"
a++
} while (a<5)
}
#! /usr/bin/awk -f
BEGIN {
a=6
do {
print "example"
a++
} while (a<5)
}
26. What is the output of this program?
#include<stdio.h>
#include<fcntl.h>
int main()
{
int fd, count;
char buff[10];
if (mkfifo("/tmp/test_fifo",0666) != 0)
perror("mkfifo");
fd = open("/tmp/test_fifo",O_RDONLY|O_NONBLOCK);
count = read(fd,buff,10);
printf("%d\n",count);
return 0;
}
#include<stdio.h>
#include<fcntl.h>
int main()
{
int fd, count;
char buff[10];
if (mkfifo("/tmp/test_fifo",0666) != 0)
perror("mkfifo");
fd = open("/tmp/test_fifo",O_RDONLY|O_NONBLOCK);
count = read(fd,buff,10);
printf("%d\n",count);
return 0;
}
27. Which one of the following command can be used to provide executable permissions for a file?
28. The /etc/passwd file doesn't contain
29. System binaries are stored in
30. What is the output of this pogram?
#include<stdio.h>
#include<stdlib.h>
#include<sys/types.h>
#include<sys/ipc.h>
#include<sys/sem.h>
static int sem_p(void);
static int sem_v(void);
union semun{
int val;
struct semid_ds *buf;
unsigned short array;
};
int sem_id;
struct semid_ds myds;
struct sembuf mybuf;
union semun myun;
static int sem_p(void)
{
mybuf.sem_num = 0;
mybuf.sem_op = -1;
mybuf.sem_flg = SEM_UNDO;
semop(sem_id,&mybuf,1);
}
static int sem_v(void)
{
mybuf.sem_num = 0;
mybuf.sem_op = 1;
mybuf.sem_flg = SEM_UNDO;
semop(sem_id,&mybuf,1);
}
int main()
{
int wfd, rfd;
sem_id = semget((key_t)911,1,0666 | IPC_CREAT);
myun.val = 1;
semctl(sem_id,0,SETVAL,myun);
sem_p();
printf("Example\n");
sem_v();
semctl(sem_id,0,IPC_RMID,myun);
return 0;
}
#include<stdio.h>
#include<stdlib.h>
#include<sys/types.h>
#include<sys/ipc.h>
#include<sys/sem.h>
static int sem_p(void);
static int sem_v(void);
union semun{
int val;
struct semid_ds *buf;
unsigned short array;
};
int sem_id;
struct semid_ds myds;
struct sembuf mybuf;
union semun myun;
static int sem_p(void)
{
mybuf.sem_num = 0;
mybuf.sem_op = -1;
mybuf.sem_flg = SEM_UNDO;
semop(sem_id,&mybuf,1);
}
static int sem_v(void)
{
mybuf.sem_num = 0;
mybuf.sem_op = 1;
mybuf.sem_flg = SEM_UNDO;
semop(sem_id,&mybuf,1);
}
int main()
{
int wfd, rfd;
sem_id = semget((key_t)911,1,0666 | IPC_CREAT);
myun.val = 1;
semctl(sem_id,0,SETVAL,myun);
sem_p();
printf("Example\n");
sem_v();
semctl(sem_id,0,IPC_RMID,myun);
return 0;
}
Read More Section(Linux)
Each Section contains maximum 100 MCQs question on Linux. To get more questions visit other sections.