Challenge - 5 Problems
ls Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
What is the output of
ls -l in a directory with one file named file.txt?You run the command
ls -l in a directory containing a single file named file.txt. What will the output look like?Linux CLI
ls -l
Attempts:
2 left
💡 Hint
The
-l option shows detailed info including permissions, owner, size, and date.✗ Incorrect
The
ls -l command lists files with detailed info. It starts with a line showing total blocks (usually 0 or more), then one line per file with permissions, links, owner, group, size, date, and name.💻 Command Output
intermediate2:00remaining
What does
ls -a show in a directory with files file1, .hidden?You run
ls -a in a directory containing two files: file1 and .hidden. What will the output be?Linux CLI
ls -a
Attempts:
2 left
💡 Hint
The
-a option shows all files, including hidden and special entries.✗ Incorrect
The
ls -a command lists all files including hidden files (those starting with a dot) and the special entries . (current directory) and .. (parent directory).📝 Syntax
advanced2:00remaining
Which
ls command lists files sorted by modification time, newest first?You want to list files sorted by modification time, newest first. Which command is correct?
Attempts:
2 left
💡 Hint
The
-t option sorts by modification time, -r reverses order.✗ Incorrect
ls -lt lists files in long format sorted by modification time, newest first. Adding -r reverses order (oldest first). -lS sorts by size, -ltu sorts by access time.🔧 Debug
advanced2:00remaining
Why does
ls -l /nonexistent produce an error?You run
ls -l /nonexistent but get an error message. What is the reason?Attempts:
2 left
💡 Hint
Check if the directory exists before listing.
✗ Incorrect
The error occurs because the directory /nonexistent does not exist.
ls cannot list files in a directory that is missing.🚀 Application
expert2:00remaining
How to list only directories in current folder using
ls and shell features?You want to list only directories (not files) in the current folder using
ls combined with shell commands. Which command achieves this?Attempts:
2 left
💡 Hint
The
-d option lists directories themselves, and */ matches directories.✗ Incorrect
ls -d */ lists only directories in the current folder by matching names ending with a slash. Other options may list files or rely on parsing output which can be unreliable.