0
0
Linux CLIscripting~10 mins

ls options (-l, -a, -h, -R) in Linux CLI - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - ls options (-l, -a, -h, -R)
Start: ls command
Check options
List detailed
Combine effects
Display output
End
The ls command checks which options are used (-l, -a, -h, -R), applies their effects, combines them if multiple, then shows the output.
Execution Sample
Linux CLI
ls -l -a -h -R
Lists all files and folders with details, human-readable sizes, including hidden files, recursively.
Execution Table
StepOption CheckedEffectOutput ExampleNotes
1-lShow detailed info (permissions, owner, size, date)-rw-r--r-- 1 user group 1234 Apr 27 10:00 file.txtLists files with details
2-aInclude hidden files (names starting with .).bashrc .file.txt folderShows all files including hidden
3-hShow sizes in human-readable format (K, M)1.2K, 3.4MMakes sizes easy to read
4-RList directories recursivelyfolder: file1 subfolder: file2Shows contents of subfolders too
5Combine allDetailed + all files + human sizes + recursiveFull detailed recursive list including hidden files with human sizesAll options work together
6EndCommand finishesOutput shown on screen
💡 All options processed, output displayed, command ends
Variable Tracker
VariableStartAfter -lAfter -aAfter -hAfter -RFinal
file_listvisible files onlydetailed info addedhidden files includedsizes in human-readable formatrecursive folders includedfull detailed recursive list with hidden files and human sizes
Key Moments - 3 Insights
Why do hidden files only appear after using -a?
Because by default ls hides files starting with '.', and -a tells ls to include them. See execution_table row 2 where -a adds hidden files.
How does -h change the size display?
It converts raw byte counts into human-friendly units like K (kilobytes) or M (megabytes), as shown in execution_table row 3.
What does -R do differently compared to no option?
-R makes ls list all subdirectories recursively, not just the current folder. See execution_table row 4 for example output.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what effect does the -a option have on the file list?
AIncludes hidden files starting with '.'
BShows file sizes in bytes
CLists files recursively
DShows detailed file permissions
💡 Hint
Check execution_table row 2 for the effect of -a
At which step does ls start showing sizes in human-readable format?
AStep 1
BStep 3
CStep 2
DStep 4
💡 Hint
Look at execution_table row 3 describing -h option
If you remove the -R option, what changes in the output?
AHidden files will not show
BSizes will not be human-readable
CSubdirectories will not be listed recursively
DFile details will not show
💡 Hint
See execution_table row 4 about -R recursive listing
Concept Snapshot
ls command options:
-l : show detailed info (permissions, owner, size, date)
-a : include hidden files (names starting with '.')
-h : show sizes in human-readable units (K, M)
-R : list directories recursively
Combine options to customize output
Full Transcript
The ls command lists files and folders. Using options changes what you see. The -l option shows detailed info like permissions and size. The -a option includes hidden files that start with a dot. The -h option makes file sizes easier to read by using units like K or M. The -R option lists all folders inside folders, showing everything recursively. You can use these options together to get detailed, complete, and easy-to-read file lists. The command checks each option, applies its effect, combines them, then shows the final output.