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:
ls
List the contents of a specific directory:
ls /path/to/directory
List the contents with more details (permissions, ownership, size, modification date):
ls -l
List all files, including hidden ones (starting with a dot):
ls -a
Combine options to list all files with details:
ls -la
List the contents with human-readable file sizes:
ls -lh
Windows (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:
ls
List all files, including hidden ones:
ls -Force
List all files with detailed information:
ls -Long
You can also use the Get-ChildItem
cmdlet directly with similar options:
Get-ChildItem -Force