nerdexam
LPI

010-100 · Question #72

When creating a new file, what can be done to make the file hidden from the default output of the ls command?

The correct answer is B. Hide the file with a name beginning with a period like .foobar.txt. On Linux and Unix systems, any file or directory whose name begins with a period is treated as hidden and omitted from the default ls output.

Finding Your Way on a Linux System

Question

When creating a new file, what can be done to make the file hidden from the default output of the ls command?

Options

  • AHide the file with a name commented out with a hash sign like #foobar.txt.
  • BHide the file with a name beginning with a period like .foobar.txt.
  • CHide the file with chvis +h filename.
  • DHide the file with chmod a+h filename.
  • EHide the file with hide filename.

How the community answered

(23 responses)
  • A
    4% (1)
  • B
    78% (18)
  • C
    13% (3)
  • E
    4% (1)

Why each option

On Linux and Unix systems, any file or directory whose name begins with a period is treated as hidden and omitted from the default ls output.

AHide the file with a name commented out with a hash sign like #foobar.txt.

A hash sign in a filename has no special meaning to the filesystem or ls; the file would still appear in normal ls output.

BHide the file with a name beginning with a period like .foobar.txt.Correct

The Linux filesystem convention is that files with names beginning with a dot (.) are considered hidden. The ls command omits them from default output; they are only shown when using ls -a or ls -A. This is purely a naming convention enforced by user-space tools, not a filesystem permission or attribute.

CHide the file with chvis +h filename.

chvis is not a valid Linux command; no such utility exists for hiding files.

DHide the file with chmod a+h filename.

chmod manages read, write, and execute permissions; there is no +h permission flag, and permissions do not control visibility in ls output.

EHide the file with hide filename.

hide is not a standard Linux command; no such built-in utility exists for hiding files.

Concept tested: Hidden files using dot-prefix naming convention in Linux

Source: https://www.gnu.org/software/coreutils/manual/html_node/ls-invocation.html

Topics

#hidden files#dot files#file naming#ls command

Community Discussion

No community discussion yet for this question.

Full 010-100 Practice