Multiple choice technology operating systems

Which is the command used to create a file with zero bytes

  1. vi

  2. touch

  3. cat

  4. ls

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

The touch command in Unix creates a file with zero bytes if it doesn't exist, or updates the timestamp if it does. vi opens an editor (not for zero-byte creation), cat displays or concatenates files, and ls lists directory contents. touch is specifically designed for creating empty files or updating timestamps.

AI explanation

The Unix/Linux touch command, when given a filename that doesn't exist, creates a new empty (zero-byte) file with that name — its primary original purpose was updating file timestamps, but as a side effect it creates the file if absent. vi is a text editor (opening it doesn't necessarily create a file until you save), cat concatenates/displays file contents (and can create a file only via redirection, not the bare command), and ls merely lists directory contents. Only touch reliably and directly creates an empty file with a single invocation.