250+ TOP MCQs on File Permissions and Answers

Linux / Unix questions and answers focuses on various Linux commands on File Management areas viz. file attributes, modes and permissions.

1. The file permission 764 means:
a) Every one can read, group can execute only and the owner can read and write
b) Every one can read and write, but owner alone can execute
c) Every one can read, group including owner can write, owner alone can execute
d) Every one can read and write and execute
Answer: c
Clarification: None.

2. The permission -rwxr–r– represented in octal expression will be
a) 777
b) 666
c) 744
d) 711
Answer: c
Clarification: None.

3. Effective user id can be set using following permission
a) 0777
b) 2666
c) 4744
d) 1711
Answer: c
Clarification: None.

4. Effective group id can be set using following permission
a) 0777
b) 2666
c) 4744
d) 1711
Answer: b
Clarification: None.

5. Sticky bit can be set using following permission
a) 0777
b) 2666
c) 4744
d) 1711
Answer: d
Clarification: None.

6. The permission -rwSr–r– represented in octal expression will be
a) 0777
b) 2666
c) 4744
d) 4644
Answer: d
Clarification: None.

7. The permission -rwxr-sr– represented in octal expression will be
a) 0777
b) 2766
c) 2744
d) 2754
Answer: d
Clarification: None.

8. If user tries to remove (rm) a readonly file (444 permission), what will happen?
a) The file is removed successfully (and silently)
b) The rm command prompts for a confirmation, the command is successful upon confirmation
c) The rm command prompts for a confirmation, however the operation fails because of insufficient permissions
d) The rm command fails because of insufficient permissions
Answer: b
Clarification: None.

9. A user does a chmod operation on a file. Which of the following is true?
a) The last accessed time of the file is updated
b) The last modification time of the file is updated
c) The last change time of the file is updated
d) None of the mentioned
Answer: c
Clarification: None.

10. If the umask value is 0002. what will be the permissions of new directory
a) 777
b) 775
c) 774
d) 664
Answer: b
Clarification: None.

11. What is the command to set the execute permissions to all the files and subdirectories within the directory /home/user1/direct
a) chmod –r +x /home/user1/direct
b) chmod –R +x /home/user1/direct
c) chmod –f –r +x /home/user1/direct
d) chmod –F +x /home/user1/direct
Answer: b
Clarification: None.

Here’s the list of Best Reference Books in

250+ TOP MCQs on Built-in Commands and Answers

Linux / Unix questions and answers focuses on Built-in Commands in Linux Bash Shell. This is set-1.1. Which command sets up shorthand for command or command line?
a) set
b) alias
c) new
d) echo

Answer: b
Clarification: None.

2. What is the function of bind command in bash shell?
a) defining new macros
b) defining new key bindings for existing commands
c) dumping the installed key bindings
d) all of the mentioned

Answer: d
Clarification: None.

3. The command ‘compgen -c’ shows
a) all variable names
b) all system wide aliases
c) full list of all commands
d) none of the mentioned

Answer: c
Clarification: None.

4. Which statement resumes the next iteration of a for, while, select, or untill loop?
a) continue
b) break
c) complete
d) command

Answer: a
Clarification: None.

5. Which command prints the directory stack?
a) cd
b) dirs
c) popd
d) pushd

Answer: b
Clarification: None.

6. The command ‘disown -r’
a) removes all jobs
b) removes all running jobs
c) marks jobs to not receive SIGHUP when bash exits
d) marks all jobs

Answer: b
Clarification: None.

7. The command ‘enable -n ‘
a) enables the specified built-in command
b) disables the specified built-in command
c) print the status of the command
d) none of the mentioned

Answer: b
Clarification: None.

8. Which command can create environment variable?
a) export
b) set
c) read
d) none of the mentioned

Answer: a
Clarification: None.

9. Which command concatenate the specified argument into a single command, then execute the command?
a) fc
b) eval
c) exec
d) getopts

Answer: b

10. The command ‘hash’
a) manages a internal hash table
b) find and remember the full path name of the specified command
c) displays used command names and the number of hits
d) all of the mentioned

Answer: d

250+ TOP MCQs on Makefile Questions and Answers

Linux / Unix questions and answers focuses on makefile. This is set 1.1. What is makefile?
a) makefile describes to the make command that how to compile the program
b) makefile contains various statements related with the compilation of target
c) makefile contains various statements
d) none of the mentioned

Answer: a
Clarification: None.

2. What is phony target in the makefile?
a) the target which is not a filename
b) the target which is a filename
c) the target which does not used for compilation
d) none of the mentioned

Answer: a
Clarification: None.

3. As we type “make” command on the terminal
a) make reads the makefile in the current directory
b) make reads the makefile in the parent directory
c) make reads the makefile in the predefined environment variable
d) none of the mentioned

Answer: a
Clarification: None.

4. The makefile starts executing from
a) first target
b) first target whose name starts with “.”
c) first target whose name does not starts with “.”
d) none of the mentioned

Answer: c
Clarification: None.

5. The command “make ” will
a) create the executable if .c file is present in the current directory
b) create the object file named as .o
c) give an error
d) none of the mentioned

Answer: a
Clarification: None.

6. If our makefile is named as “”, then which one of the following command will compile the code with this makefile
a) make -a
b) make -f
c) make sanfoudry
d) make

Answer: b
Clarification: None.

7. Which option of make command print the commands that would be executed, but do not execute them?
a) -m
b) -n
c) -o
c) -p

Answer: b
Clarification: None.

8. If we want to get the exit status that specified targets are up to date or not, we have to execute the make command with option
a) -q
b) -r
c) -s
d) -t

Answer: a
Clarification: None.

9. Which make command option ignores all errors in commands executed to remark files?
a) -i
b) -j
c) -k
d) -l

Answer: a
Clarification: None.

10. If make command is executed as “make -j 2”, then
a) two jobs will run simultaneously
b) only two will be executed
c) it will give an error
d) none of the mentioned

Answer: a

250+ TOP MCQs on Linux Sysfs and Answers

Linux / Unix questions and answers focuses on sysfs. This is set 3.1. Sysfs is initialised in ______ file via sysfs_init function.
a) fs/sysfs/mount.c
b) sysfs/mount.c
c) fs/mount.c
c) none of the mentionedAnswer: a
Clarification: None.

2. Kernel objects are exported as _____ via sysfs.
a) regular files
b) symbolic links
c) directories
d) none of the mentioned

Answer: c
Clarification: None.

3. Sysfs internally stores the pointer to the ____ that implements the directory in the file system.
a) kobjects
b) kstructures
c) kinodes
d) none of the mentioned

Answer: a
Clarification: None.

4. Attributes can be exported for objects in the form of _______ in the file system.
a) regular files
b) directories
c) symbolic links
d) none of the mentioned

Answer: a
Clarification: None.

5. In sysfs every subsystem has
a) a shared attribute structure
b) its own attribute structure
c) a shared & own attribute structure
d) none of the mentioned

Answer: b
Clarification: None.

6. sysfs is based on
a) rootfs
b) ramfs
c) initramfs
d) none of the mentioned

Answer: b
Clarification: None.

7. Which one of the following is a notification to user space from the kernel that something has changed in the system’s configuration?
a) hotplug event
b) module event
c) attach event
d) none of the mentioned

Answer: a
Clarification: None.

8. In the device driver model the device_driver object contains the
a) name of the device driver
b) embedded kobjects
c) method for probing a device
d) all of the mentioned

Answer: d
Clarification: None.

9. A ____ is a higher level view of a device that abstracts out low level implementation details/
a) inode
b) class
b) major number
d) minor number

Answer: b
Clarification: None.

10. When a device is removed from the system
a) files and directories of that device in the sysfs are removed automatically
b) all the files of sysfs are preserved until the system turn offs
c) it does not create any change in the sysfs
d) none of the mentioned

Answer: a

250+ TOP MCQs on Signal Handling System Calls and Answers

Linux Debugging questions and answers focuses on signal handling System Calls.1. What will happen as we press the “Ctrl+c” key after running this program?

  1.    #include
  2.    #include
  3. 
    
  4.    void response (int);
  5.    void response (int sig_no)
  6.    {
  7.        printf("Linuxn");
  8.    }
  9.    int main()
  10.    {
  11.        signal(SIGINT,response);
  12.        while(1){
  13.            printf("n");
  14.            sleep(1);
  15.        }
  16.        return 0;
  17.    }

a) the string “Linux” will print
b) the process will be terminated after printing the string “Linux”
c) the process will terminate
d) none of the mentioned

Answer: a
2. What will happen if we press “Ctrl+c” key two times after running this program?
  1.    #include
  2.    #include
  3. 
    
  4.    void response(int);
  5.    void response(int sig_no)
  6.    {
  7.        printf("Linuxn");
  8.        signal(SIGINT,SIG_DFL);
  9.    }
  10.    int main()
  11.    {
  12.        signal(SIGINT,response);
  13.        while(1){
  14.            printf("n");
  15.            sleep(1);
  16.        }
  17.        return 0;
  18.    }

a) process will terminate in the first time
b) process will terminate in the second time
c) process will never terminate
d) none of the mentioned

Answer: b

3. What happens as the SIGINT signal hits the running process of this program?

  1.    #include
  2.    #include
  3.    #include
  4. 
    
  5.    int main()
  6.    {
  7.        pid_t child;
  8.        signal(SIGINT,SIG_IGN);
  9.        child=fork();
  10.        switch(child){
  11.            case -1:
  12.                perror("fork");
  13.                exit(1);
  14.            case 0:
  15.                while(1){
  16.                    printf("Child Processn");
  17.                    sleep(1);
  18.                }
  19.                break;
  20.            default :
  21.                while(1){
  22.                    printf("Parent Processn");
  23.                    pause();
  24.                }
  25.                break;
  26.        }
  27.        return 0;
  28.    }

a) child process terminates
b) parent process terminates
c) both child and parent process ignores the signal
d) none of the mentioned

Answer: c

4. What will print as the SIGINT signal hits the running process of this program?

  1.    #include
  2.    #include
  3.    #include
  4. 
    
  5.    void response (int);
  6.    void response (int sig_no)
  7.    {
  8.        printf("%s",sys_siglist[sig_no]);
  9.    }
  10.    int main()
  11.    {
  12.        signal(SIGINT,response);
  13.        while(1){
  14.            printf("n");
  15.            sleep(1);
  16.        }
  17.        return 0;
  18.    }

a) Interrupt
b) Stop
c) Terminate
d) none of the mentioned

Answer: a

5. In this program

  1.    #include
  2.    #include
  3.    #include
  4. 
    
  5.    int main()
  6.    {
  7.        pid_t child;
  8.        child=fork();
  9.        switch(child){
  10.            case -1 :
  11.                perror("fork");
  12.                exit(1);
  13.            case 0 :
  14.                while(1){
  15.                    printf("Child Processn");
  16.                    sleep(1);
  17.                }
  18.                break;
  19.            default :
  20.                sleep(5);
  21.                kill(child,SIGINT);
  22.                printf("The child process has been killed by the parent processn");
  23.                break;
  24.        }
  25.        return 0;
  26.    }

a) the child process kills the parent process
b) the parent process kills the child process
c) both the processes are killed by each other
d) none of the mentioned

Answer: b

6. What is the output of this program?

  1.    #include
  2.    #include
  3. 
    
  4.    void response (int);
  5.    void response (int sig_no)
  6.    {
  7.        printf("%sn",sys_siglist[sig_no]);
  8.    }
  9.    int main()
  10.    {
  11.        pid_t child;
  12.        int status;
  13.        child = fork();
  14.        switch(child){
  15.            case -1:
  16.                perror("fork");
  17.            case 0:
  18.                break;
  19.            default :
  20.                signal(SIGCHLD,response);
  21.                wait(&status);
  22.                break;
  23.        }
  24.    }

a) this program will print nothing
b) this program will print “Child Exited”
c) segmentation fault
d) none of the mentioned

Answer: b

7. Which one of the following is not true about this program?

  1.    #include
  2.    #include
  3. 
    
  4.    void response (int);
  5.    void response (int signo)
  6.    {
  7.        printf("%sn",sys_siglist[signo]);
  8.        signal(SIGSEGV,SIG_IGN);
  9.    }
  10.    int main()
  11.    {
  12.        signal (SIGSEGV,response);
  13.        char *str;
  14.        *str = 10;
  15.        return 0;
  16.    }

a) kernel sends SIGSEGV signal to a process as segmentation fault occurs
b) in this process signal handler will execute only one time of recieving the signal SIGSEGV
c) all of the mentioned
d) none of the mentioned

Answer: d

8. What is the output of this program?

  1.    #include
  2.    #include
  3.    #include
  4. 
    
  5.    void response (int);
  6.    void response (int sig_no)
  7.    {
  8.        printf("%sn",sys_siglist[sig_no]);
  9.        printf("This is singal handlern");
  10.    }
  11.    int main()
  12.    {
  13.        pid_t child;
  14.        int status;
  15.        child = fork();
  16.        switch (child){
  17.            case -1 :
  18.                perror("fork");
  19.                exit (1);
  20.            case 0 :
  21.                kill(getppid(),SIGKILL);
  22.                printf("I am an orphan process because my parent has been killed by men");
  23.                printf("Handler failedn");
  24.                break;
  25.            default :
  26.                signal(SIGKILL,response);
  27.                wait(&status);
  28.                printf("The parent process is still aliven");
  29.                break;
  30.        }
  31.        return 0;
  32.    }

a) the child process kills the parent process
b) the parent process kills the child process
c) handler function executes as the signal arrives to the parent process
d) none of the mentioned

Answer: a

9. This program will print

  1.    #include
  2.    #include
  3.    #include
  4. 
    
  5.    void response (int);
  6.    void response (int sig_no)
  7.    {
  8.        printf("%s is workingn",sys_siglist[sig_no]);
  9.    }
  10.    int main()
  11.    {
  12.        alarm(5);
  13.        sleep(50);
  14.        printf("n");
  15.        signal(SIGALRM,response);
  16.        return 0;
  17.    }

a) “”
b) “Alarm clock”
c) nothing
d) none of the mentioned

Answer: b

10. What happnes as the signal SIGINT hits the current process in the program?

  1.     #include
  2.     #include
  3. 
    
  4.     void response (int);
  5.     void response (int sig_no)
  6.     {
  7.         printf("Linuxn");
  8.     }
  9.     int main()
  10.     {
  11.         struct sigaction act;
  12.         act.sa_handler = response;
  13.         act.sa_flags = 0;
  14.         sigemptyset(&act.sa_mask);
  15.         sigaction(SIGINT,&act,0);
  16.         while(1){
  17.             printf("n");
  18.             sleep(1);
  19.         }
  20.         return 0;
  21.     }

a) the process terminates
b) the string “Linux” prints
c) the string “Linux” prints and then process terminates
d) none of the mentioned

Answer: b