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!

Q121

Q121 Which file contains the list of mounted file systems in Unix?

A

/etc/mount

B

/etc/fstab

C

/mnt/fslist

D

/var/mntlist

Q122

Q122 What is an inode in Unix file systems?

A

A file permission

B

A data structure holding file metadata

C

A type of directory

D

A command

Q123

Q123 Which command is used to check and repair file systems in Unix?

A

fsrepair

B

chkdsk

C

fsck

D

diskcheck

Q124

Q124 How would you view the disk usage of a directory and its subdirectories in Unix?

A

df -h directory

B

du -h directory

C

ls -l directory

D

df directory

Q125

Q125 Which command mounts a file system in Unix, assuming /dev/sdb1 as the device and /mnt/data as the mount point?

A

mount /dev/sdb1 /mnt/data

B

mnt /dev/sdb1 /mnt/data

C

fsck /dev/sdb1

D

loadfs /mnt/data

Q126

Q126 A user receives a "disk full" error but has deleted files. What could be a probable issue?

A

Disk is corrupted

B

Inode limit reached

C

Permissions issue

D

Unmounted disk

Q127

Q127 A file system is read-only and cannot be modified. Which command could remount it with write permissions?

A

mount -r

B

mount -o rw,remount /dev/sda1

C

remount /dev/sda1

D

fsck -rw /dev/sda1

Q128

Q128 What is the purpose of an alias in Unix?

A

To create a user

B

To define a custom command

C

To edit a file

D

To open a new shell

Q129

Q129 Where can shell aliases be stored to persist across sessions in Unix?

A

.bash_profile

B

/etc/aliases

C

~/.alias

D

/bin/alias

Q130

Q130 Which command lists all defined aliases in the current shell?

A

alias -l

B

list-alias

C

alias

D

show-alias

Q131

Q131 How can you make a shell script run each time a new terminal session opens?

A

Place it in /bin

B

Add it to .bash_profile

C

Move to /usr/local/bin

D

Add to ~/.profile

Q132

Q132 How would you create an alias ll for ls -l?

A

alias ll='ls -l'

B

set ll=ls -l

C

alias ll="ls -l"

D

alias -set ll=ls -l

Q133

Q133 How would you remove an alias named myalias in the current session?

A

unalias myalias

B

rm myalias

C

delete myalias

D

unset myalias

Q134

Q134 An alias does not persist after logging out. What could resolve this?

A

Add it to .bash_profile

B

Create a new alias each session

C

Use unalias

D

Store in alias.log

Q135

Q135 An alias name conflicts with an existing command. What can you do to avoid this issue?

A

Use unalias first

B

Add to ~/.profile

C

Reboot the system

D

Create a function instead

Q136

Q136 What does the chmod command do in Unix?

A

Changes file permissions

B

Modifies user account

C

Displays file structure

D

Creates a directory

Q137

Q137 In Unix, what does a permission setting of 755 mean for a file?

A

Owner can read, write, execute; group and others can read, execute

B

All can read, write

C

Owner and group can write, execute

D

Others have no access

Q138

Q138 Which command allows you to change the ownership of a file in Unix?

A

chown

B

chmod

C

chperm

D

useradd

Q139

Q139 What does the umask command define in Unix?

A

File permissions for new files

B

Default group for new users

C

System access policies

D

Password settings

Q140

Q140 How would you set a file's permissions to rwxr--r-- in Unix?

A

chmod 777

B

chmod 744

C

chmod 755

D

chmod 754

Q141

Q141 Which command recursively changes permissions for all files and directories within a directory?

A

chmod -R

B

chperm

C

chown

D

chmod -a

Q142

Q142 A user cannot modify a file due to permission issues. Which command could resolve this if they are the owner?

A

chmod +x

B

chown user file

C

chmod 644

D

setperm

Q143

Q143 A user is denied access to a directory even with rwx permissions. What could be the issue?

A

File is locked

B

Wrong permissions on parent directory

C

File system is full

D

Directory is hidden

Q144

Q144 What does $? represent in shell scripting?

A

Process ID

B

Exit status of the last command

C

Parent process

D

User ID

Q145

Q145 Which command allows you to define functions within a shell script?

A

function

B

define

C

proc

D

func

Q146

Q146 What is the purpose of the trap command in shell scripting?

A

Traps errors

B

Handles signals

C

Prevents execution

D

Creates functions

Q147

Q147 How do you pass an argument to a shell script?

A

sh script arg1

B

script arg1

C

bash script

D

call script arg1

Q148

Q148 How would you create a for-loop in a shell script to iterate over files in a directory?

A

for file in dir

B

for each in dir

C

for file in *; do

D

do for file in

Q149

Q149 A script terminates unexpectedly upon receiving a SIGINT. How can this be handled in the script?

A

Add trap 'exit' SIGINT

B

Use ignore function

C

Edit permissions

D

Run in background

Q150

Q150 A shell script outputs an "unexpected end of file" error. What is the most likely cause?

A

Missing done or fi

B

Invalid loop

C

Infinite loop

D

Incorrect permissions

ad verticalad vertical
ad