11. What is the output of this program?
#!/bin/bash
var[1]=hello_1
var[2]=hello_2
var[3]=hello_3
echo ${var[*]}
exit 0
#!/bin/bash
var[1]=hello_1
var[2]=hello_2
var[3]=hello_3
echo ${var[*]}
exit 0
12. The command "gcc -S demo.c" will
13. The statement z = 'expr 5 / 2' would store which of the following values in z?
14. This program will create . . . . . . . . child processes?
#include<stdio.h>
#include<unistd.h>
int main()
{
fork();
fork();
fork();
printf("Example\n");
return 0;
}
#include<stdio.h>
#include<unistd.h>
int main()
{
fork();
fork();
fork();
printf("Example\n");
return 0;
}
15. The COFF stands for
16. The kill system call is used to
17. Which GDB command interrupts the program whenever the value of a variable is modified and prints the value old and new values of the variable?
18. What is the output of second program if we run the demo1 first and after that we run demo2 in the different terminal?
/*This is demo1.c*/
#include<stdio.h>
#include<sys/ipc.h>
#include<sys/shm.h>
#include<string.h>
int main()
{
int shm_id;
char *addr;
struct shmid_ds ds;
shm_id = shmget((key_t)1234,10,0666|IPC_CREAT);
if(shm_id == -1){
perror("shmget");
}
addr = (char*)shmat(shm_id,NULL,SHM_RND);
if(addr == (char *)-1){
perror("shmat");
}
strcpy(addr,"Example");
if (shmdt(addr) != 0){
perror("shmdt");
}
sleep(10);
if( shmctl(shm_id,IPC_RMID,0) == -1){
perror("shmctl");
}
return 0;
}
/*This is demo2.c*/
#include<stdio.h>
#include<sys/ipc.h>
#include<sys/shm.h>
int main()
{
int shm_id;
char *addr;
struct shmid_ds ds;
shm_id = shmget((key_t)111,10,0666|IPC_CREAT);
if(shm_id == -1){
perror("shmget");
}
addr = (char*)shmat(shm_id,NULL,SHM_RND);
if(addr == (char *)-1){
perror("shmat");
}
printf("%s\n",addr);
if (shmdt(addr) != 0){
perror("shmdt");
}
return 0;
}
/*This is demo1.c*/
#include<stdio.h>
#include<sys/ipc.h>
#include<sys/shm.h>
#include<string.h>
int main()
{
int shm_id;
char *addr;
struct shmid_ds ds;
shm_id = shmget((key_t)1234,10,0666|IPC_CREAT);
if(shm_id == -1){
perror("shmget");
}
addr = (char*)shmat(shm_id,NULL,SHM_RND);
if(addr == (char *)-1){
perror("shmat");
}
strcpy(addr,"Example");
if (shmdt(addr) != 0){
perror("shmdt");
}
sleep(10);
if( shmctl(shm_id,IPC_RMID,0) == -1){
perror("shmctl");
}
return 0;
}
/*This is demo2.c*/
#include<stdio.h>
#include<sys/ipc.h>
#include<sys/shm.h>
int main()
{
int shm_id;
char *addr;
struct shmid_ds ds;
shm_id = shmget((key_t)111,10,0666|IPC_CREAT);
if(shm_id == -1){
perror("shmget");
}
addr = (char*)shmat(shm_id,NULL,SHM_RND);
if(addr == (char *)-1){
perror("shmat");
}
printf("%s\n",addr);
if (shmdt(addr) != 0){
perror("shmdt");
}
return 0;
}
19. The result of an expression can be assigned to an environement variable with the command
20. Kernel modules are present in
Read More Section(Linux)
Each Section contains maximum 100 MCQs question on Linux. To get more questions visit other sections.