The vdir command is an equivalent to the “
ls -l -b” command, printing the content in long list format and showing escape characters on the file or directory name, just like the dir command is equivalent to the “
ls -C -b” command.
Practically, you might rarely or not use this command on a daily basis, but knowing about it will add something to your Linux knowledge that will separate you from others.
In this short article, you will learn the most practical ways to use the vdir command.
|Root or Sudo Privileges||No|
|Host System and Architecture||Ubuntu 22.10 (x64)|
|OS Compatibility||Ubuntu, Manjaro, Fedora, etc.|
|Discussed Tools in this Article|
Syntax of the Vdir Command
Similar to the ls command, the vdir command takes two arguments: one is the option, and the other is the file or directory path.
$ vdir [OPTION] [FILENAME/DIRECTORY PATH]
Listing Content of the Directory in Long List Format
The default behavior of this command without any options or paths is identical to the “
ls -l -b” command; you can find the similarities by executing both of them.
$ ls -lb $ vdir
Listing the Entries Size in Human-Readable Units
-h” or “
--human-readable” flag can be used to display the entry size in a human-readable format like “KB“, “MB“, and “GB“, as shown.
$ vdir -h
Listing All the Content of the Directory, Including Hidden
-a” or “
--all” flag will show all the files and directories in the current working directory, including the hidden ones, as shown.
$ vdir -a
Listing All the Content of the Directory, Except Pseudo Files
By default, the vdir command will list the “
.” (current directory) and “
..” (parent directory), also known as pseudo files, at the beginning of entries.
Use the “
-A” or “
--almost-all” flag to have the same result except hide the pseudo files.
$ vdir -A
Sorting Files Based on Size (Largest First)
-S” will sort the files and directories based on their sizes, listing the largest files first and the smallest files last.
$ vdir -S
Sorting Files Based on Modification Date (Latest First)
-t” flag will list all the files and directories based on their modification dates, where the most recently modified files will be listed first.
$ vdir -t
Group the Same File Type While Listing
--group-directories-first” flag will group the entries together based on their file type.
$ vdir --group-directories-first
Recursively List all the Files and Directories from the Specified Directory
--recursive” flag will recursively search for files and directories in the sub-directories of the specified directory and list them in the output.
$ vdir --recursive mydir/
Displaying the Entries with Inode, UID, and GID
-in” flag will display all the entries with their inode numbers and list the user ID and group ID.
$ vdir -in
Although this command is identical to the ls command and both have the same options and functionality, if you want to know more about it, check the help section.
$ vdir --help
Also Read: What is Exit Status Code of Last Command in Linux
The vdir command has three exit statuses to handle errors.
- 0: Success
- 1: Minor problems (ex: sub-directory access is restricted)
- 2: Serious trouble (ex: invalid flag or defined file or directory path does not exist)
That was all about this command.
If you are wondering why this command exists, I suggest you ignore it as something done without any solid reason, just like the dir command.
If you have questions or queries related to this command, let’s have a good conversation in the comment section.
Join The Conversation
Users are always welcome to leave comments about the articles, whether they are questions, comments, constructive criticism, old information, or notices of typos. Please keep in mind that all comments are moderated according to our comment policy.