ls
ls: list directory contents.
The ls command is used to list the contents of a directory. It is one of the most commonly used commands when working in the command line. The ls command can be used with various options to display different types of information about files and directories.
Examples
Linux/macOS
List the contents of the current directory:
lsList the contents of a specific directory:
ls /path/to/directoryList the contents with more details (permissions, ownership, size, modification date):
ls -lList all files, including hidden ones (starting with a dot):
ls -aCombine options to list all files with details:
ls -laList the contents with human-readable file sizes:
ls -lhWindows (PowerShell)
PowerShell supports ls as an alias for its Get-ChildItem cmdlet. The behavior and options are somewhat different from Unix systems but provide similar functionality.
List files and directories:
lsList all files, including hidden ones:
ls -ForceList all files with detailed information:
ls -LongYou can also use the Get-ChildItem cmdlet directly with similar options:
Get-ChildItem -Force