{"id":6988,"date":"2018-10-08T12:54:06","date_gmt":"2018-10-08T09:54:06","guid":{"rendered":"https:\/\/www.howtoforge.com\/linux-vdir-command\/"},"modified":"2018-10-08T12:54:06","modified_gmt":"2018-10-08T09:54:06","slug":"linux-vdir-command-tutorial-for-beginners-8-examples","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/linux-vdir-command-tutorial-for-beginners-8-examples\/","title":{"rendered":"Linux vdir Command Tutorial for Beginners (8 Examples)"},"content":{"rendered":"<p>Listing contents of a directory is one of the most basic tasks that users (both pro and noobs) find themselves involved in. The\u00a0<a href=\"https:\/\/www.howtoforge.com\/linux-ls-command\/\" target=\"_blank\" rel=\"noopener noreferrer\">ls<\/a> command is hands down the most popular tool used for this purpose. However, it&#8217;s not the only one.<\/p>\n<p>There are some alternatives. For example, there&#8217;s a utility called <strong>vdir<\/strong>, basics of which we&#8217;ll be discussing here. But before we do that, it&#8217;s worth mentioning that all examples in this tutorial have been tested on an Ubuntu 18.04 LTS machine.<\/p>\n<p>Like ls, the vdir command in Linux is also used to list directory contents. Following is its syntax:<\/p>\n<p class=\"command\">vdir [OPTION]&#8230; [FILE]&#8230;<\/p>\n<p>And here&#8217;s how the tool&#8217;s man page explains it:<\/p>\n<pre>List information about the FILEs (the current directory by default).\u00a0 <br\/>Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.<\/pre>\n<p>Following are some Q&amp;A-styled examples that should give you a good idea on how the vdir command works.<\/p>\n<h2 id=\"q-how-to-use-vdir\">Q1. How to use vdir?<\/h2>\n<p>Basic usage is pretty simple &#8211; just execute the vdir command sans any option.<\/p>\n<p class=\"command\">vdir<\/p>\n<p>For example, in my case, running &#8216;vdir&#8217; produced the following output:<\/p>\n<pre>total 12<br\/>drwxr-xr-x 2 guest-A8CLd9 guest-A8CLd9\u00a0\u00a0 40 Sep 26 09:29 Desktop<br\/>drwxr-xr-x 2 guest-A8CLd9 guest-A8CLd9\u00a0\u00a0 40 Sep 26 09:29 Documents<br\/>drwxr-xr-x 2 guest-A8CLd9 guest-A8CLd9\u00a0\u00a0 40 Sep 26 09:29 Downloads<br\/>-rw-r--r-- 1 guest-A8CLd9 guest-A8CLd9 8980 Sep 26 09:29 examples.desktop<br\/>drwxrwxr-x 2 guest-A8CLd9 guest-A8CLd9\u00a0\u00a0 40 Sep 26 09:29 Files-From-Desktop<br\/>drwxr-xr-x 2 guest-A8CLd9 guest-A8CLd9\u00a0\u00a0 40 Sep 26 09:29 Music<br\/>drwxr-xr-x 2 guest-A8CLd9 guest-A8CLd9\u00a0\u00a0 40 Sep 26 09:29 Pictures<br\/>drwxr-xr-x 2 guest-A8CLd9 guest-A8CLd9\u00a0\u00a0 40 Sep 26 09:29 Public<br\/>drwxr-xr-x 2 guest-A8CLd9 guest-A8CLd9\u00a0\u00a0 40 Sep 26 09:29 Templates<br\/>drwxr-xr-x 2 guest-A8CLd9 guest-A8CLd9\u00a0\u00a0 40 Sep 26 09:29 Videos<\/pre>\n<p>So you can see the output is similar to the &#8216;ls -l&#8217; command.<\/p>\n<h2 id=\"q-how-to-make-vdir-display-entries-starting-with-dot-\">Q2. How to make vdir display entries starting with dot (.)?<\/h2>\n<p>By default, the vdir command output doesn&#8217;t show names that begin with dot (.). However, you can change this behavior using the -a command line option.<\/p>\n<p class=\"command\">vdir -a<\/p>\n<p>Following output was produced in my case:<\/p>\n<pre>total 52<br\/>drwx------ 20 guest-A8CLd9 guest-A8CLd9\u00a0\u00a0 540 Sep 26 09:30 .<br\/>drwxrwxrwt\u00a0 7 root\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 root\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 16384 Sep 26 10:17 ..<br\/>-rw-r--r--\u00a0 1 guest-A8CLd9 guest-A8CLd9\u00a0\u00a0 220 Sep 26 09:29 .bash_logout<br\/>-rw-r--r--\u00a0 1 guest-A8CLd9 guest-A8CLd9\u00a0 3637 Sep 26 09:29 .bashrc<br\/>drwxr-xr-x 12 guest-A8CLd9 guest-A8CLd9\u00a0\u00a0 260 Sep 26 09:37 .cache<br\/>drwxr-xr-x 16 guest-A8CLd9 guest-A8CLd9\u00a0\u00a0 360 Sep 26 09:29 .config<br\/>drwxr-xr-x\u00a0 2 guest-A8CLd9 guest-A8CLd9\u00a0\u00a0\u00a0 40 Sep 26 09:29 Desktop<br\/>drwxr-xr-x\u00a0 2 guest-A8CLd9 guest-A8CLd9\u00a0\u00a0\u00a0 40 Sep 26 09:29 Documents<br\/>drwxr-xr-x\u00a0 2 guest-A8CLd9 guest-A8CLd9\u00a0\u00a0\u00a0 40 Sep 26 09:29 Downloads<br\/>-rw-r--r--\u00a0 1 guest-A8CLd9 guest-A8CLd9\u00a0 8980 Sep 26 09:29 examples.desktop<br\/>drwxrwxr-x\u00a0 2 guest-A8CLd9 guest-A8CLd9\u00a0\u00a0\u00a0 40 Sep 26 09:29 Files-From-Desktop<br\/>drwx------\u00a0 3 guest-A8CLd9 guest-A8CLd9\u00a0\u00a0\u00a0 60 Sep 26 09:30 .gconf<br\/>drwx------\u00a0 3 guest-A8CLd9 guest-A8CLd9\u00a0\u00a0\u00a0 60 Sep 26 09:30 .gnome2<br\/>drwx------\u00a0 2 guest-A8CLd9 guest-A8CLd9\u00a0\u00a0\u00a0 40 Sep 26 09:30 .gnome2_private<br\/>-rw-------\u00a0 1 guest-A8CLd9 guest-A8CLd9\u00a0\u00a0 358 Sep 26 09:29 .ICEauthority<br\/>drwxr-xr-x\u00a0 3 guest-A8CLd9 guest-A8CLd9\u00a0\u00a0\u00a0 60 Sep 26 09:29 .kde<br\/>drwx------\u00a0 3 guest-A8CLd9 guest-A8CLd9\u00a0\u00a0\u00a0 60 Sep 26 09:29 .local<br\/>drwx------\u00a0 4 guest-A8CLd9 guest-A8CLd9\u00a0\u00a0\u00a0 80 Sep 26 09:30 .mozilla<br\/>drwxr-xr-x\u00a0 2 guest-A8CLd9 guest-A8CLd9\u00a0\u00a0\u00a0 40 Sep 26 09:29 Music<br\/>drwxr-xr-x\u00a0 2 guest-A8CLd9 guest-A8CLd9\u00a0\u00a0\u00a0 40 Sep 26 09:29 Pictures<br\/>-rw-r--r--\u00a0 1 guest-A8CLd9 guest-A8CLd9\u00a0\u00a0 697 Sep 26 09:29 .profile<br\/>drwxrwxr-x\u00a0 2 guest-A8CLd9 guest-A8CLd9\u00a0\u00a0\u00a0 60 Sep 26 09:29 .psensor<br\/>drwxr-xr-x\u00a0 2 guest-A8CLd9 guest-A8CLd9\u00a0\u00a0\u00a0 40 Sep 26 09:29 Public<br\/>drwxr-xr-x\u00a0 2 guest-A8CLd9 guest-A8CLd9\u00a0\u00a0\u00a0 40 Sep 26 09:29 Templates<br\/>drwxr-xr-x\u00a0 2 guest-A8CLd9 guest-A8CLd9\u00a0\u00a0\u00a0 40 Sep 26 09:29 Videos<br\/>-rw-------\u00a0 1 guest-A8CLd9 guest-A8CLd9\u00a0\u00a0\u00a0 61 Sep 26 09:29 .Xauthority<br\/>-rw-------\u00a0 1 guest-A8CLd9 guest-A8CLd9\u00a0\u00a0 108 Sep 26 09:29 .xsession-errors<\/pre>\n<p>So you can see that file names\u00a0beginning with a dot are also produced in output.<\/p>\n<h2 id=\"q-how-to-make-vdir-scale-sizes-by-fixed-size\">Q3. How to make vdir scale sizes by fixed size?<\/h2>\n<p>Suppose you want vdir to print sizes (5th column in output) in blocks of megabytes, then you can do this using the\u00a0&#8211;block-size option, by supplying &#8216;M&#8217; as input to it.<\/p>\n<p class=\"command\">vdir &#8211;block-size=M<\/p>\n<p>Following is the output this command produced on my system:<\/p>\n<pre>total 1M<br\/>drwxr-xr-x 2 guest-A8CLd9 guest-A8CLd9 1M Sep 26 09:29 Desktop<br\/>drwxr-xr-x 2 guest-A8CLd9 guest-A8CLd9 1M Sep 26 09:29 Documents<br\/>drwxr-xr-x 2 guest-A8CLd9 guest-A8CLd9 1M Sep 26 09:29 Downloads<br\/>-rw-r--r-- 1 guest-A8CLd9 guest-A8CLd9 1M Sep 26 09:29 examples.desktop<br\/>drwxrwxr-x 2 guest-A8CLd9 guest-A8CLd9 1M Sep 26 09:29 Files-From-Desktop<br\/>drwxr-xr-x 2 guest-A8CLd9 guest-A8CLd9 1M Sep 26 09:29 Music<br\/>drwxr-xr-x 2 guest-A8CLd9 guest-A8CLd9 1M Sep 26 09:29 Pictures<br\/>drwxr-xr-x 2 guest-A8CLd9 guest-A8CLd9 1M Sep 26 09:29 Public<br\/>drwxr-xr-x 2 guest-A8CLd9 guest-A8CLd9 1M Sep 26 09:29 Templates<br\/>drwxr-xr-x 2 guest-A8CLd9 guest-A8CLd9 1M Sep 26 09:29 Videos<\/pre>\n<p>So you can see that size entries are produced in blocks of megabytes (M).<\/p>\n<p>Here&#8217;s some useful information related to the input that this option requires:<\/p>\n<pre> The\u00a0 SIZE\u00a0 argument\u00a0 is\u00a0 an\u00a0 integer and optional unit (example: 10K is<br\/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 10*1024).\u00a0 Units are K,M,G,T,P,E,Z,Y\u00a0 (powers\u00a0 of\u00a0 1024)\u00a0 or\u00a0 KB,MB,...<br\/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 (powers of 1000).<\/pre>\n<h2 id=\"q-how-to-make-vdir-produce-output-like-ls\">Q4. How to make vdir produce output like ls?<\/h2>\n<p>By default, the ls command doesn&#8217;t produce details in output &#8211; just name of files\/directories in the current directory.<\/p>\n<p>However, vdir produces a whole lot of info by default. But if you want, you can restrict vdir to an &#8216;ls&#8217; like output. This you can do using the -C command line option.<\/p>\n<p class=\"command\">vdir -C<\/p>\n<p>Following output was produced in my case:<\/p>\n<pre>Desktop\u00a0 Documents\u00a0 Downloads\u00a0 examples.desktop\u00a0 Files-From-Desktop\u00a0 Music\u00a0 Pictures\u00a0 Public\u00a0 Templates\u00a0 Videos<\/pre>\n<h2 id=\"q-how-to-make-vdir-produce-colored-output\">Q5. How to make vdir produce colored output?<\/h2>\n<p>If you compare the output produced by vdir in the previous section with the output produced by &#8216;ls&#8217; command, you&#8217;ll observe one difference: the ls command output is colored while that of vdir isn&#8217;t.<\/p>\n<p>However, you can force vdir to produce colored output as well. This you can do using the &#8211;color command line option.<\/p>\n<p class=\"command\">vdir &#8211;color<\/p>\n<h2 id=\"q-how-to-make-vdir-produce-unsorted-output\">Q6. How to make vdir produce unsorted output?<\/h2>\n<p>This you can do using the -f command line option.<\/p>\n<p class=\"command\">vdir -f<\/p>\n<p>Following is the output this command produced in my case:<\/p>\n<pre>.\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0 .gnome2\u00a0\u00a0 Files-From-Desktop\u00a0 .local\u00a0\u00a0 \u00a0 Music\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0 Templates\u00a0 .xsession-errors\u00a0 .cache\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 .bash_logout<br\/>..\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0 .mozilla\u00a0 .ICEauthority\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Videos\u00a0\u00a0 \u00a0 Documents\u00a0 Downloads\u00a0 .Xauthority\u00a0\u00a0 \u00a0 .config\u00a0\u00a0 \u00a0\u00a0\u00a0 .profile<br\/>.gnome2_private\u00a0 .psensor\u00a0 .gconf\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Pictures\u00a0 Public\u00a0\u00a0\u00a0\u00a0 Desktop\u00a0\u00a0\u00a0 .kde\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0 examples.desktop\u00a0 .bashrc<\/pre>\n<p>Here&#8217;s how the man page explains this -f option:<\/p>\n<pre>-f\u00a0\u00a0\u00a0\u00a0 do not sort, enable -aU, disable -ls --color<\/pre>\n<h2 id=\"q-how-to-make-vdir-group-directories-first-in-the-output\">Q7. How to make vdir group directories first in the output?<\/h2>\n<p>If you want the vdir command to group directories first in the output, use the <em>&#8211;group-directories-first<\/em> option.<\/p>\n<p class=\"command\">vdir &#8211;group-directories-first<\/p>\n<p>Following is the output this command produced in my case:<\/p>\n<pre>total 12<br\/>drwxr-xr-x 2 guest-eugepN guest-eugepN\u00a0\u00a0 40 Aug 22\u00a0 2011 Desktop<br\/>drwxr-xr-x 2 guest-eugepN guest-eugepN\u00a0\u00a0 40 Aug 22\u00a0 2011 Documents<br\/>drwxr-xr-x 2 guest-eugepN guest-eugepN\u00a0\u00a0 40 Aug 22\u00a0 2011 Downloads<br\/>drwxrwxr-x 2 guest-eugepN guest-eugepN\u00a0\u00a0 40 Aug 22\u00a0 2011 Files-From-Desktop<br\/>drwxr-xr-x 2 guest-eugepN guest-eugepN\u00a0\u00a0 40 Aug 22\u00a0 2011 Music<br\/>drwxr-xr-x 2 guest-eugepN guest-eugepN\u00a0\u00a0 40 Aug 22\u00a0 2011 Pictures<br\/>drwxr-xr-x 2 guest-eugepN guest-eugepN\u00a0\u00a0 40 Aug 22\u00a0 2011 Public<br\/>drwxr-xr-x 2 guest-eugepN guest-eugepN\u00a0\u00a0 40 Aug 22\u00a0 2011 Templates<br\/>drwxr-xr-x 2 guest-eugepN guest-eugepN\u00a0\u00a0 40 Aug 22\u00a0 2011 Videos<br\/>-rw-r--r-- 1 guest-eugepN guest-eugepN 8980 Aug 22\u00a0 2011 examples.desktop<\/pre>\n<p>So you can see all directories got listed first.<\/p>\n<h2 id=\"q-how-to-make-vdir-produce-index-number-for-each-file\">Q8. How to make vdir produce index number for each file?<\/h2>\n<p>This can be achieved using the -i command line option.<\/p>\n<p class=\"command\">vdir -i<\/p>\n<p>Following is a sample output:<\/p>\n<pre>total 12<br\/>\u00a022 drwxr-xr-x 2 guest-eugepN guest-eugepN\u00a0\u00a0 40 Aug 22\u00a0 2011 Desktop<br\/>\u00a026 drwxr-xr-x 2 guest-eugepN guest-eugepN\u00a0\u00a0 40 Aug 22\u00a0 2011 Documents<br\/>\u00a023 drwxr-xr-x 2 guest-eugepN guest-eugepN\u00a0\u00a0 40 Aug 22\u00a0 2011 Downloads<br\/>\u00a0 6 -rw-r--r-- 1 guest-eugepN guest-eugepN 8980 Aug 22\u00a0 2011 examples.desktop<br\/>155 drwxrwxr-x 2 guest-eugepN guest-eugepN\u00a0\u00a0 40 Aug 22\u00a0 2011 Files-From-Desktop<br\/>\u00a027 drwxr-xr-x 2 guest-eugepN guest-eugepN\u00a0\u00a0 40 Aug 22\u00a0 2011 Music<br\/>\u00a028 drwxr-xr-x 2 guest-eugepN guest-eugepN\u00a0\u00a0 40 Aug 22\u00a0 2011 Pictures<br\/>\u00a025 drwxr-xr-x 2 guest-eugepN guest-eugepN\u00a0\u00a0 40 Aug 22\u00a0 2011 Public<br\/>\u00a024 drwxr-xr-x 2 guest-eugepN guest-eugepN\u00a0\u00a0 40 Aug 22\u00a0 2011 Templates<br\/>\u00a029 drwxr-xr-x 2 guest-eugepN guest-eugepN\u00a0\u00a0 40 Aug 22\u00a0 2011 Videos<\/pre>\n<p>The first column contains the respective index numbers.<\/p>\n<p>Depending upon the requirement, the vdir command can prove to be a useful tool for you. In this tutorial, we have discussed some key option this utility offers. To learn more about this tool, head to its <a href=\"https:\/\/linux.die.net\/man\/1\/vdir\" target=\"_blank\" rel=\"noopener noreferrer\">man page<\/a>.<\/p>\n<div class=\"authorbox\" readability=\"15\">\n<img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/10\/linux-vdir-command-tutorial-for-beginners-8-examples.jpg\" alt=\"Himanshu Arora\" title=\"\"> <\/p>\n<p><strong>About Himanshu Arora<\/strong><\/p>\n<p>Himanshu Arora has been working on Linux since 2007. He carries professional experience in system level programming, networking protocols, and command line. In addition to HowtoForge, Himanshu&#8217;s work has also been featured in some of world&#8217;s other leading publications including Computerworld, IBM DeveloperWorks, and Linux Journal.<\/p>\n<\/div>\n<div>\n<p><b>Share this page:<\/b><\/p>\n<p>\n<a href=\"https:\/\/www.facebook.com\/sharer.php?u=https%3A%2F%2Fwww.howtoforge.com%2Flinux-vdir-command%2F\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/10\/linux-vdir-command-tutorial-for-beginners-8-examples.png\" height=\"20\" alt=\"\" title=\"\"><\/a><br \/>\n<a href=\"https:\/\/twitter.com\/intent\/tweet?url=https%3A%2F%2Fwww.howtoforge.com%2Flinux-vdir-command%2F&amp;text=Linux+vdir+Command+Tutorial+for+Beginners+%288+Examples%29&amp;via=howtoforgecom&amp;related=howtoforgecom\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/10\/linux-vdir-command-tutorial-for-beginners-8-examples-1.png\" height=\"20\" alt=\"\" title=\"\"><\/a><br \/>\n<a href=\"https:\/\/twitter.com\/howtoforgecom\/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/10\/linux-vdir-command-tutorial-for-beginners-8-examples-2.png\" height=\"20\" alt=\"\" title=\"\"><\/a><br \/>\n<a href=\"https:\/\/plus.google.com\/share?url=https%3A%2F%2Fwww.howtoforge.com%2Flinux-vdir-command%2F\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/10\/linux-vdir-command-tutorial-for-beginners-8-examples-3.png\" height=\"20\" alt=\"\" title=\"\"><\/a>\n<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Listing contents of a directory is one of the most basic tasks that users (both pro and noobs) find themselves involved in. The\u00a0ls command is hands down the most popular tool used for this purpose. However, it&#8217;s not the only one. There are some alternatives. For example, there&#8217;s a utility called vdir, basics of which [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[36],"tags":[],"class_list":["post-6988","post","type-post","status-publish","format-standard","hentry","category-36"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/6988","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/comments?post=6988"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/6988\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=6988"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=6988"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=6988"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}