The -l option shows a detailed list of files and directories. It includes permissions, number of links, owner, group, size, and modification date.
Click to reveal answer
beginner
What is the purpose of the -a option in ls?
The -a option shows all files, including hidden files that start with a dot (.), which are normally not shown.
Click to reveal answer
beginner
Explain what the -h option does when used with ls -l.
The -h option makes file sizes easier to read by showing them in human-friendly units like KB, MB, or GB instead of bytes.
Click to reveal answer
intermediate
What does the -R option do in the ls command?
The -R option lists directories and their contents recursively, showing all files and folders inside subdirectories.
Click to reveal answer
intermediate
How would you combine ls options to see all files with detailed info and human-readable sizes?
Use ls -lah. This shows all files including hidden ones (-a), detailed info (-l), and human-readable sizes (-h).
Click to reveal answer
Which ls option shows hidden files?
A-l
B-h
C-a
D-R
✗ Incorrect
The -a option shows all files, including hidden ones starting with a dot.
What does ls -lh display?
AList files with permissions only
BList only hidden files
CList files recursively
DList files with detailed info and human-readable sizes
✗ Incorrect
-l shows detailed info and -h makes sizes human-readable.
Which option lists directory contents recursively?
A-R
B-h
C-l
D-a
✗ Incorrect
The -R option lists all directories and subdirectories recursively.
What information does ls -l NOT show?
AFile content
BFile size
CFile owner
DFile permissions
✗ Incorrect
ls -l shows metadata but not the actual content of files.
How do you show all files including hidden ones with detailed info?
Als -a
Bls -la
Cls -l
Dls -h
✗ Incorrect
ls -la combines -l for details and -a for hidden files.
Describe what each of these ls options does: -l, -a, -h, and -R.
Think about what you want to see: details, hidden files, easy sizes, or all folders inside folders.
You got /4 concepts.
How would you use ls options to list all files including hidden ones, with sizes easy to read, and detailed info?
Combine the options that show details, hidden files, and human-friendly sizes.
You got /4 concepts.
Practice
(1/5)
1. What does the ls -a command do in Linux?
easy
A. Shows all files including hidden ones
B. Lists files with detailed information
C. Displays file sizes in human-readable format
D. Lists files recursively in subdirectories
Solution
Step 1: Understand the -a option
The -a option in ls shows all files, including hidden files that start with a dot.
Step 2: Compare with other options
Other options like -l show details, -h shows sizes human-readable, and -R lists recursively.
Final Answer:
Shows all files including hidden ones -> Option A
Quick Check:
-a means show hidden files [OK]
Hint: Remember: 'a' for all files including hidden [OK]
Common Mistakes:
Confusing -a with -l for detailed info
Thinking -a shows sizes in human format
Assuming -a lists files recursively
2. Which of the following is the correct syntax to list files with detailed info and human-readable sizes?
easy
A. ls -la
B. ls -lR
C. ls -h -a
D. ls -lh
Solution
Step 1: Combine options for detailed and human-readable
The -l option shows detailed info, and -h makes sizes human-readable. Together, ls -lh is correct.
Step 2: Check option order and other choices
A (ls -la) shows detailed info including hidden files but misses human-readable sizes. C (ls -h -a) misses detailed info. D (ls -lR) lists recursively, not human-readable sizes.
Final Answer:
ls -lh -> Option D
Quick Check:
-l + -h = detailed + human sizes [OK]
Hint: Use -l and -h together for details and friendly sizes [OK]
Common Mistakes:
Mixing up option order and meaning
Using -h without -l for details
Confusing -R with -h
3. What will be the output of ls -lR in a directory with two subfolders, each containing files?
medium
A. Lists files in current directory only
B. Shows file sizes in human-readable format
C. Lists files with details in current and all subdirectories
D. Lists hidden files only
Solution
Step 1: Understand -lR options
-l lists files with details, and -R lists recursively through all subdirectories.
Step 2: Predict output behavior
The command will show detailed info for files in the current directory and all files in subfolders recursively.
Final Answer:
Lists files with details in current and all subdirectories -> Option C
Quick Check:
-lR = detailed + recursive listing [OK]
Hint: Remember -R means recursive, -l means detailed [OK]
Common Mistakes:
Thinking -R lists hidden files only
Assuming -lR shows human-readable sizes
Believing it lists only current directory
4. You ran ls hR but got an error: "ls: cannot access 'hR': No such file or directory". What is the likely cause?
medium
A. Options must be combined without spaces
B. You typed options together without a dash
C. Options order is incorrect
D. You used uppercase letters instead of lowercase
Solution
Step 1: Analyze the error message
The error "ls: cannot access 'hR': No such file or directory" suggests the shell interpreted 'hR' as a file or directory name.
Step 2: Identify correct option syntax
Options must be preceded by a dash and can be combined like -hR. Typing ls hR without dash causes the shell to treat 'hR' as a filename.
Final Answer:
You typed options together without a dash -> Option B
Quick Check:
Options need dash prefix [OK]
Hint: Always prefix options with a dash (-) [OK]
Common Mistakes:
Using uppercase instead of lowercase options
Putting spaces between dash and options
Assuming option order matters
5. You want to list all files including hidden ones, with detailed info and human-readable sizes, recursively through all subdirectories. Which command should you use?
hard
A. ls -alhR
B. ls -lha
C. ls -aRl
D. ls -l -a -h
Solution
Step 1: Identify needed options
You need -a for hidden files, -l for detailed info, -h for human-readable sizes, and -R for recursive listing.
Step 2: Combine options correctly
All options can be combined as -alhR. ls -alhR: ls -alhR includes all needed options.
Step 3: Check other options
B (ls -lha) misses recursive -R. C (ls -aRl) includes all options but order does not matter in Linux, so it is also correct. D (ls -l -a -h) misses recursive -R.
Final Answer:
ls -alhR -> Option A
Quick Check:
All needed options combined = ls -alhR [OK]
Hint: Combine all needed options with one dash for full listing [OK]
Common Mistakes:
Forgetting -R for recursion
Not combining options properly
Using options without dash
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.