unix banner

Unix Multiple Choice Questions (MCQs) and Answers

Master Unix 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 Unix concepts. Begin your placement preparation journey now!

Q31

Q31 A user cannot modify a file due to permission restrictions. What command can change this?

A

ls

B

chown

C

chmod

D

cp

Q32

Q32 A file cannot be deleted due to "Operation not permitted." What is the likely issue?

A

Directory is not empty

B

File is owned by another user

C

File is in a hidden directory

D

File is not executable

Q33

Q33 Which command is used to create a new directory in Unix?

A

mkdir

B

newdir

C

touch

D

cp

Q34

Q34 Which command displays the contents of a file in Unix?

A

display

B

cat

C

view

D

see

Q35

Q35 What is the function of the echo command in Unix?

A

Display file contents

B

Print text to screen

C

List directories

D

Create new file

Q36

Q36 Which command lists all files, including hidden files, in Unix?

A

ls -a

B

ls -l

C

ls -h

D

list

Q37

Q37 What is the function of the grep command in Unix?

A

Copy files

B

Find files

C

Search for patterns in text

D

List directory contents

Q38

Q38 How do you display the last 10 lines of a file in Unix?

A

last 10

B

tail

C

head -10

D

tail -10

Q39

Q39 Which command is used to rename a file in Unix?

A

mv

B

rename

C

cp

D

ren

Q40

Q40 How can you count the number of lines in a file in Unix?

A

count -l

B

wc -l

C

lines -c

D

file -l

Q41

Q41 How do you search for the word "example" in a file named file.txt using Unix?

A

find "example" file.txt

B

search example file.txt

C

grep "example" file.txt

D

grep example.txt "file"

Q42

Q42 A user tries to use the cp command but encounters a "Permission denied" error. What should they do?

A

Restart Unix

B

Use chmod to change permissions

C

Reboot the system

D

Use ls -a to list files

Q43

Q43 A file cannot be moved because it "does not exist." What could be the issue?

A

Incorrect file path

B

File is hidden

C

File has no permissions

D

Disk space is full

Q44

Q44 A script stops with a "Command not found" error. What should be checked first?

A

Environment variables

B

User permissions

C

Script format

D

File size

Q45

Q45 What is the purpose of a shell script in Unix?

A

To create graphical applications

B

To automate tasks

C

To debug code

D

To manage permissions

Q46

Q46 Which symbol is used to make a comment in a shell script?

A

#

B

//

C

*

D

$

Q47

Q47 What does the chmod +x script.sh command do?

A

Executes the script

B

Adds write permission

C

Adds execute permission

D

Displays script contents

Q48

Q48 Which command is used to execute a shell script?

A

run

B

execute

C

sh

D

exe

Q49

Q49 What does #!/bin/bash signify at the beginning of a shell script?

A

A comment

B

File location

C

Path to the interpreter

D

Path to home directory

Q50

Q50 How would you print "Hello, World!" in a shell script?

A

display "Hello, World!"

B

echo "Hello, World!"

C

print "Hello, World!"

D

say "Hello, World!"

Q51

Q51 How do you define a variable NAME with the value "Unix" in a shell script?

A

var NAME="Unix"

B

set NAME Unix

C

NAME="Unix"

D

variable NAME=Unix

Q52

Q52 Which command is used to read user input into a variable called INPUT?

A

input INPUT

B

read INPUT

C

enter INPUT

D

get INPUT

Q53

Q53 How do you check if a variable is equal to a specific value in a shell script?

A

if $variable == value

B

if [ "$variable" -eq value ]

C

if [ "$variable" = value ]

D

if test

Q54

Q54 A script is not executing due to permission issues. What command can fix this?

A

chmod +x script.sh

B

chown script.sh

C

chmod 644 script.sh

D

chmod -r script.sh

Q55

Q55 A script outputs "command not found." What is a likely cause?

A

Incorrect file path

B

Command is not in $PATH

C

Missing execute permissions

D

File is locked

Q56

Q56 A script fails with a "syntax error near unexpected token" message. What could be the reason?

A

Incorrect permissions

B

Command not in $PATH

C

Syntax error or missing quotes

D

File is hidden

Q57

Q57 Which command is used to view currently running processes in Unix?

A

ps

B

top

C

ls

D

who

Q58

Q58 What is the function of the kill command in Unix?

A

To view processes

B

To delete files

C

To terminate processes

D

To schedule processes

Q59

Q59 How would you pause a running process in Unix?

A

pause

B

hold

C

sleep

D

kill -STOP

Q60

Q60 What does the nice command do in Unix?

A

Changes file permissions

B

Sets process priority

C

Ends a process

D

Displays process tree

ad verticalad vertical
ad