Beginners Guide for Vdir Command on Linux

Linux TLDR
Last Updated:
Reading time: 2 minutes

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.

Tutorial Details

DescriptionVdir
Difficulty LevelLow
Root or Sudo PrivilegesNo
OS CompatibilityUbuntu, Manjaro, Fedora, etc.
Prerequisitesvdir
Internet RequiredNo

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

Output:

ls and vdir commands

Listing the Entries Size in Human-Readable Units

The “-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

Output:

Listing the entries' sizes in human-readable format

Listing All the Content of the Directory, Including Hidden

The “-a” or “--all” flag will show all the files and directories in the current working directory, including the hidden ones, as shown.

$ vdir -a

Output:

Listing all files, including hidden ones

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

Output:

Listing all files except pseudo files

Sorting Files Based on Size (Largest First)

The “-S” will sort the files and directories based on their sizes, listing the largest files first and the smallest files last.

$ vdir -S

Output:

Listing files and directories based on their size

Sorting Files Based on Modification Date (Latest First)

The “-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

Output:

Listing files and directories based on their modification dates

Group the Same File Type While Listing

The “--group-directories-first” flag will group the entries together based on their file type.

$ vdir --group-directories-first

Output:

Grouping files together based on their file type

Recursively List all the Files and Directories from the Specified Directory

The “--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/

Output:

Listing all files and directories recursively

Displaying the Entries with Inode, UID, and GID

The “-in” flag will display all the entries with their inode numbers and list the user ID and group ID.

$ vdir -in

Output:

Listing the entries with inode, uid, and gid

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

Exit Status

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.