010-100 · Question #74
Which of the following commands will display a list all files in the current directory including the hidden files?
The correct answer is A. ls -a. The ls command's -a flag lists all files including hidden ones (those whose names begin with a dot). No other listed option correctly performs this function.
Question
Which of the following commands will display a list all files in the current directory including the hidden files?
Options
- Als -a
- Bls --hidden
- Cls -h
- Dls --a
How the community answered
(21 responses)- A71% (15)
- B5% (1)
- C14% (3)
- D10% (2)
Why each option
The ls command's -a flag lists all files including hidden ones (those whose names begin with a dot). No other listed option correctly performs this function.
The -a (or --all) flag for ls instructs it to not ignore entries starting with a dot, which is the convention Linux uses for hidden files. This reveals files like .bashrc and .profile that are otherwise omitted from directory listings.
ls --hidden is not a valid option for the ls command and will return an error; the correct long form is --all.
ls -h enables human-readable file size output (e.g., KB, MB) and has no effect on displaying hidden files.
ls --a is not a valid option and will produce an error; the correct short flag is -a and the correct long option is --all.
Concept tested: Listing hidden files using ls command flags
Source: https://man7.org/linux/man-pages/man1/ls.1.html
Topics
Community Discussion
No community discussion yet for this question.