010-150 · Question #1
What is the first character for file or directory names if they should not be displayed by commands such as ls unless specifically requested?
The correct answer is B. . (dot). In Linux and Unix-like systems, files and directories beginning with a dot are treated as hidden and are not shown by default with ls or similar commands.
Question
What is the first character for file or directory names if they should not be displayed by commands such as ls unless specifically requested?
Options
- A\ (backslash)
- B. (dot)
- C
- (minus)
- D_ (underscore)
How the community answered
(26 responses)- A15% (4)
- B73% (19)
- C4% (1)
- D8% (2)
Why each option
In Linux and Unix-like systems, files and directories beginning with a dot are treated as hidden and are not shown by default with ls or similar commands.
A backslash is an escape character in shell syntax and has no special meaning as a filename prefix for hiding files.
The dot (.) as the first character of a filename is the Unix/Linux convention for marking a file or directory as hidden. Commands like ls omit these entries by default, and you must use ls -a or ls -A to reveal them. This behavior is built into the shell and standard utilities across all POSIX-compliant systems.
A leading hyphen-minus has no hiding effect - it can cause issues with some commands that interpret it as an option flag, but ls will still display such files.
An underscore prefix is a common naming convention in some languages for private variables but has no effect on file visibility in the filesystem.
Concept tested: Linux hidden file and directory naming convention
Source: https://www.gnu.org/software/coreutils/manual/coreutils.html#ls-invocation
Topics
Community Discussion
4B is correct. In Linux and Unix systems, any file or directory whose name begins with a dot is treated as hidden and will not appear in ls output unless you use the -a or -la flag to show all files.
I remember staring at this exact question and second-guessing myself for a second before I thought of files like .bashrc sitting quietly in my home directory, and that dot clicked right into place, B all the way. If you have ever typed ls -a and suddenly seen a bunch of files that were hiding in plain sight, you already know this one in your bones.
The muscle memory from ls -a is real, but for the exam just lock in that the dot prefix is the Linux hiding convention, not a permission or attribute flag, so you can eliminate C and D fast and never lose time second-guessing.
I actually leaned toward A at first because backslash feels special in shell contexts, but then I spun up a quick terminal and tried naming a file with a dot prefix and ran ls, and sure enough it vanished from the output until I added the -a flag. That hands-on check reminded me that the dot convention for hidden files goes all the way back to early Unix, so B is the one to lock in.