0

Basic File operation Unix Quiz

Description: Basic File operation Unix Quiz
Number of Questions: 5
Created by:
Tags: unix
Attempted 0/5 Correct 0 Score 0

What command will give you a long listing of a directory AND include hidden files?

  1. ls -la

  2. ls -a

  3. ls -xv

  4. rm -rf *


Correct Option: B

AI Explanation

To answer this question, let's go through each option to understand why it is correct or incorrect:

Option A) ls -la - This option will give a long listing of a directory, but it includes hidden files as well. The "-a" flag is used to include hidden files and directories.

Option B) ls -a - This option is the correct answer. It will give a long listing of a directory and include hidden files. The "-a" flag is used to include hidden files and directories.

Option C) ls -xv - This option is incorrect. The "-xv" flags are not used to include hidden files or give a long listing. The "-x" flag is used to sort files by extension, and the "-v" flag is used to sort files by version.

Option D) rm -rf * - This option is incorrect. The "rm" command is used to remove files and directories, not to list them. The "-rf" flags are used to forcefully remove files and directories, and the "*" is a wildcard that represents all files and directories in the current directory.

The correct answer is Option B) ls -a. This option is correct because it will give a long listing of a directory and include hidden files.

How do you move up level folder level?

  1. cd .

  2. cd ..

  3. cd ~

  4. cd


Correct Option: B

How do you delete a file?

  1. mv filename

  2. cp filename

  3. rm filename

  4. rm -rf *


Correct Option: C

AI Explanation

To delete a file, you can use the rm command in a terminal. Let's go through each option to understand why it is correct or incorrect:

Option A) mv filename - This option is incorrect because the mv command is used to move or rename files, not delete them.

Option B) cp filename - This option is incorrect because the cp command is used to copy files, not delete them.

Option C) rm filename - This option is correct because the rm command is used to remove/delete files. By providing the filename as an argument, you can delete the specific file.

Option D) rm -rf * - This option is incorrect because the rm -rf * command is used to forcefully delete all files and directories in the current directory. It is a dangerous command and should be used with caution.

The correct answer is Option C) rm filename. This option is correct because it uses the rm command to delete the specified file.

How do you delete a directory?

  1. rm directory

  2. mv directory

  3. cd directory

  4. rmdir directory


Correct Option: D

How do you rename a file?

  1. mv oldfilename newfilename

  2. touch oldfilename newfilename

  3. cp oldfilename newfilename

  4. rm -rf *


Correct Option: A
- Hide questions