{"id":109,"date":"2020-11-21T11:26:01","date_gmt":"2020-11-21T11:26:01","guid":{"rendered":"https:\/\/webhostingnoida.in\/blog\/?p=109"},"modified":"2021-07-21T11:35:36","modified_gmt":"2021-07-21T11:35:36","slug":"ls-command-examples-in-linux","status":"publish","type":"post","link":"https:\/\/webhostingnoida.in\/blog\/ls-command-examples-in-linux\/","title":{"rendered":"\u2018ls\u2019 Command Examples in Linux"},"content":{"rendered":"<p style=\"border: 0px; margin: 0px 0px 1.5em; padding: 0px; color: #3a3a3a; font-family: Muli, sans-serif; font-size: 17px;\"><a style=\"border: 0px; margin: 0px; padding: 0px; background-color: transparent; transition: color 0.1s ease-in-out 0s, background-color 0.1s ease-in-out 0s; text-decoration-line: underline; color: #bb0e30; outline: none 0px;\" href=\"https:\/\/www.tecmint.com\/tag\/linux-ls-command\/\" target=\"_blank\" rel=\"noopener\">ls command<\/a>\u00a0is one of the most frequently used command in Linux. I believe\u00a0<span style=\"border: 0px; margin: 0px; padding: 0px; font-weight: bold;\">ls<\/span>\u00a0command is the first command you may use when you get into the command prompt of Linux Box.<\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_83 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/webhostingnoida.in\/blog\/ls-command-examples-in-linux\/#1_List_Files_using_ls_with_no_option\" >1. List Files using ls with no option<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/webhostingnoida.in\/blog\/ls-command-examples-in-linux\/#2_List_Files_With_option_%E2%80%93l\" >2 List Files With option \u2013l<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/webhostingnoida.in\/blog\/ls-command-examples-in-linux\/#3_View_Hidden_Files\" >3. View Hidden Files<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/webhostingnoida.in\/blog\/ls-command-examples-in-linux\/#4_List_Files_with_Human_Readable_Format_with_option_-lh\" >4. List Files with Human Readable Format with option -lh<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/webhostingnoida.in\/blog\/ls-command-examples-in-linux\/#5_Display_Inode_number_of_File_or_Directory\" >5. Display Inode number of File or Directory<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/webhostingnoida.in\/blog\/ls-command-examples-in-linux\/#6_List_Files_and_Directories_with_%E2%80%98_Character_at_the_end\" >6. List Files and Directories with \u2018\/\u2019 Character at the end<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/webhostingnoida.in\/blog\/ls-command-examples-in-linux\/#7List_Files_in_Reverse_Order\" >7.List Files in Reverse Order<\/a><\/li><\/ul><\/nav><\/div>\n<h4><span class=\"ez-toc-section\" id=\"1_List_Files_using_ls_with_no_option\"><\/span>1. List Files using ls with no option<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p><strong>ls<\/strong>\u00a0with no option list files and directories in bare format where we won\u2019t be able to view details like file types, size, modified date and time, permission and links etc.<\/p>\n<pre><strong># ls<\/strong>\r\n\r\n0001.pcap        Desktop    Downloads         index.html   install.log.syslog  Pictures  Templates\r\nanaconda-ks.cfg  Documents  fbcmd_update.php  install.log  Music               Public    Videos<\/pre>\n<h4><span class=\"ez-toc-section\" id=\"2_List_Files_With_option_%E2%80%93l\"><\/span>2 List Files With option \u2013l<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p>Here,\u00a0<strong>ls -l<\/strong>\u00a0(<strong>-l<\/strong>\u00a0is character not one) shows file or directory, size, modified date and time, file or folder name and owner of file and its permission.<\/p>\n<pre><strong># ls -l<\/strong>\r\n\r\ntotal 176\r\n-rw-r--r--. 1 root root   683 Aug 19 09:59 0001.pcap\r\n-rw-------. 1 root root  1586 Jul 31 02:17 anaconda-ks.cfg\r\ndrwxr-xr-x. 2 root root  4096 Jul 31 02:48 Desktop\r\ndrwxr-xr-x. 2 root root  4096 Jul 31 02:48 Documents\r\ndrwxr-xr-x. 4 root root  4096 Aug 16 02:55 Downloads\r\n-rw-r--r--. 1 root root 21262 Aug 12 12:42 fbcmd_update.php\r\n-rw-r--r--. 1 root root 46701 Jul 31 09:58 index.html\r\n-rw-r--r--. 1 root root 48867 Jul 31 02:17 install.log\r\n-rw-r--r--. 1 root root 11439 Jul 31 02:13 install.log.syslog\r\ndrwxr-xr-x. 2 root root  4096 Jul 31 02:48 Music\r\ndrwxr-xr-x. 2 root root  4096 Jul 31 02:48 Pictures\r\ndrwxr-xr-x. 2 root root  4096 Jul 31 02:48 Public\r\ndrwxr-xr-x. 2 root root  4096 Jul 31 02:48 Templates\r\ndrwxr-xr-x. 2 root root  4096 Jul 31 02:48 Videos<\/pre>\n<h4><span class=\"ez-toc-section\" id=\"3_View_Hidden_Files\"><\/span>3. View Hidden Files<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p>List all files including hidden file starting with \u2018<strong>.<\/strong>\u2018.<\/p>\n<pre><strong># ls -a<\/strong>\r\n\r\n.                .bashrc  Documents         .gconfd          install.log         .nautilus     .pulse-cookie\r\n..               .cache   Downloads         .gnome2          install.log.syslog  .netstat.swp  .recently-used.xbel\r\n0001.pcap        .config  .elinks           .gnome2_private  .kde                .opera        .spice-vdagent\r\nanaconda-ks.cfg  .cshrc   .esd_auth         .gtk-bookmarks   .libreoffice        Pictures      .tcshrc\r\n.bash_history    .dbus    .fbcmd            .gvfs            .local              .pki          Templates\r\n.bash_logout     Desktop  fbcmd_update.php  .ICEauthority    .mozilla            Public        Videos\r\n.bash_profile    .digrc   .gconf            index.html       Music               .pulse        .wireshark<\/pre>\n<h4><span class=\"ez-toc-section\" id=\"4_List_Files_with_Human_Readable_Format_with_option_-lh\"><\/span>4. List Files with Human Readable Format with option -lh<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p>With combination of\u00a0<strong>-lh<\/strong>\u00a0option, shows sizes in human readable format.<\/p>\n<pre><strong># ls -lh<\/strong>\r\n\r\ntotal 176K\r\n-rw-r--r--. 1 root root  683 Aug 19 09:59 0001.pcap\r\n-rw-------. 1 root root 1.6K Jul 31 02:17 anaconda-ks.cfg\r\ndrwxr-xr-x. 2 root root 4.0K Jul 31 02:48 Desktop\r\ndrwxr-xr-x. 2 root root 4.0K Jul 31 02:48 Documents\r\ndrwxr-xr-x. 4 root root 4.0K Aug 16 02:55 Downloads\r\n-rw-r--r--. 1 root root  21K Aug 12 12:42 fbcmd_update.php\r\n-rw-r--r--. 1 root root  46K Jul 31 09:58 index.html\r\n-rw-r--r--. 1 root root  48K Jul 31 02:17 install.log\r\n-rw-r--r--. 1 root root  12K Jul 31 02:13 install.log.syslog\r\ndrwxr-xr-x. 2 root root 4.0K Jul 31 02:48 Music\r\ndrwxr-xr-x. 2 root root 4.0K Jul 31 02:48 Pictures\r\ndrwxr-xr-x. 2 root root 4.0K Jul 31 02:48 Public\r\ndrwxr-xr-x. 2 root root 4.0K Jul 31 02:48 Templates\r\ndrwxr-xr-x. 2 root root 4.0K Jul 31 02:48 Videos<\/pre>\n<h4><span class=\"ez-toc-section\" id=\"5_Display_Inode_number_of_File_or_Directory\"><\/span>5. Display Inode number of File or Directory<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p>We can see some number printed before file\u00a0<strong>\/<\/strong>\u00a0directory name. With\u00a0<strong>-i<\/strong>\u00a0options list file\u00a0<strong>\/<\/strong>\u00a0directory with inode number.<\/p>\n<pre><strong># ls -i<\/strong>\r\n\r\n20112 0001.pcap        23610 Documents         23793 index.html          23611 Music     23597 Templates\r\n23564 anaconda-ks.cfg  23595 Downloads            22 install.log         23612 Pictures  23613 Videos\r\n23594 Desktop          23585 fbcmd_update.php     35 install.log.syslog  23601 Public<\/pre>\n<h4><span class=\"ez-toc-section\" id=\"6_List_Files_and_Directories_with_%E2%80%98_Character_at_the_end\"><\/span>6. List Files and Directories with \u2018\/\u2019 Character at the end<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p>Using\u00a0<strong>-F<\/strong>\u00a0option with\u00a0<strong>ls<\/strong>\u00a0command, will add the\u00a0<strong>\u2018\/\u2019<\/strong>\u00a0Character at the end each directory.<\/p>\n<pre><strong># ls -F<\/strong>\r\n\r\n0001.pcap        Desktop\/    Downloads\/        index.html   install.log.syslog  Pictures\/  Templates\/\r\nanaconda-ks.cfg  Documents\/  fbcmd_update.php  install.log  Music\/              Public\/    Videos\/<\/pre>\n<h4><span class=\"ez-toc-section\" id=\"7List_Files_in_Reverse_Order\"><\/span>7.List Files in Reverse Order<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<pre><strong># ls -r<\/strong>\r\n\r\nVideos     Public    Music               install.log  fbcmd_update.php  Documents  anaconda-ks.cfg\r\nTemplates  Pictures  install.log.syslog  index.html   Downloads         Desktop    0001.pcap<\/pre>\n<p>Hope this blog will be helpful for your troubleshooting and handling the server<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>ls command\u00a0is one of the most frequently used command in Linux. I believe\u00a0ls\u00a0command is the first command you may use when you get into the command prompt of Linux Box. 1. List Files using ls with no option ls\u00a0with no option list files and directories in bare format where we won\u2019t be able to view<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4],"tags":[],"class_list":["post-109","post","type-post","status-publish","format-standard","hentry","category-linux-commands"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/webhostingnoida.in\/blog\/wp-json\/wp\/v2\/posts\/109","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webhostingnoida.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webhostingnoida.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webhostingnoida.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/webhostingnoida.in\/blog\/wp-json\/wp\/v2\/comments?post=109"}],"version-history":[{"count":1,"href":"https:\/\/webhostingnoida.in\/blog\/wp-json\/wp\/v2\/posts\/109\/revisions"}],"predecessor-version":[{"id":110,"href":"https:\/\/webhostingnoida.in\/blog\/wp-json\/wp\/v2\/posts\/109\/revisions\/110"}],"wp:attachment":[{"href":"https:\/\/webhostingnoida.in\/blog\/wp-json\/wp\/v2\/media?parent=109"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webhostingnoida.in\/blog\/wp-json\/wp\/v2\/categories?post=109"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webhostingnoida.in\/blog\/wp-json\/wp\/v2\/tags?post=109"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}