Multiple choice technology operating systems

An alternative to ls command

  1. dir

  2. list

  3. echo *

  4. cat

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

'echo *' is an alternative to the 'ls' command. The asterisk is a wildcard that expands to all files in the current directory, and echo prints them. While ls provides formatted output with details like permissions and timestamps, 'echo *' simply lists the filenames. 'dir' is a DOS/Windows command, not Unix. 'list' is not a standard Unix command, and 'cat' displays file contents, not directory listings.

AI explanation

To answer this question, we need to understand the purpose of the "ls" command and compare it to the alternative options provided.

The "ls" command is used in Unix-like operating systems to list the files and directories in a directory. It provides information such as file names, permissions, sizes, and timestamps.

Let's go through each option to understand why it is correct or incorrect:

Option A) dir - This option is incorrect because "dir" is the equivalent command in Windows operating systems, not in Unix-like systems.

Option B) list - This option is incorrect because there is no "list" command in Unix-like operating systems.

Option C) echo * - This option is correct because "echo " will display the names of all the files and directories in the current directory, similar to the "ls" command. The asterisk () is a wildcard that represents all files and directories.

Option D) cat - This option is incorrect because the "cat" command is used to display the contents of a file, not to list files and directories.

The correct answer is Option C) echo *. This option is correct because it provides an alternative way to list the files and directories in the current directory, similar to the "ls" command.