Basic Unix Quiz - 1

Description: Basic Unix Quiz - 1
Number of Questions: 10
Created by:
Tags: unix
Attempted 0/10 Correct 0 Score 0
  1. ^pat

  2. $pat

  3. pat$

  4. pat^


Correct Option: A
Explanation:

To match the pattern "pat" at the beginning of a line using the grep command, the symbol ^ will be used.

Now let's go through each option and explain why it is right or wrong:

A. ^pat: This option is correct. The ^ symbol in a regular expression is used to match the pattern at the beginning of a line. Therefore, ^pat will match the pattern "pat" at the beginning of a line.

B. $pat: This option is incorrect. The $ symbol in a regular expression is used to match the pattern at the end of a line. Therefore, $pat will match the pattern "pat" at the end of a line, not at the beginning.

C. pat$: This option is incorrect. The $ symbol in a regular expression is used to match the pattern at the end of a line. Therefore, pat$ will match the pattern "pat" at the end of a line, not at the beginning.

D. pat^: This option is incorrect. The symbol ^ does not have any special meaning when it appears after the pattern. Therefore, pat^ will match the literal string "pat^" rather than the pattern "pat" at the beginning of a line.

The Answer is: A. ^pat

  1. chmod u x emp[l-3]

  2. chmod 777 emp*

  3. chmod u r ??? emp

  4. chmod 222 emp?


Correct Option: A

Which command sends the word count of the file infile to the newfile.

  1. wc infile >newfile

  2. wc newfile

  3. wc infile - newfile

  4. wc infile | newfile


Correct Option: A

Which command is used to remove the read permission of the file 'note' from both the group and others?

  1. chmod go r note

  2. chmod go rw note

  3. chmod go-x note

  4. chmod go-r, 4-x note


Correct Option: D

AI Explanation

To answer this question, we need to understand the chmod command and its options.

The chmod command is used to change the permissions of a file or directory. The permissions include read, write, and execute permissions for the owner, group, and others.

In this question, we want to remove the read permission for both the group and others from the file 'note'.

Let's go through each option to determine the correct command:

Option A) chmod go r note - This option sets the read permission for both the group and others. It does not remove the read permission. Therefore, this option is incorrect.

Option B) chmod go rw note - This option sets both the read and write permissions for both the group and others. It does not remove the read permission. Therefore, this option is incorrect.

Option C) chmod go-x note - This option removes the execute permission for both the group and others from the file 'note'. It does not remove the read permission. Therefore, this option is incorrect.

Option D) chmod go-r, 4-x note - This option removes the read permission for both the group and others from the file 'note'. It uses the symbolic mode of the chmod command. The 'go-r' part removes the read permission, and the '4-x' part is invalid syntax. Therefore, this option is incorrect.

The correct answer is A. chmod go r note. This option is correct because it removes the read permission for both the group and others from the file 'note'.

- Hide questions