ls is a Linux shell command that lists directory contents of files and directories. It provides valuable information about files, directories, and their attributes.
Syntax of `ls` command in Linux
ls [option] [file/directory]
‘ls’ will display the contents of the current directory. By default, ‘ls’ lists files and directories in alphabetical order.
Commonly Used Options in `ls` command in Linux
| Options | Description |
| -l | known as a long format that displays detailed information about files and directories. |
| -a | Represent all files Include hidden files and directories in the listing. |
| -t | Sort files and directories by their last modification time, displaying the most recently modified ones first. |
| -r | known as reverse order which is used to reverse the default order of listing. |
| -S | Sort files and directories by their sizes, listing the largest ones first. |
| -R | List files and directories recursively, including subdirectories. |
| -i | known as inode which displays the index number (inode) of each file and directory. |
| -g | known as group which displays the group ownership of files and directories instead of the owner. |
| -h | Print file sizes in human-readable format (e.g., 1K, 234M, 2G). |
| -d | List directories themselves, rather than their contents. |