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

OptionsDescription
-lknown as a long format that displays detailed information about files and directories.
-aRepresent all files Include hidden files and directories in the listing.
-tSort files and directories by their last modification time, displaying the most recently modified ones first.
-rknown as reverse order which is used to reverse the default order of listing.
-SSort files and directories by their sizes, listing the largest ones first.
-RList files and directories recursively, including subdirectories.
-iknown as inode which displays the index number (inode) of each file and directory.
-gknown as group which displays the group ownership of files and directories instead of the owner.
-hPrint file sizes in human-readable format (e.g., 1K, 234M, 2G).
-dList directories themselves, rather than their contents.

Leave a Reply

Your email address will not be published. Required fields are marked *