ls
List files and folders
What it does
ls lists what is in a folder: the current one with no arguments, otherwise the one you name. -l gives a detailed list with permissions, owner, size and modification date, and -a adds hidden files, whose names start with a dot, such as .git and .env.
-h together with -l shows sizes in readable units, 4.0K or 12M instead of a byte count. Flags can be combined: ls -la is the same as ls -l -a.
Syntax
ls
ls <folder>
ls -la
ls -lh <folder>Examples
List all files, hidden ones included, in the long format
ls -lasame as:
ls -al,ls -l -a,ls -a -lls— list files-l— long format-a— hidden files too (starting with a dot)
List the files in the logs folder with sizes in KB and MB
ls -lh logssame as:
ls -hl logs,ls -l -h logs,ls -h -l logs-l— long format-h— human-readable sizeslogs— which folder to list