79
64.8k

190+ Linux Programming Solved MCQs

These multiple-choice questions (MCQs) are designed to enhance your knowledge and understanding in the following areas: Master of Computer Applications (MCA) , Programming Languages .

Chapters

Chapter: Unit 2
101.

Which command will you use to see the available routes?

A. show route
B. route status
C. netstat -r
D. none of the mentioned
Answer» C. netstat -r
102.

The permission -rwxr-xr-t represented in octal expression will be

A. 0777
B. 1755
C. 1754
D. 2754
Answer» B. 1755
103.

With a umask value of 112, what is the default permission assigned to newly created regular file?

A. —x–x-wx
B. -rw-rw-r–
C. -r-xr-x-r–
D. -rw-rw-r–
Answer» D. -rw-rw-r–
104.

Which command is used to assign read-write permission to the owner?

A. chmod a+r file
B. chmod o+r file
C. chmod u=rw file
D. chmod og-r file
Answer» C. chmod u=rw file
105.

Given the command $ chmod o-w datafile

A. sets write permission to everyone for datafile
B. sets write permission to others for datafile
C. clears write permission to everyone for datafile
D. clears write permission to others for datafile
Answer» D. clears write permission to others for datafile
106.

Which of these commands will set the permissions on file textfile to read and write for the owner, read for the group, and nothing for everyone else?

A. chmod 046 textfile
B. chmod 640 textfile
C. chmod 310 textfile
D. chmod rw r nil textfile
Answer» B. chmod 640 textfile
107.

If you are a root user, how can you grand execute permission only for the owner of the file project1?

A. chmod +x project1
B. chmod u+x project1
C. chmod a+x project1
D. chmod U+X project1
Answer» B. chmod u+x project1
108.

A user executes the following command successfully: $ chmod +x file1.txt Which of the following is true of the output of this command?

A. The command results in adding execute permission to the user who ran this command
B. The command results in adding execute permission for the owner of the file
C. The command results in an error since the file is not an executable file
D. The command results in adding execute permission for all users (i.e., user,group & others)
Answer» D. The command results in adding execute permission for all users (i.e., user,group & others)
109.

What does chmod +t do?

A. wrong syntax
B. set effective userid for filename
C. set effective groupid for filename
D. set the sticky bit
Answer» D. set the sticky bit
110.

Which of the following umask settings doesn’t allow execute permission to be set by default on directory files

A. 222
B. 111
C. 000
D. 444
Answer» D. 444
111.

Which of the following umask settings allow execute permission to be set by default on regular files

A. 222
B. 111
C. 000
D. None of the given choices
Answer» D. None of the given choices
112.

The command chmod 4777 a.out

A. will set the suid bit of a.out
B. will set the suid bit of a.out only if the command is issued by root
C. is not a valid command
D. will set the sticky bit of a.out
Answer» A. will set the suid bit of a.out
Chapter: Unit 3
113.

The commonly used UNIX commands like date, Is, cat, etc. are stored in

A. /dev directory
B. /bin and /usr/bin directories
C. /unixdirecotry
D. /tmp directory
Answer» B. /bin and /usr/bin directories
114.

Which command is used to concatenate all files beginning with the string ‘emp’ and followed by non-numeric characters?

A. catemp{!0-9]
B. more [emp][!0-9]
C. cateemp[x-z]
D. catemp[a-z]
Answer» A. catemp{!0-9]
115.

Which command will be used to match the pattern agarwal, Aggarwal, Agggarwal and agrawal in the file named empl.1st?

A. grep “[aA]99*[ar][ra]wal” empl.1st
B. grepag* empl.1st
C. cutagrawal empl.1st
D. grepag[ra][ar]wal empl.1st
Answer» A. grep “[aA]99*[ar][ra]wal” empl.1st
116.

Which command is used to select those lines where the data lies between 7000 and 7999 at the end of the line of file empl.lit.

A. grep “$7…” empl.1st
B. grep “7…^” empl.1st
C. grep “7…$” empl.1st
D. grep ^7… empl.1st
Answer» C. grep “7…$” empl.1st
117.

Which command is used to select those lines that begin with a 2 in the tre file empl.1st?

A. grep “^2” empl.1st
B. grep “2…” empl.1st
C. grep “7^” empl.1st
D. grep “2^” empl.1st
Answer» A. grep “^2” empl.1st
118.

Which of the following commands is used to update access and modification times of a file?

A. grep
B. wc
C. touch
D. cat
Answer» C. touch
119.

The command that can be used to restrict incoming messages to a user is

A. mesg
B. halt
C. grep
D. sleep
Answer» A. mesg
120.

The command which transcribes the standard input to the standard output and also makes a copy of the same in a file is

A. tee
B. sort
C. tr
D. grep
Answer» C. tr
121.

What command is used to count the total number of lines, words, and characters contained in a file?

A. countw
B. wcount
C. wc
D. count p
Answer» C. wc
122.

What command is used to remove files?

A. dm
B. rm
C. delete
D. erase
Answer» B. rm
123.

What command is used with vi editor to delete a single character?

A. x
B. y
C. a
D. z
Answer» A. x
124.

What command is used to save the standard output in a file, as well as display it on the terminal?

A. tee
B. grep
C. cat
D. more
Answer» A. tee
125.

What command is used to count just the number of lines contained in a file?

A. wc –r
B. wc –w
C. wc –c
D. wc –l
Answer» D. wc –l
126.

What command is used to sort the lines of data in a file in reverse order?

A. sort –r
B. st
C. sh
D. sort
Answer» A. sort –r
127.

What shell's wild-card is used to match a single character?

A. [!ijk]
B. [ijk]
C. ?
D. *
Answer» C. ?
128.

Which of the following command lists the last 10 lines of a file?

A. grep
B. tail
C. head
D. cat
Answer» B. tail
129.

Which statement resumes the next iteration of a for, while, select, or untill loop?

A. continue
B. break
C. complete
D. command
Answer» B. break
130.

Which command can create environment variable?

A. export
B. set
C. read
D. none of the mentioned
Answer» D. none of the mentioned
131.

Which of the following is not a major Unix shell?

A. X Shell
B. C Shell
C. Bash Shell
D. Korn Shell
Answer» C. Bash Shell
132.

Which was the first Unix shell?

A. X Shell
B. C Shell
C. Bash Shell
D. Korn Shell
Answer» B. C Shell
133.

The purpose of the PATH variable is to

A. Show the current directory
B. Show the directory path of a file
C. Tells the shell what directories to search when a command is entered
D. Both A and C
Answer» C. Tells the shell what directories to search when a command is entered
134.

What special character is used to designate the users home directory in the C shell?

A. @
B. ~
C. &
D. $
Answer» C. &
135.

The shell in the Unix system is the

A. Outer layer of a seed
B. User interface with the operating system
C. Provides a prompt
D. Both (b) and (c)
Answer» A. Outer layer of a seed
136.

The asterisk is a meta-character which in the command "ls *.txt" means

A. Any single character
B. Any combination of one or more characters
C. Any combination of zero or more characters
D. None of the above
Answer» A. Any single character
137.

Which command runs the shell built-in command ‘command’ with the given argument?

A. builtin
B. caller
C. there is no command present for this purpose
D. none of the mentioned
Answer» A. builtin
138.

Which option of the command ‘cd’ use the actual filesystem path for cd..and the value of pwd?

A. -l
B. -L
C. -p
D. -P
Answer» D. -P
139.

Which command generates possible completions for string according to the and write it to standard output?

A. compgen
B. complete
C. continue
D. none of the mentioned
Answer» A. compgen
140.

Which command executes ‘command’ in place of the current process instead of creating a new process?

A. exec
B. command
C. trap
D. none of the mentioned
Answer» A. exec
141.

Which of the following is not a iterative construct in "bash"?

A. If
B. For
C. Until
D. While
Answer» C. Until
142.

Assuming the files fileA, fileB, fileAB, fileBC and fileABC, exist in a directory, which files match with the pattern file[ABC]?

A. fileA, fileB and fileABC
B. fileABC
C. fileA and fileB
D. fileAB, fileBC and fileABC
Answer» C. fileA and fileB
143.

What will be printed for the command below? $ grep –c “^echo” abc

A. The count of lines that do not contain the pattern echo in file abc
B. The count of lines which begin with the pattern echo in file abc
C. The count of lines that ends with the pattern echo in file abc
D. None of the above
Answer» B. The count of lines which begin with the pattern echo in file abc
144.

Which one is used to select only one copy of the repeated lines?

A. uniq -u
B. uniq -d
C. uniq -c
D. uniq –I
Answer» A. uniq -u
145.

Indicate the right option to search for BOB, Bob, BOb or BoB?

A. grep –i Bob files
B. grep ‘B[oO][bB]’ files
C. grep ‘[BOB]’ files
D. grep -v ‘Bob’ files
Answer» B. grep ‘B[oO][bB]’ files
146.

Indicate the right option to search for anything not a letter or number

A. grep ‘^[a-zA-Z0-9]’
B. grep ‘[^a-zA-Z0-9]’
C. grep ‘[a-zA-Z0-9]’
D. None of the above
Answer» B. grep ‘[^a-zA-Z0-9]’
147.

One of the entry of /etc/passwd file is shown below: user1:x:1111:2222:McqMate:/home/user1:/bin/bash Which among the following will print userid and home dir in the following pattern “user1:/home/user1”

A. awk `{print $1 “:” $6}` /etc/passwd
B. awk `{print $1 “:” $7}` /etc/passwd
C. awk `{print $2 “:” $6}` /etc/passwd
D. awk `{print $2 “:” $7}` /etc/passwd
Answer» A. awk `{print $1 “:” $6}` /etc/passwd
148.

who cut –d ” ” -f1 what is the ouput if the who command displays like this user1 tty 0 1234

A. user1
B. user1 tty 0 1234
C. tty
D. tty 0 1234
Answer» A. user1
Chapter: Unit 4
149.

FIFO Stands For :

A. Figure in Figure Out
B. First in First Out
C. File input File Output
D. None
Answer» B. First in First Out
150.

The set of possible names for a given type of IPC is called its

A. Process
B. Name Space
C. Connect
D. Communication
Answer» B. Name Space

Done Studing? Take A Test.

Great job completing your study session! Now it's time to put your knowledge to the test. Challenge yourself, see how much you've learned, and identify areas for improvement. Don’t worry, this is all part of the journey to mastery. Ready for the next step? Take a quiz to solidify what you've just studied.