1. GDB command "frame" is used
2. What is the difference between the built-in functions rand() and srand() in awk programming?
3. System call can be implemented using which assembly instruction(s) on x86 processors?
4. We can list all the breakpoint in GDB by the command
5. A user does a chmod operation on a file. Which of the following is true?
6. What is the output of this program?
#include<stdio.h>
#include<fcntl.h>
#include<sys/stat.h>
#include<sys/mman.h>
int main()
{
int s_id;
int *ptr;
s_id = shm_open("shared_mem",O_CREAT|O_RDWR,0666);
if(s_id == -1)
perror("shm_open");
ptr = mmap(NULL,100,PROT_WRITE,MAP_PRIVATE,s_id,0);
if(ptr == MAP_FAILED);
perror("mmap");
if(munmap(ptr,100) == -1)
perror("munmap");
if(shm_unlink("shared_mem") == -1)
perror("shm_unlink");
return 0;
}
#include<stdio.h>
#include<fcntl.h>
#include<sys/stat.h>
#include<sys/mman.h>
int main()
{
int s_id;
int *ptr;
s_id = shm_open("shared_mem",O_CREAT|O_RDWR,0666);
if(s_id == -1)
perror("shm_open");
ptr = mmap(NULL,100,PROT_WRITE,MAP_PRIVATE,s_id,0);
if(ptr == MAP_FAILED);
perror("mmap");
if(munmap(ptr,100) == -1)
perror("munmap");
if(shm_unlink("shared_mem") == -1)
perror("shm_unlink");
return 0;
}
7. This program can send the request to
#include<stdio.h>
#include<netinet/in.h>
#include<sys/types.h>
#include<sys/socket.h>
int main()
{
int fd_client,fd, len;
struct sockaddr_in add_server;
fd_client = socket(AF_INET,SOCK_STREAM,0);
if (fd_client == -1)
{
perror("fd_sock");
exit(1);
}
add_server.sin_family = AF_INET;
add_server.sin_port = ntohs(4001);
add_server.sin_addr.s_addr = inet_addr("193.39.0.4");
len = sizeof(add_server);
fd = connect(fd_client,(struct sockaddr*)&add_server,len);
if(fd == -1)
perror("connect");
return 0;
}
#include<stdio.h>
#include<netinet/in.h>
#include<sys/types.h>
#include<sys/socket.h>
int main()
{
int fd_client,fd, len;
struct sockaddr_in add_server;
fd_client = socket(AF_INET,SOCK_STREAM,0);
if (fd_client == -1)
{
perror("fd_sock");
exit(1);
}
add_server.sin_family = AF_INET;
add_server.sin_port = ntohs(4001);
add_server.sin_addr.s_addr = inet_addr("193.39.0.4");
len = sizeof(add_server);
fd = connect(fd_client,(struct sockaddr*)&add_server,len);
if(fd == -1)
perror("connect");
return 0;
}
8. What will happen if we press "Ctrl+c" key two times after running this program?
#include<stdio.h>
#include<signal.h>
void response(int);
void response(int sig_no)
{
printf("Linux\n");
signal(SIGINT,SIG_DFL);
}
int main()
{
signal(SIGINT,response);
while(1){
printf("Example\n");
sleep(1);
}
return 0;
}
#include<stdio.h>
#include<signal.h>
void response(int);
void response(int sig_no)
{
printf("Linux\n");
signal(SIGINT,SIG_DFL);
}
int main()
{
signal(SIGINT,response);
while(1){
printf("Example\n");
sleep(1);
}
return 0;
}
9. What are the sizes of (Integer/Long/Pointer) in LP64 programming model?
10. Which one of the following is a symlink to the root path as seen by the process?
Read More Section(Linux)
Each Section contains maximum 100 MCQs question on Linux. To get more questions visit other sections.