0

operating systems Online Quiz - 8

Description: operating systems Online Quiz - 8
Number of Questions: 20
Created by:
Tags: operating systems
Attempted 0/20 Correct 0 Score 0

In vi if we want to replace any string e.g. "NAME" with "name" from line number 1 to 10 only, what command we can use?

  1. :%s/NAME/name/

  2. :1-10s/NAME/name/

  3. :1,10s/NAME/name/

  4. :s/NAME/name/


Correct Option: C

How to check the exit status of the previous command?

  1. $?

  2. $$

  3. $#

  4. $@


Correct Option: A

what is the command to change ownership of a file?

  1. change

  2. setfscl

  3. chown

  4. chmod


Correct Option: C

echo this || echo that && echo other What will be the output?

  1. this

  2. that

  3. this other

  4. this that other


Correct Option: C

AI Explanation

To understand the output of the given command, let's break it down:

The command is: echo this || echo that && echo other

The echo command is used to display a message on the console.

The || operator is the logical OR operator, which means that if the command on the left side of || fails (returns a non-zero exit status), then the command on the right side of || will be executed.

The && operator is the logical AND operator, which means that if the command on the left side of && succeeds (returns a zero exit status), then the command on the right side of && will be executed.

Now, let's evaluate the given command:

  1. echo this - This command will be executed regardless of the previous command's exit status. It will display "this" on the console.

  2. echo that - This command will not be executed because the previous command (echo this) was successful and returned a zero exit status.

  3. echo other - This command will be executed because the previous command (echo this) was successful. It will display "other" on the console.

Therefore, the output of the given command will be "this other", which corresponds to option C.

How could you check if two strings are equal?

  1. test $a -eq $b

  2. test a -eq b

  3. test $a -equal $b

  4. test $a = $b


Correct Option: D

Which of the following would return the process ID of the sleep command?

  1. sleep 1 & echo $!

  2. sleep 1 & echo $?

  3. sleep 1 & echo $#

  4. sleep 1 & echo $$


Correct Option: A

Which command will create a soft link to a file?

  1. ls -n

  2. ln

  3. ln -s

  4. link -s


Correct Option: C

How to search recursively in the directory structure to list the file named file1?

  1. ls -lrt file1

  2. ls -lR file1

  3. find . -s file1

  4. find . -name file1


Correct Option: D

How can you determine the number of positional parameter passed to the script ?

  1. $# will print the same

  2. $? will print the same

  3. $! will print the same

  4. $$ will print the same


Correct Option: A

"What will be the output of following command var=hello varx=goodbye echo ${var}x"

  1. goodbye

  2. hello

  3. hellox

  4. hellogoodbye


Correct Option: C

How can we know two text files are identical?

  1. if the output of “cmp -s file1 file2” is not zero

  2. if the output of “cmp -s file1 file2” is zero

  3. if the output of “cmp -s file1 file2” is one

  4. if the output of “cmp -diff file1 file2” is zero


Correct Option: B

The purpose of the nohup command is to prevent programs from closing when you log out. True or False?

  1. True

  2. False


Correct Option: A

Which one of the following PIDs is assigned to the init program?

  1. 0

  2. 1

  3. 2

  4. 100


Correct Option: B

How can the time stamps of a file be preserved while copying a file?

  1. cp -i

  2. cp -r

  3. cp -p

  4. cp -R


Correct Option: C

How to send a running process to background?

  1. ctrl+c then bg

  2. ctrl+z then bg

  3. ctlr+m then bg

  4. ctrl+z then fg


Correct Option: B

"what does the command do? find . -type f -mtime 2"

  1. list all ordinary files in current dir that have been modified within last 24 hours

  2. list all ordinary files in current dir that have been modified within last 4 days

  3. list all ordinary files in current dir that have been modified within last 48 hrs

  4. list all ordinary files in current dir that have been modified within last 2 hrs


Correct Option: C

AI Explanation

To answer this question, let's break down the command and its options:

The command "find" is used to search for files and directories within a given directory hierarchy.

The dot (.) represents the current directory.

The option "-type f" is used to specify that the search should only include ordinary files (not directories or other types of files).

The option "-mtime 2" is used to specify that the search should include files that have been modified within the last 48 hours. The number 2 represents the number of days.

Therefore, the correct answer is C) list all ordinary files in the current directory that have been modified within the last 48 hours.

what is the name of the data structure to maintain file identification?

  1. inode

  2. filter

  3. kernel

  4. shell


Correct Option: A

How to save the output of any command in a file as well as display the same on the VDU?

  1. echo “hello world” > temp.txt

  2. echo “hello world” | tee temp.txt

  3. echo "hello world">tmp.txt|tee tmp.txt

  4. echo "hello world">tmp.txt|print


Correct Option: B

Which of the following will list the directories from the current working path.

  1. ls -l | grep ^d

  2. ls | grep dir

  3. ls | grep ^d

  4. pwd


Correct Option: A

How can you print the first 10 line of a file

  1. head +10 file

  2. cat file

  3. tail -10 file

  4. head -10 file


Correct Option: D
- Hide questions