{"id":157721,"date":"2024-07-22T01:45:56","date_gmt":"2024-07-21T22:45:56","guid":{"rendered":"https:\/\/computingforgeeks.com\/?p=157721"},"modified":"2024-07-22T11:19:18","modified_gmt":"2024-07-22T08:19:18","slug":"30-essential-linux-ls-commands-with-examples","status":"publish","type":"post","link":"https:\/\/computingforgeeks.com\/30-essential-linux-ls-commands-with-examples\/","title":{"rendered":"30 Essential Linux ls Commands with Examples"},"content":{"rendered":"\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"576\" src=\"https:\/\/computingforgeeks.com\/wp-content\/uploads\/2024\/07\/30-linux-commands-with-examples-1024x576.png\" alt=\"\" class=\"wp-image-157731\" title=\"\" srcset=\"https:\/\/computingforgeeks.com\/wp-content\/uploads\/2024\/07\/30-linux-commands-with-examples-1024x576.png 1024w, https:\/\/computingforgeeks.com\/wp-content\/uploads\/2024\/07\/30-linux-commands-with-examples-300x169.png 300w, https:\/\/computingforgeeks.com\/wp-content\/uploads\/2024\/07\/30-linux-commands-with-examples-768x432.png 768w, https:\/\/computingforgeeks.com\/wp-content\/uploads\/2024\/07\/30-linux-commands-with-examples-1536x864.png 1536w, https:\/\/computingforgeeks.com\/wp-content\/uploads\/2024\/07\/30-linux-commands-with-examples-747x420.png 747w, https:\/\/computingforgeeks.com\/wp-content\/uploads\/2024\/07\/30-linux-commands-with-examples-696x392.png 696w, https:\/\/computingforgeeks.com\/wp-content\/uploads\/2024\/07\/30-linux-commands-with-examples-1068x601.png 1068w, https:\/\/computingforgeeks.com\/wp-content\/uploads\/2024\/07\/30-linux-commands-with-examples.png 1920w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Are you tired of often typing &#8220;<em>dir<\/em>&#8221; in Linux terminal only to remember the right command is &#8220;<em>ls<\/em>&#8220;?. In this comprehensive guide, we cover in detail the usage of <code>ls<\/code> command which in your gateway to interacting with with files and directories in a Linux system. We will use real-world examples that will empower you to:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>List, sort and filter files and directories more efficiently.<\/li>\n\n\n\n<li>Navigate Linux complex directory structures without struggle.<\/li>\n\n\n\n<li>Gain better insights into Linux file ownership and permissions.<\/li>\n\n\n\n<li>Elevate your skills to a Linux power user.<\/li>\n<\/ul>\n\n\n\n<p>The <code>ls<\/code> command is used to list the contents of directories in Linux. There are several options used to customize the output from <em>ls<\/em>. Here are 30 most useful <code>ls<\/code> commands for beginners and seasoned Linux pro uses.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1. Basic <code>ls<\/code> Command<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>$<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\"> ls<\/mark>\narchive1.tar.gz  archive3.tar.gz  archive5.tar.gz  dir2  file1.txt  file3.txt  file5.txt   image2.jpg  image4.jpg  script1.sh  script3.sh  script5.sh\narchive2.tar.gz  archive4.tar.gz  dir1             dir3  file2.txt  file4.txt  image1.jpg  image3.jpg  image5.jpg  script2.sh  script4.sh<\/code><\/pre>\n\n\n\n<p>Lists files and directories in the current directory.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2. List with Detailed Information <code>-l<\/code><\/h3>\n\n\n\n<p>If you want to display detailed information about the files including permissions, owner, group, number of links, size, and modification date use <code>-l<\/code> option.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\">ls -l<\/mark>\ntotal 92\n-rw-r--r-- 1 root root  565 Jul 20 19:26 archive1.tar.gz\n-rw-r--r-- 1 root root  336 Jul 20 19:26 archive2.tar.gz\n-rw-r--r-- 1 root root  669 Jul 20 19:26 archive3.tar.gz\n-rw-r--r-- 1 root root   80 Jul 20 19:26 archive4.tar.gz\n-rw-r--r-- 1 root root  457 Jul 20 19:26 archive5.tar.gz\ndrwxr-xr-x 5 root root 4096 Jul 20 19:26 dir1\ndrwxr-xr-x 5 root root 4096 Jul 20 19:26 dir2\ndrwxr-xr-x 5 root root 4096 Jul 20 19:26 dir3\n-rw-r--r-- 1 root root  562 Jul 20 19:26 file1.txt\n-rw-r--r-- 1 root root  280 Jul 20 19:26 file2.txt\n-rw-r--r-- 1 root root  809 Jul 20 19:26 file3.txt\n-rw-r--r-- 1 root root  479 Jul 20 19:26 file4.txt\n-rw-r--r-- 1 root root  169 Jul 20 19:26 file5.txt\n-rw-r--r-- 1 root root  626 Jul 20 19:26 image1.jpg\n-rw-r--r-- 1 root root  461 Jul 20 19:26 image2.jpg\n-rw-r--r-- 1 root root  461 Jul 20 19:26 image3.jpg\n-rw-r--r-- 1 root root  841 Jul 20 19:26 image4.jpg\n-rw-r--r-- 1 root root   33 Jul 20 19:26 image5.jpg\n-rw-r--r-- 1 root root  835 Jul 20 19:26 script1.sh\n-rw-r--r-- 1 root root  545 Jul 20 19:26 script2.sh\n-rw-r--r-- 1 root root  409 Jul 20 19:26 script3.sh\n-rw-r--r-- 1 root root  208 Jul 20 19:26 script4.sh\n-rw-r--r-- 1 root root  943 Jul 20 19:26 script5.sh<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">3. List All Files (Including Hidden) <code>-a<\/code><\/h3>\n\n\n\n<p>By using <code>-a<\/code> command option you will see hidden files (those starting with a dot) as seen in the following example.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\"> ls  -a<\/mark>\n.   archive1.tar.gz  archive3.tar.gz  archive5.tar.gz  dir2  file1.txt  file3.txt  file5.txt    <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-luminous-vivid-amber-color\">  .hidden2.conf  .hidden4.conf  <\/mark>image1.jpg  image3.jpg  image5.jpg  script2.sh  script4.sh\n..  archive2.tar.gz  archive4.tar.gz  dir1             dir3  file2.txt  file4.txt  .hidden1.conf  <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-luminous-vivid-amber-color\">.hidden3.conf  .hidden5.conf<\/mark>  image2.jpg  image4.jpg  script1.sh  script3.sh  script5.sh<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">4. List with Human-Readable Sizes <code>-h<\/code><\/h3>\n\n\n\n<p>If you want to show the file sizes in human-readable format (e.g., <em><strong>KB<\/strong><\/em>, <strong><em>MB<\/em><\/strong>), then use <code>-h<\/code> command option.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\"> ls -lh ~\/goharbor-prepare.tar<\/mark>\n-rw-r--r-- 1 root root <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\">203M<\/mark> Jul 20 17:38 \/root\/goharbor-prepare.tar<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">5. List Files by Modification Time <code>-t<\/code><\/h3>\n\n\n\n<p>Sorts the files by modification time, with the newest showing first by using <code>-t<\/code><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\"> ls -lht ~\/<\/mark>\ntotal 835M\ndrwxr-xr-x 5 root root 4.0K <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\">Jul 20 19:27 <\/mark>linux-ls\ndrwxr-xr-x 3 root root 4.0K Jul 20 18:44 myapp\ndrwxr-xr-x 3 root root 4.0K Jul 20 18:10 myproject\ndrwxr-xr-x 2 root root 4.0K Jul 20 18:05 django-app\n-rw-r--r-- 1 root root 203M Jul 20 17:38 goharbor-prepare.tar\ndrwxr-xr-x 3 root root 4.0K Jul 20 16:51 harbor\ndrwxr-xr-x 5 root root 4.0K Jul 20 00:02 quay\n-rw-r--r-- 1 root root 629M Jun  6 09:39 harbor-offline-installer-v2.11.0.tgz\n-rw-r--r-- 1 root root  12K Jun  6 09:39 harbor-online-installer-v2.11.0.tgz\n-rw-r--r-- 1 root root 3.8M May 15 17:19 starship-x86_64-unknown-linux-gnu.tar.gz\n-rw-r--r-- 1 root root   65 <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-cyan-blue-color\">May 15 17:19 <\/mark>starship-x86_64-unknown-linux-gnu.tar.gz.sha256<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">6. Reverse Order<\/h3>\n\n\n\n<p>To reverse the display order of the list, use <code>-r<\/code> command option:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\">ls -lhr ~\/<\/mark>\ntotal 835M\n-rw-r--r-- 1 root root   65 May 15 17:19 starship-x86_64-unknown-linux-gnu.tar.gz.sha256\n-rw-r--r-- 1 root root 3.8M May 15 17:19 starship-x86_64-unknown-linux-gnu.tar.gz\ndrwxr-xr-x 5 root root 4.0K Jul 20 00:02 quay\ndrwxr-xr-x 3 root root 4.0K Jul 20 18:10 myproject\ndrwxr-xr-x 3 root root 4.0K Jul 20 18:44 myapp\ndrwxr-xr-x 5 root root 4.0K Jul 20 19:27 linux-ls\n-rw-r--r-- 1 root root  12K Jun  6 09:39 harbor-online-installer-v2.11.0.tgz\n-rw-r--r-- 1 root root 629M Jun  6 09:39 harbor-offline-installer-v2.11.0.tgz\ndrwxr-xr-x 3 root root 4.0K Jul 20 16:51 harbor\n-rw-r--r-- 1 root root 203M Jul 20 17:38 goharbor-prepare.tar\ndrwxr-xr-x 2 root root 4.0K Jul 20 18:05 django-app<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">7. List Files Recursively<\/h3>\n\n\n\n<p>Lists all files and directories recursively.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\">ls -R ~\/<\/mark>\n\/root\/quay:\nconfig  postgres  storage\n\n\/root\/quay\/config:\nconfig.yaml\n\n\/root\/quay\/postgres:\nuserdata<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">8. List Only Directories<\/h3>\n\n\n\n<p>You can limit the output by only listing the directories in your current directory.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\"> ls -d *\/<\/mark>\ndir1\/  dir2\/  dir3\/<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">9. Long Listing of Specific Directory<\/h3>\n\n\n\n<p>Show detailed information for files in a specified directory by running the following commands.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ls -l \/path\/to\/directory<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">10. List Files with Wildcards<\/h3>\n\n\n\n<p>If you wish to list files matching a specific pattern (e.g., all <code>.txt<\/code> files), run:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\">ls *.txt<\/mark>\nfile1.txt  file2.txt  file3.txt  file4.txt  file5.txt\n\n$ <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-luminous-vivid-amber-color\">ls *.jpg<\/mark>\nimage1.jpg  image2.jpg  image3.jpg  image4.jpg  image5.jpg<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">11. List with File Type Indicators<\/h3>\n\n\n\n<p>Appends a character to each entry to indicate the file type (<code>\/<\/code> for directories, <code>*<\/code> for executables).<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ls -F<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">12. List Files by Size<\/h3>\n\n\n\n<p>Sort files by size, with the largest first using the following commands.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ls -lS<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">13. Classify Files by Type<\/h3>\n\n\n\n<p>This works similar to <code>-F<\/code>, classifies files by appending indicators.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ls --classify<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">14. List Directory Tree<\/h3>\n\n\n\n<p>Get a tree view of the directory structure using the following commands.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ls -R | grep \":$\"<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">15. List with Inode Numbers<\/h3>\n\n\n\n<p>Get the inode number count for each file by using <code>-i<\/code> option.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ls -i<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">16. List Files in Columns<\/h3>\n\n\n\n<p>Lists entries by column using <code>-C<\/code> commands.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ls -C<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">17. List Files with Access Time<\/h3>\n\n\n\n<p>To sort and display files by the by last access time use <code>-u<\/code><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\"> ls -ltu<\/mark>\ntotal 92\ndrwxr-xr-x 5 root root 4096 Jul 21 22:15 dir3\ndrwxr-xr-x 5 root root 4096 Jul 21 22:15 dir2\ndrwxr-xr-x 5 root root 4096 Jul 21 22:15 dir1\n-rw-r--r-- 1 root root  457 Jul 20 19:26 archive5.tar.gz\n-rw-r--r-- 1 root root   33 Jul 20 19:26 image5.jpg\n-rw-r--r-- 1 root root  943 Jul 20 19:26 script5.sh\n-rw-r--r-- 1 root root  169 Jul 20 19:26 file5.txt\n-rw-r--r-- 1 root root   80 Jul 20 19:26 archive4.tar.gz\n...<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">18. List Files with Change Time<\/h3>\n\n\n\n<p>Sort the output by and displays the last change time of file status information.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ls -lc<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">19. List with Colors<\/h3>\n\n\n\n<p>Use the <code>--color<\/code> command option to enable colorized output for better readability.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ls --color<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">20. List Only Names<\/h3>\n\n\n\n<p>Pass <code>-1<\/code> to the ls command to list one file per line.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ls -1<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">21. List Files in Reverse by Size<\/h3>\n\n\n\n<p>You can also sort files by size, you will see the smallest first.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\">  ls -lhSr ~\/<\/mark>\ntotal 835M\n-rw-r--r-- 1 root root   65 May 15 17:19 starship-x86_64-unknown-linux-gnu.tar.gz.sha256\ndrwxr-xr-x 5 root root 4.0K Jul 20 00:02 quay\ndrwxr-xr-x 3 root root 4.0K Jul 20 18:10 myproject\ndrwxr-xr-x 3 root root 4.0K Jul 20 18:44 myapp\ndrwxr-xr-x 5 root root 4.0K Jul 20 19:27 linux-ls\ndrwxr-xr-x 3 root root 4.0K Jul 20 16:51 harbor\ndrwxr-xr-x 2 root root 4.0K Jul 20 18:05 django-app\n-rw-r--r-- 1 root root  12K Jun  6 09:39 harbor-online-installer-v2.11.0.tgz\n-rw-r--r-- 1 root root 3.8M May 15 17:19 starship-x86_64-unknown-linux-gnu.tar.gz\n-rw-r--r-- 1 root root 203M Jul 20 17:38 goharbor-prepare.tar\n-rw-r--r-- 1 root root 629M Jun  6 09:39 harbor-offline-installer-v2.11.0.tgz<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">22. List Files in Reverse by Time<\/h3>\n\n\n\n<p>Let&#8217;s sort the files by modification time, and get the oldest as the first one.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ls -ltr<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">23. List Files by Extension<\/h3>\n\n\n\n<p>Sort alphabetically by file extension<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ls -X<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">24. List Files with Context<\/h3>\n\n\n\n<p>See the security context for each file using <code>--context<\/code><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ls --context<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">25. List with Quoting Styles<\/h3>\n\n\n\n<p>Get the output with quotes in the names of files.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ls -Q<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">26. List Files in Human-Readable Format with SI Units<\/h3>\n\n\n\n<p>List using the SI units for file sizes (e.g., 1K = 1000).<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ls -lh --si<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">27. List Files in Reverse by Extension<\/h3>\n\n\n\n<p>If you wish to sort files by extension, in reverse order, run the commands below.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ls -Xr<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">28. List Files and Show Only Directory Names<\/h3>\n\n\n\n<p>Displays only the directories in the current directory.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\">ls -d *\/<\/mark>\ndir1\/  dir2\/  dir3\/<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">29. List Files in Reverse Alphabetical Order<\/h3>\n\n\n\n<p>To reverse the order of the list, showing files in reverse alphabetical order, use <code>-r<\/code> command option:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ls -r<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">30. Combine Multiple Options<\/h3>\n\n\n\n<p>You can easily combine multiple options: example is to show all files, in long format, with human-readable sizes, and classifies file types.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ls -alhF<\/code><\/pre>\n\n\n\n<p>Below is a table summarizing the 30 <code>ls<\/code> command usage examples:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Command<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>ls<\/code><\/td><td>Lists files and directories in the current directory.<\/td><\/tr><tr><td><code>ls -l<\/code><\/td><td>Displays detailed information including permissions, number of links, owner, group, size, and modification date.<\/td><\/tr><tr><td><code>ls -a<\/code><\/td><td>Includes hidden files (those starting with a dot).<\/td><\/tr><tr><td><code>ls -lh<\/code><\/td><td>Shows file sizes in human-readable format (e.g., KB, MB).<\/td><\/tr><tr><td><code>ls -lt<\/code><\/td><td>Sorts by modification time, newest first.<\/td><\/tr><tr><td><code>ls -lr<\/code><\/td><td>Reverses the order of the list.<\/td><\/tr><tr><td><code>ls -R<\/code><\/td><td>Lists all files and directories recursively.<\/td><\/tr><tr><td><code>ls -d *\/<\/code><\/td><td>Lists only directories in the current directory.<\/td><\/tr><tr><td><code>ls -l \/path\/to\/directory<\/code><\/td><td>Shows detailed information for files in a specified directory.<\/td><\/tr><tr><td><code>ls *.txt<\/code><\/td><td>Lists files matching a pattern (e.g., all <code>.txt<\/code> files).<\/td><\/tr><tr><td><code>ls -F<\/code><\/td><td>Appends a character to each entry to indicate the file type (<code>\/<\/code> for directories, <code>*<\/code> for executables).<\/td><\/tr><tr><td><code>ls -lS<\/code><\/td><td>Sorts files by size, largest first.<\/td><\/tr><tr><td><code>ls --classify<\/code><\/td><td>Same as <code>-F<\/code>, classifies files by appending indicators.<\/td><\/tr><tr><td>`ls -R<\/td><td>grep &#8220;:$&#8221;`<\/td><\/tr><tr><td><code>ls -i<\/code><\/td><td>Displays the inode number for each file.<\/td><\/tr><tr><td><code>ls -C<\/code><\/td><td>Lists files in columns.<\/td><\/tr><tr><td><code>ls -lu<\/code><\/td><td>Sorts by and displays the last access time.<\/td><\/tr><tr><td><code>ls -lc<\/code><\/td><td>Sorts by and displays the last change time of file status information.<\/td><\/tr><tr><td><code>ls --color<\/code><\/td><td>Enables colorized output for better readability.<\/td><\/tr><tr><td><code>ls -1<\/code><\/td><td>Lists one file per line.<\/td><\/tr><tr><td><code>ls -lSr<\/code><\/td><td>Sorts files by size, smallest first.<\/td><\/tr><tr><td><code>ls -ltr<\/code><\/td><td>Sorts files by modification time, oldest first.<\/td><\/tr><tr><td><code>ls -X<\/code><\/td><td>Sorts files by extension.<\/td><\/tr><tr><td><code>ls --context<\/code><\/td><td>Displays security context for each file.<\/td><\/tr><tr><td><code>ls -Q<\/code><\/td><td>Quotes the names of files.<\/td><\/tr><tr><td><code>ls -lh --si<\/code><\/td><td>Uses SI units for file sizes (e.g., 1K = 1000).<\/td><\/tr><tr><td><code>ls -Xr<\/code><\/td><td>Sorts files by extension, in reverse order.<\/td><\/tr><tr><td><code>ls -d *\/<\/code><\/td><td>Displays only the directories in the current directory.<\/td><\/tr><tr><td><code>ls -r<\/code><\/td><td>Reverses the order of the list, showing files in reverse alphabetical order.<\/td><\/tr><tr><td><code>ls -alhF<\/code><\/td><td>Combines multiple options: shows all files, in long format, with human-readable sizes, and classifies file types.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>In this article we&#8217;ve provided a comprehensive usage of the <code>ls<\/code> command with examples. By mastering the common <code>ls<\/code>command options, you will start to navigate and manipulate the Linux filesystem easily.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Are you tired of often typing &#8220;dir&#8221; in Linux terminal only to remember the right command is &#8220;ls&#8220;?. In this comprehensive guide, we cover in detail the usage of ls command which in your gateway to interacting with with files and directories in a Linux system. We will use real-world examples that will empower you &#8230; <a title=\"30 Essential Linux ls Commands with Examples\" class=\"read-more\" href=\"https:\/\/computingforgeeks.com\/30-essential-linux-ls-commands-with-examples\/\" aria-label=\"Read more about 30 Essential Linux ls Commands with Examples\">Read more<\/a><\/p>\n","protected":false},"author":3,"featured_media":157731,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[299,50,832,9275],"tags":[39166,39167],"class_list":["post-157721","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-how-to","category-linux-tutorials","category-tech","category-terminal","tag-linux-ls","tag-ls-commands-linux"],"_links":{"self":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts\/157721","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/comments?post=157721"}],"version-history":[{"count":0,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts\/157721\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/media\/157731"}],"wp:attachment":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/media?parent=157721"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/categories?post=157721"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/tags?post=157721"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}