linux banner

Linux Multiple Choice Questions (MCQs) and Answers

Master Linux with Practice MCQs. Explore our curated collection of Multiple Choice Questions. Ideal for placement and interview preparation, our questions range from basic to advanced, ensuring comprehensive coverage of Linux concepts. Begin your placement preparation journey now!

Q31

Q31 How do you list all files, including hidden files, in a directory?

A

ls -a

B

ls -l

C

ls -h

D

ls -all

Q32

Q32 How do you view the first 10 lines of a file named data.txt?

A

head -10 data.txt

B

tail -10 data.txt

C

cat data.txt

D

more data.txt

Q33

Q33 How do you search for the pattern "error" in a file named log.txt and display matching lines?

A

grep "error" log.txt

B

find "error" log.txt

C

locate "error" log.txt

D

search "error" log.txt

Q34

Q34 A user complains that they cannot find a command they just installed.
What could be the most likely cause?

A

The command is not in the user's PATH

B

The command is not executable

C

The command was not installed correctly

D

The command is hidden

Q35

Q35 A user reports that the df command is showing incorrect free space for a partition.
What could be a possible reason?

A

The partition is unmounted

B

The disk is faulty

C

Inode exhaustion

D

Filesystem is read-only

Q36

Q36 A user wants to compress a file but receives a "Permission denied" error.
What is the likely cause?

A

The file is read-only

B

The user does not have write permissions

C

The file is already compressed

D

The user is not in the correct directory

Q37

Q37 A user wants to use the find command to search for all .txt files in their home directory, but it returns no results.
What could be the issue?

A

Incorrect syntax

B

The files do not exist

C

The user lacks read permissions

D

The files are hidden

Q38

Q38 What does the command chmod 755 do?

A

Sets read, write, and execute permissions for the owner, and read and execute permissions for others

B

Sets read and write permissions for the owner, and read permissions for others

C

Sets execute permissions for the owner and group

D

Sets read and execute permissions for the owner and group

Q39

Q39 What does the 'r' permission signify in Linux file permissions?

A

Read

B

Write

C

Execute

D

Delete

Q40

Q40 How can you view the permissions of a file named example.txt?

A

ls example.txt

B

ls -l example.txt

C

chmod example.txt

D

chown example.txt

Q41

Q41 What is the effect of setting the setuid bit on an executable file?

A

The file can be executed with the user's permissions

B

The file can be executed with the group's permissions

C

The file can be executed with the owner's permissions

D

The file can only be executed by the owner

Q42

Q42 Which command is used to change the owner of a file?

A

chmod

B

chown

C

chgrp

D

ls -l

Q43

Q43 How do you grant read and write permissions to the owner and the group for a file named data.txt?

A

chmod 660 data.txt

B

chmod 640 data.txt

C

chmod 644 data.txt

D

chmod 600 data.txt

Q44

Q44 How do you add execute permissions for the user on a file named script.sh?

A

chmod +x script.sh

B

chmod u+x script.sh

C

chmod u-x script.sh

D

chmod o+x script.sh

Q45

Q45 Which command is used to change the group ownership of a file named project.txt to a group named devteam?

A

chown devteam project.txt

B

chgrp devteam project.txt

C

chgroup devteam project.txt

D

chmod devteam project.txt

Q46

Q46 A user reports that they cannot delete a file named report.txt, even though they have write permissions.
What could be the reason?

A

The file is read-only

B

The user does not have execute permissions

C

The directory containing the file does not have write permissions

D

The file is hidden

Q47

Q47 A file named data.txt has the permissions set to -rwxr-xr--.
What does this imply about the user's permissions?

A

The user can read, write, and execute the file

B

The user can read and write the file

C

The user can read and execute the file

D

The user can only read the file

Q48

Q48 Which command is used to list all currently running processes?

A

ps

B

ls

C

top

D

jobs

Q49

Q49 What is the purpose of the 'init' process in Linux?

A

To initialize network connections

B

To manage the system's boot process

C

To execute user commands

D

To manage user sessions

Q50

Q50 What is a zombie process in Linux?

A

A process that is sleeping

B

A process that is currently running

C

A terminated process that has not been cleaned up by its parent

D

A process that is in the background

Q51

Q51 Which signal is sent to a process to terminate it immediately?

A

SIGINT

B

SIGTERM

C

SIGKILL

D

SIGHUP

Q52

Q52 How do you put a currently running job into the background?

A

fg

B

bg

C

ctrl+c

D

ctrl+z

Q53

Q53 How do you kill a process with the process ID 1234?

A

kill -9 1234

B

killall 1234

C

kill -KILL 1234

D

terminate 1234

Q54

Q54 How do you display a real-time view of running processes, showing system resource usage?

A

ps

B

ls

C

top

D

jobs

Q55

Q55 A user reports that a process is consuming too much CPU.
Which command can help identify this process?

A

ps

B

ls

C

top

D

jobs

Q56

Q56 A user has started a process in the background but now wants to bring it to the foreground.
Which command should they use?

A

fg

B

bg

C

kill

D

jobs

Q57

Q57 A process is stuck and not responding to SIGTERM.
What is the most effective way to kill it?

A

kill -15 PID

B

kill -1 PID

C

kill -9 PID

D

kill -HUP PID

Q58

Q58 What is a shell script in Linux?

A

A compiled program

B

A series of commands written in a file

C

A binary executable

D

A system call

Q59

Q59 Which of the following is used to make a shell script executable?

A

chmod +x script.sh

B

chmod u+x script.sh

C

chmod 777 script.sh

D

chmod 755 script.sh

Q60

Q60 What is the purpose of the shebang (#!) in a shell script?

A

To comment the script

B

To specify the script's interpreter

C

To define variables

D

To provide execution permissions

ad verticalad vertical
ad