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.
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)- A4% (1)
- B78% (18)
- C13% (3)
- E4% (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.
A hash sign in a filename has no special meaning to the filesystem or ls; the file would still appear in normal ls output.
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.
chvis is not a valid Linux command; no such utility exists for hiding files.
chmod manages read, write, and execute permissions; there is no +h permission flag, and permissions do not control visibility in ls output.
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
Community Discussion
No community discussion yet for this question.