010-160 practice question 8 of 15

Which command displays file names only and no additional information?

Full set: 81 questions
Answer options
A: ls -a Correct answer
B: ls -lh
C: ls -l
D: ls -alh
E: ls -nl
Correct Answer:
A. ls -a
Explanation

The ls command, by default, lists only the names of files and directories. The -a (or --all) option modifies this behavior to include entries that start with a . (dot), which are typically hidden. However, it does not change the output format. The command ls -a still displays only the filenames, just a more complete list of them. In contrast, any command using the -l option will display a "long listing format," which includes additional information such as permissions, ownership, size, and modification date.

Why Incorrect

B. ls -lh: The -l option enables a long listing format, and -h makes file sizes human-readable. This displays much more than just filenames.
C. ls -l: The -l option explicitly requests a long listing format, which includes multiple columns of metadata in addition to the filename.
D. ls -alh: This combination uses -l for a long listing format, showing significant additional information beyond just the filenames.
E. ls -nl: This combination also uses -l for a long listing format, with -n showing numeric user/group IDs instead of names.

References

1. GNU Coreutils Manual (ls invocation): The official documentation for ls specifies the function of each option. It describes the default output as listing only names and explicitly states that the -l option is used to "use a long listing format." The -a option is described as "do not ignore entries starting with .", which affects which files are listed, not the format of the listing itself.

Source: GNU Coreutils, ls invocation, Section 22.1. Available at: https://www.gnu.org/software/coreutils/manual/htmlnode/ls-invocation.html (Accessed under "General options" and "Which files are listed").

2. Linux Programmer's Manual (man page): The ls(1) man page is the primary reference on a Linux system. It states for the -l option: "use a long listing format." For the -a option, it states: "do not ignore entries starting with .". This confirms that -l adds information, while -a does not change the output format from filenames only.

Source: ls(1) — Linux manual page. (Accessible via man ls on any standard Linux distribution).

3. University of Chicago, Introduction to the Command Line: Course materials from the university's Research Computing Center explain that ls by itself lists files, ls -a lists all files including hidden ones, and ls -l provides a "long list" with details like permissions and ownership. This distinction is fundamental to command-line usage.

Source: University of Chicago, Research Computing Center, "Introduction to the Command Line," Section: "Navigating the Filesystem." Available at: https://rcc.uchicago.edu/docs/tutorials/kicp/command-line.html

Scroll to Top