250+ TOP MCQs on User Account Management and Answers

Linux / Unix questions and answers focuses on Linux administration on User & Account management and related commands. It will be useful for anyone learning Linux Basics, Essentials and/or Administration.

1. User’s Primary Group id is listed in which file, at the time of creation of the user (On a standard Unix system)
a) /etc/passwd
b) /etc/groups
c) /etc/login
d) /etc/profile
Answer: a
Clarification: None.

2. The encrypted password of a user is stored in
a) /etc/shadow
b) /etc/enpasswwd
c) /etc/.passwd
d) /etc/passwd
Answer: a
Clarification: None.

3. A user can change the default log-in shell using
a) chmod
b) chsh
c) rmsh
d) tchsh
Answer: b
Clarification: None.

4. Which of the following identifiers associated with a process decide its privilege level
a) uid
b) suid
c) euid
d) gid
Answer: c
Clarification: None.

5. The /etc/passwd file doesn’t contain
a) userid
b) home directory for a user
c) login shell name
d) none of the mentioned
Answer: d
Clarification: None.

6. User id 0 is
a) An innvalid user id
b) The id of the root user
c) The id of a user when the user’s account is deleted
d) None of the mentioned
Answer: b
Clarification: None.

7. The login shell is
a) The shell program that runs when the user logs in
b) The shell program that authenticates the user while logging in
c) Common shell for all the users that belong to the same group
d) None of the mentioned
Answer: a
Clarification: None.

8. Which of the following command can be used to change the user password?
a) user can’t change the password
b) passwd
c) passd
d) pwd
Answer: b
Clarification: None.

9. What does the following command do ?
who | wc –l
a) List the number of users logged in
b) List the users
c) List the number of users in the system
d) Display the content of who command
Answer: a
Clarification: None.

10. By default, a Linux user falls under which group?
a) staff
b) others
c) same as userid (UPG)
d) system
Answer: c
Clarification: None.

11. Which of the following files need to be referred for user’s secondary group?
a) /etc/passwd
b) /etc/shadow
c) /etc/group
d) /etc/profile
Answer: c
Clarification: None.

12. The ls –l output for /etc/passwd and /usr/bin/passwd is as follows:

-rw-rw-r-- 1 root root 2807 Apr 26 13:50 /etc/passwd
-r-s—x—x 1 root root 17008 May 25 02:30 /usr/bin/passwd
 
If a user, not belonging to the group ‘root’, runs the passwd executable in an attempt to modify his password, then which of the following is true?

a) password change fails since user does not have permission to update /etc/passwd file
b) password change is successful because the program runs as root
c) passwd change program runs in kernel mode where write access to the /etc/passwd file is possible
d) /etc/passwd is a special file and the system by default allows all users to update it
Answer: b
Clarification: None.

contest

250+ TOP MCQs on Expressions and Answers

Linux / Unix questions and answers focuses on Expressions in Awk Programming.

1. What is expression in awk programming?
a) expression evaluates a value to print, test or pass to a function
b) expression assigns a new value to a variable or field
c) expression evaluates a value to print, test or pass to a function & also assigns a new value to a variable or field
d) none of the mentioned
Answer: c
Clarification: None.

2. Which one of the following is not true?
a) there are 3 types of constant expressions: numeric, string and regular
b) arithmetic operators are used to evaluate expressions
c) assignment expression is an expression that stores a value into a variable
d) comparison expressions does not compare strings for relationship
Answer: d
Clarification: None.

3. All numeric values are represented within awk in
a) double precision floating point
b) integer
c) exponential notation
d) fixed point
Answer: a
Clarification: None.

4. Concatenation is performed by
a) writing expressions next to one another, with no operator
b) conditional operator
c) relational operator
d) matching operator
Answer: a
Clarification: None.

5. The comparison expression “x ~ y” will true if
a) x is not equal to y
b) the string x does not match the regular expression denoted by y
c) the string x matches the regular expression denoted by y
d) none of the mentioned
Answer: c
Clarification: None.

6. What is the output of this program?

  1.    #! /usr/bin/awk -f
  2.    BEGIN {
  3.        print "20"<"9" ? "true":"false"	      
  4.    }

a) true
b) false
c) syntax error
d) none of the mentioned
Answer: a
Clarification: The operands of relational operators are converted to, and compared as string if both are not numbers. Strings are compared by comparing the characters of each. Hence 20 is less then 9.
Output:
[email protected]:/home/# chmod +x test.awk
[email protected]:/home/# ./test.awk
true
[email protected]:/home/#

7. What is the output of this program?

  1.    #! /usr/bin/awk -f
  2.    BEGIN {
  3.        a=10;
  4.        b=10;
  5.        print a==b ? "true":"false"	      
  6.    }

a) true
b) false
c) syntax error
d) none of the mentioned
Answer: a
Clarification: None.
Output:
[email protected]:/home/# chmod +x test.awk
[email protected]:/home/# ./test.awk
true
[email protected]:/home/#

8. What is the output of this program?

  1.    #! /usr/bin/awk -f
  2.    BEGIN {
  3.        var1=""
  4.        var2="linux"
  5.        print var1" provides "var2" MCQs "	      
  6.    }

a) provides linux MCQs
b) var1 provides var2 MCQs
c) provides MCQs
d) syntax error
Answer: a
Clarification: None.
Output:
[email protected]:/home/# chmod +x test.awk
[email protected]:/home/# ./test.awk
provides linux MCQs
[email protected]:/home/#

9. What is the output of this program?

  1.    #! /usr/bin/awk -f
  2.    BEGIN {
  3.        two=2;
  4.        two++;
  5.        print two 
  6.    }

a) two
b) three
c) 2
d) 3
Answer: d
Clarification: None.
Output:
[email protected]:/home/# chmod +x test.awk
[email protected]:/home/# ./test.awk
3
[email protected]:/home/#

10. What is the output of this program?

  1.     #! /usr/bin/awk -f
  2.     BEGIN {
  3.         one=10;
  4.         two=3;
  5.         print (one%two)+10 
  6.     }

a) (one%two)+10
b) 13
c) 11
d) syntax error
Answer: c
Clarification: The remainder of 10/3 is 1. remainder is added to 10.
Output:
[email protected]:/home/# chmod +x test.awk
[email protected]:/home/# ./test.awk
11
[email protected]:/home/#

250+ TOP MCQs on Stages of Compilation and Answers

Linux / Unix questions and answers focuses on various stages of compilation for gcc compiler. This is set 1.1. The correct sequence of GCC compilation process is
a) preprocessing -> compilation -> assemble -> linking
b) assemble -> preprocessing -> compilation -> linking
c) preprocessing -> assemble -> compilation -> linking
d) none of the mentioned

Answer: a
Clarification: None.

2. The preprocessor removes the _______ from the source code.
a) comments
b) header files
c) both comments and header files
d) none of the mentioned

Answer: a
Clarification: None.

3. The compiler converts
a) assembly code into machine code
b) preprocessed source code into assembly code
c) machine code into assembly code
d) none of the mentioned

Answer: b
Clarification: None.

4. The assembly code is converted into the machine code by
a) compiler
b) assembler
c) linker
d) none of the mentioned

Answer: b
Clarification: None.

5. What is the role of linker in the compilation process?
a) linker links the object code with the library code
b) linker converts machine code into executable machine code
c) linker generates an executable file
d) all of the mentioned

Answer: d
Clarification: None.

6. If .c is compiled with GCC, then the .s file will contain the
a) assembly code
b) machine code
c) preprocessed code
d) expanded source code

Answer: a
Clarification: None.

7. The object file contains the
a) assembly code
b) machine code
c) modified source code
d) none of the mentioned

Answer: b
Clarification: None.

8. If we do not specify the executable file name at the compilation time in GCC, then in linux the compiler creates executable named as
a) a.out
b) a.exe
c) x.out
d) x.exe

Answer: a
Clarification: None.

9. The macros specifies in source code are expanded by
a) preprocessor
b) assembler
c) compiler
d) linker

Answer: a
Clarification: None.

10. The preprocessor creates the file with extension
a) .a
b) .i
c) .s
d) .o

Answer: b
Clarification: None.

250+ TOP MCQs on Memory Management and Answers

Here is a listing of Linux / Unix Technical Interview Questions & Answers for experienced IT professionals as well as fresh engineering graduates. These questions can be attempted by anyone focusing on Linux Development and Systems programming.

1. On x86-32 Linux, at which address the code segment of the program starts?
a) 0x00000000
b) 0x08048000
c) 0x80000000
d) 0xbfff0000
Answer: b
Clarification: None.

2. On x86-32 Linux, at which address the user stack resides normally?
a) 0x00000000
b) 0x3fff0000
c) 0x7fff0000
d) 0xbfff0000
Answer: d
Clarification: None.

3. A system has 512MB of physical memory. Which among the following is not a suitable virtual memory size for this system architecture?
a) 512MB
b) 256M
c) 4GB
d) None of the mentioned
Answer: d
Clarification: None.

4. LRU stands for
a) Last received Unit
b) Least recently Used
c) Least recently usable
d) Lost Recoverd unit
Answer: b
Clarification: None.

5. Mm_struct maintains?
a) memory files
b) open files
c) pipe
d) active memory regions
Answer: d
Clarification: None.

6. Which sytem call can be used by a user process to lock a memory so that it cannot be swapped out?
a) memory files()
b) memlock()
c) pipe()
d) active memory regions
Answer: b
Clarification: None.

7. Is page table per process entity?
a) Yes
b) No
Answer: a
Clarification: None.

8. Among these files which has an ELF format
a) shared objects
b) core
c) executables
d) all of the mentioned
Answer: d
Clarification: None.

9. What is the use of strace command?
a) strace can be used to check the system calls called by the program. So, this can be used for debugging and benchmarking purposes
b) strace cannot be used to check the system calls called by the program
c) all of the mentioned
d) none of the mentioned
Answer: a
Clarification: None.

10. If one of the thread in multithreaded process is blocked on an I/O, which of the following is true?
a) The entire process with block if their is no kernel supported threads
b) Other threads of the process will continue to execute even if there is no kernel supported threads
c) It depends on specific implementatation
d) All of the mentioned
Answer: a
Clarification: None.

11. Which one can be a real time schedule policy?
a) SCHED_FIFO
b) SCHED_SPF
c) SCHED_OTHER
d) SCHED_FILO
Answer: a
Clarification: None.

12. In Linux kernel-2.6 Real time priority ranges from
a) 0 to 99
b) 0 to 139
c) -20 to 19
d) 100 to 139
Answer: a
Clarification: None.

13. Solaris real time class priority is
a) 0-59
b) 60-99
c) 100-159
d) 160-169
Answer: c
Clarification: None.

14. Solaris System class priority is
a) 0-59
b) 60-99
c) 100-159
d) 160-169
Answer: b
Clarification: None.

Learn detailed answer of these interview questions and an in-depth coverage on Linux Systems Programming by our popular training program titled Linux Systems Programming delivered by our Founder & CTO.

Read here to know more about the skills required to become a Linux Systems Developer.

Linux Commands & Shell Programming.
These questions focuses on Process Management, Memory Management, File Management, Inter Process Communications, Signal Handling, etc.

250+ TOP MCQs on System-V IPCs – Message Queues, Shared Memory and Semaphores and Answers

Linux Debugging questions and answers focuses on the System-V IPCs i.e. Message Queues, Shared Memory and Semaphores.1. What is the output of this program?

  1.    #include
  2.    #include
  3.    #include<sys/stat.h>
  4.    #include
  5. 
    
  6.    int main()
  7.    {
  8.        sem_t* sem_id;
  9.        sem_id = sem_open("sem_value",O_CREAT,0666,0);
  10.        if(sem_id == SEM_FAILED)
  11.            perror("sem_open");
  12.        sem_wait(sem_id);
  13.        printf("n");
  14.        if(sem_close(sem_id) == -1)
  15.            perror("sem_close");
  16.        return 0;
  17.    }

a) this program will print the string “”
b) this process will block
c) segmentaion fault
d) none of the mentioned

Answer: b

2. What is the output of this program?

  1.    #include
  2.    #include
  3.    #include<sys/stat.h>
  4.    #include
  5. 
    
  6.    int main()
  7.    {
  8.        sem_t* sem_id;
  9.        int value;
  10.        sem_id = sem_open("sem_value",O_CREAT,0666,0);
  11.        if(sem_id == SEM_FAILED)
  12.            perror("sem_open");
  13.        if(sem_getvalue(sem_id,&value) == -1)
  14.            perror("sem_getvalue");
  15.        printf("%dn",value);
  16.        sem_wait(sem_id);
  17.        printf("n");
  18.        if(sem_close(sem_id) == -1)
  19.            perror("sem_close");
  20.        return 0;
  21.    }

a) 0
b)
c) Both 0 and
d) None of the mentioned

Answer: a

3. What is the output of this program?

  1.    #include
  2.    #include
  3.    #include<sys/stat.h>
  4.    #include
  5. 
    
  6.    int main()
  7.    {
  8.        sem_t* sem_id;
  9.        sem_id = sem_open("sem_value",O_CREAT,0666,0);
  10.        if(sem_id == SEM_FAILED)
  11.            perror("sem_open");
  12.        sem_post(sem_id);
  13.        printf("n");
  14.        if(sem_close(sem_id) == -1)
  15.            perror("sem_close");
  16.        return 0;
  17.    }

a) this process will block
b) this program will print the string “”
c) segmentation fault
d) none of the mentioned

Answer: b

4. What is the output of this program?

  1.    #include
  2.    #include
  3.    #include<sys/stat.h>
  4.    #include
  5. 
    
  6.    int main()
  7.    {
  8.        sem_t* sem_id;
  9.        sem_id = sem_open("sem_value",O_CREAT,0666,0);
  10.        if(sem_id == SEM_FAILED)
  11.            perror("sem_open");
  12.        if(sem_close(sem_id) == -1)
  13.            perror("sem_close");
  14.        sem_wait(sem_id);
  15.        printf("n");
  16.        return 0;
  17.    }

a) this process will block
b) this program will print the string “”
c) segmentation fault
d) none of the mentioned

Answer: c

5. What is the output of this program?

  1.    #include
  2.    #include
  3.    #include<sys/stat.h>
  4.    #include
  5. 
    
  6.    int main()
  7.    {
  8.        sem_t* sem_id;
  9.        int value;
  10.        sem_id = sem_open("new_13",O_CREAT,0666,3);
  11.        if(sem_id == SEM_FAILED)
  12.            perror("sem_open");
  13.        sem_wait(sem_id);
  14.        sem_wait(sem_id);
  15.        sem_wait(sem_id);
  16.        sem_wait(sem_id);
  17.        sem_post(sem_id);
  18.        sem_post(sem_id);
  19.        sem_getvalue(sem_id,&value);
  20.        printf("%dn",value);
  21.        if(sem_close(sem_id) == -1)
  22.            perror("sem_close");
  23.        return 0;
  24.    }

a) 2
b) 3
c) 0
d) none of the mentioned

Answer: d

6. What is the output of this program?

  1.    #include
  2.    #include
  3.    #include<sys/stat.h>
  4.    #include<sys/mman.h>
  5. 
    
  6.    int main()
  7.    {
  8.        int s_id;
  9.        s_id = shm_open("shared_mem",O_CREAT|O_RDWR,0666);
  10.        printf("%dn",s_id);
  11.        if(shm_unlink("shared_mem") == -1)
  12.            perror("shm_unlink");
  13.        return 0;
  14.    }

a) -1
b) 1
c) 2
d) 3

Answer: d

7. What is the output of this program?

  1.    #include
  2.    #include
  3.    #include<sys/stat.h>
  4.    #include<sys/mman.h>
  5. 
    
  6.    int main()
  7.    {
  8.        int s_id;
  9.        int *ptr;
  10.        s_id = shm_open("shared_mem",O_CREAT|O_RDWR,0666);
  11.        if(s_id == -1)
  12.            perror("shm_open");
  13.        ptr = mmap(NULL,100,PROT_WRITE,MAP_PRIVATE,s_id,0);
  14.        if(ptr == MAP_FAILED);
  15.            perror("mmap");
  16.        if(munmap(ptr,100) == -1)
  17.            perror("munmap");
  18.        if(shm_unlink("shared_mem") == -1)
  19.            perror("shm_unlink");
  20.        return 0;
  21.    }

a) mmap: Success
b) mmap: Failure
c) munmap: Success
d) munmap: Failure

Answer: a

8. What is the output of this program?

  1.    #include
  2.    #include
  3.    #include<sys/stat.h>
  4.    #include<sys/mman.h>
  5. 
    
  6.    int main()
  7.    {
  8.        int s_id;
  9.        int *ptr;
  10.        s_id = shm_open("shared_mem",O_CREAT|O_RDWR,0666);
  11.        if(s_id == -1)
  12.            perror("shm_open");
  13.        ptr = mmap(NULL,100,PROT_WRITE,MAP_PRIVATE,s_id,0);
  14.        if(ptr == MAP_FAILED);
  15.            perror("mmap");
  16.        ptr = mmap(ptr,100,PROT_WRITE,MAP_PRIVATE,s_id,0);
  17.        if(ptr == MAP_FAILED);
  18.            perror("mmap");
  19.        if(munmap(ptr,100) == -1)
  20.            perror("munmap");
  21.        if(shm_unlink("shared_mem") == -1)
  22.            perror("shm_unlink");
  23.        return 0;
  24.    }

a) mmap: Success
mmap: Success
b) mmap: Success
mmap: Failure
c) segmentation fault
d) none of the mentioned

Answer: a

9. What is the output of this program?

  1.    #include
  2.    #include
  3.    #include
  4.    #include<sys/stat.h>
  5.    #include<sys/mman.h>
  6. 
    
  7.    int main()
  8.    {
  9.        int s_id;
  10.        s_id = shm_open("shared_mem",O_CREAT|O_RDWR,0666);
  11.        if(s_id != EACCES)
  12.            perror("Permission grantedn");
  13.        return 0;
  14.    }

a) Permission granted
: Success
b) Permission granted
c) segmentation fault
d) none of the mentioned

Answer: a

10. What is the output of this program?

  1.     #include
  2.     #include
  3.     #include
  4.     #include<sys/stat.h>
  5.     #include<sys/mman.h>
  6. 
    
  7.     int main()
  8.     {
  9.         int s_id;
  10.         s_id = shm_open("shared_memory",O_TRUNC,0666);
  11.         if(s_id == -1)
  12.             perror("shm_openn");
  13.         return 0;
  14.     }

a) this program will give an error because OTRUNC is not a valid flag
b) this program will give an error
c) this program will give segmentation fault
d) none of the mentioned

Answer: b

250+ TOP MCQs on Linux Environment and Answers

Linux / Unix questions and answers is useful for various certification exams on Linux like Redhat certification exam, Ubuntu/SuSE certification exam, LPI certification exam, etc.

1. To increase the response time and throughput, the kernel minimizes the frequency of disk access by keeping a pool of internal data buffer called
a) Pooling
b) Spooling
c) Buffer cache
d) Swapping
Answer: c
Clarification: None.

2. At start of process execution, STDOUT & STDERR
a) Point to current terminal device
b) Are closed
c) Point to special files on the system
d) None of the mentioned
Answer: a
Clarification: None.

3. wtmp and utmp files contain:
a) Temporary system data
b) User login-logout log
c) The user’s command execution log
d) The user’s su and sudo attempts
Answer: b
Clarification: None.

4. Which is the core of the operating system?
a) Shell
b) Kernel
c) Commands
d) Script
Answer: b
Clarification: None.

5. ILP32 stands for
a) 32 bit Integer, Long & Pointer
b) 32 bit Integrated Long & Pointer
c) 32 bit Intelligent Long & Pointer
d) 32 bit Long & Pointer
Answer: a
Clarification: None.

6. Single Unix Specification Version 2 provides enhanced support for
a) 16 bit Unix
b) 32 bit Unix
c) 64 bit Unix
d) 8 bit Unix
Answer: c
Clarification: None.

7. Under UNIX the key board is the default input device and the monitor is the default output device
a) True
b) False
Answer: a
Clarification: None.

8. Which among the following interacts directly with system hardware?
a) Shell
b) Commands
c) Kernel
d) Applications
Answer: c
Clarification: None.

9. Applications communicate with kernel by using:
a) System Calls
b) C Programs
c) Shell Script
d) Shell
Answer: a
Clarification: None.