Cheat Sheet #day42 - ls

ls Cheatsheet
Basic Usage
List Files and Directories
lsList Files and Directories with Details
ls -l
Common Options
List All Files (Including Hidden)
ls -aList All Files with Details
ls -laList Files in Human-Readable Format
ls -lhList Files in Reverse Order
ls -rSort Files by Modification Time
ls -tSort Files by Size
ls -SSort Files by Extension
ls -XDisplay Directory Entries Instead of Contents
ls -d */List Only Directories
ls -d */Colorize the Output
ls --color=auto
Combining Options
List All Files, Including Hidden, with Human-Readable Sizes
ls -lhaList Files Sorted by Modification Time with Details
ls -ltList Files Sorted by Size in Human-Readable Format
ls -lhSList Files with Details, Sorted by Extension
ls -lX
Useful Tips
List Files with Detailed Information Including Timestamps
ls -l --time-style=full-isoList Files with Inode Numbers
ls -iList Files Recursively
ls -RList Files with Detailed Information Including File Type
ls -FList Only the File Names
ls -1
Advanced Options
List Files with Contextual Information (like
ls -l)ls -CGroup Directories First
ls --group-directories-firstIgnore Certain Files
ls --ignore="pattern"Display Help for
lsls --helpList Files with Detailed Information Including Context
ls -lcList Files with Access Time
ls -luList Files with Birth Time
ls -lt --time=birth
Examples
List All Files in
/etcDirectoryls -a /etcList Files in
/varDirectory in Human-Readable Formatls -lh /varList Files in
/homeDirectory Sorted by Modification Timels -lt /homeList Files in Current Directory with Details and Sorted by Size
ls -lSList Files in Current Directory with Full Timestamps
ls -l --time-style=full-isoList Files in Current Directory with Inode Numbers
ls -iList Files in Current Directory Recursively
ls -RList Files in Current Directory with File Types
ls -F
This cheatsheet covers essential commands and options for using ls effectively, from basic listing and formatting to advanced sorting and filtering. Adjust the commands according to your specific requirements and environment.




