
vdir Command in Linux
Linux provides many commands for listing directory contents. The most commonly used tool is ls, but there are alternatives that give you different default output formats. One such command is vdir. Essentially, vdir performs the same task as "ls -l" displaying a long-form listing that includes file permissions, ownership, size, and modification time.
Table of Contents
Here is a comprehensive guide to the options available with the vdir command −
- Understanding vdir Command
- Syntax of vdir Command
- How to Use vdir Command in Linux?
- Examples of vdir Command in Linux
Understanding vdir Command
The name vdir is sometimes remembered as "verbose directory listing". The idea behind it is that an administrator or user may wish for a listing that always shows detailed information. In practice, vdir is equivalent to running −
ls -l --escape

Or sometimes,
ls -lb

The -l option creates the long listing format, and the -b option escapes non-printable characters. Although the differences are subtle, vdir provides a standardized way of getting detailed information without remembering multiple options each time.
Syntax of vdir Command
The basic way to invoke vdir is simple. If you type −
vdir

Without additional arguments, it will list the current directory in a long format using its default options. You can also supply one or more directories (or files) as parameters. For example −
vdir /etc /var/log

This command will list both the /etc and /var/log directories in verbose (long format) detail. On many systems, vdir is actually just a symbolic link to ls with preset options. In many installations, typing −
man vdir

How to Use vdir Command in Linux?
While vdir supports most of the options familiar to ls, understanding its frequently used options is important. Many of these options control sorting, output display, and formatting. Here are some of the most common ones −
The Long Listing Format (-l)
Since vdir is designed to be verbose, it uses the -l option by default. This option instructs the command to output detailed information about files and directories. For example −
vdir

This output gives you enough information for daily administrative tasks.
Including Hidden Files (-a)
Often, files or directories starting with a dot (.) are hidden. To include these files in the verbose output, you can use the -a option −
vdir -a

For instance, this command will display files like .rc, .profile, or .config along with all the regular files in the directory.
Escaping Non-Printable Characters (-b)
The -b option causes vdir to print non-graphic characters in file names as octal escapes. Although this option is part of its standard behavior, you might sometimes mention it explicitly for clarity −
vdir -b

It ensures that even if a file name contains spaces or unusual characters, they will be represented in a sanitized manner.
Human-Readable File Sizes (-h)
To convert the file sizes into a more understandable format (for example, K, M, or G for kilobytes, megabytes, or gigabytes), you can add the -h option. This is particularly useful when dealing with large files −
vdir -lh

Here, file sizes are easier to interpret than raw byte counts.
Displaying Inode Numbers (-i)
Every file in a Linux file system is associated with an inode number, which uniquely identifies it. To include inode numbers in the listing, use the -i option −
vdir -li

The output begins with the inode number before each file's permission string, which can be useful when diagnosing file system issues or linking files manually.
Sorting and Ordering Files
For example, to display the longest listing sorted by size and then reversed, use −
vdir -lSr

Recursive Listing (-R)
If you want to list not only the current directory but also all subdirectories and their files, the -R option enables a recursive listing −
vdir -lR

This produces an output that displays each directory's contents, with each subdirectory preceded by its name. It is useful for auditing entire directory trees and for troubleshooting issues that might span multiple nested levels.
Display Sort-By-Time Options (-c, -u)
- -c − When combined with -l, sort by the file's last status change time instead of modification time.
- -u − Sort by the file's access time.
For example, to sort by the last status change time −
vdir -lc

This subtle difference is important when troubleshooting file permission issues or determining the most recent changes in system files.
Examples of vdir Command in Linux
Let's consider several real-world examples to see how these options can be combined to meet various needs.
Basic Detailed Directory Listing
Simply running −
vdir

It produces an output equivalent to that of ls -l -b. For most users, this suffices when you need a detailed report of file metadata.
Complete Listing Including Hidden Files
If you want a comprehensive output that includes hidden files (those that begin with a dot) −
vdir -la

This command lists all files (both visible and hidden) and displays details (permissions, ownership, size, and modification date) for each file. This is particularly useful when you are troubleshooting configuration issues or need to verify that your user's hidden configuration files are present and correct.
Human-Readable Format with Inode Numbers
To gain an understanding of not only file sizes in easy-to-read units but also associated inode numbers, you can combine options −
vdir -lhi

In the output, each line begins with an inode number, followed by file permissions and sizes formatted in a human-friendly way (if you combine with -h, e.g., vdir -lhi -h). This command is useful for system administrators who may need to reference inodes when performing lower-level file system checks.
Sorting by Modification Time
When you are interested in seeing the most recently updated files at the top, the -t option comes into play −
vdir -lt

Files are now sorted based on modification time, which is very helpful when tracking recent changes. To reverse the order (i.e., oldest first), simply add the -r option −
vdir -lt

Recursive Directory Listing
To audit an entire directory tree, you might run −
vdir -lR /var/log

This command recursively lists every file and folder starting from the /var/log directory. By examining the output, an administrator can check for irregularities, such as unusually large log files or improperly set permissions deep within the directory structure.
Sorting by File Size
Another common requirement is to determine which files take up the most space. Using the -S option sorts files based on size −
vdir -lS

This output lists the files so the largest ones appear at the top by default (unless the -r option reverses the sort). This is ideal for quickly pinpointing space hogs on a system.
Combining Options for Specific Displays
Imagine you have a scenario where you need the absolute detail for a troubleshooting session. You want hidden files, in a recursive listing, sorted by last access time, with human-readable sizes and inodes shown. The command might look like −
vdir -lahRu

Conclusion
The Linux vdir command might be one of the lesser-known utilities in daily use compared to its friend ls, but it remains a powerful tool for obtaining a detailed, unmodified view of directory contents.
Whether you are troubleshooting file permissions, monitoring directory changes over time, or integrating file listings into custom scripting and monitoring solutions, understanding every option available to vdir is crucial.