vdir

file systemLinux/Unix
The vdir command is one of the most frequently used commands in Linux/Unix-like operating systems. vdir List directory contents in a verbose, multi-column format

Quick Reference

Command Name:

vdir

Category:

file system

Platform:

Linux/Unix

Basic Usage:

vdir [options] [arguments]

Common Use Cases

    Syntax

    vdir [OPTION]... [FILE]...

    Options

    The vdir command accepts all the same options as the ls command, since it's effectively ls with the -l option already set. Here are some commonly used options:

    Option Description
    -a, --all Do not ignore entries starting with .
    -A, --almost-all Do not list implied . and ..
    --author Print the author of each file
    -b, --escape Print C-style escapes for nongraphic characters
    --block-size=SIZE Scale sizes by SIZE before printing them
    -B, --ignore-backups Do not list implied entries ending with ~
    -c Sort by change time, newest first
    -C List entries by columns
    --color[=WHEN] Colorize the output; WHEN can be 'always', 'auto', or 'never'
    -d, --directory List directories themselves, not their contents
    -D, --dired Generate output designed for Emacs' dired mode
    -f Do not sort, enable -aU, disable -ls --color
    -F, --classify Append indicator (one of */=>@|) to entries
    --file-type Likewise, except do not append '*'
    --format=WORD Format output as WORD list: across (-x), commas (-m), horizontal (-x), long (-l), single-column (-1), verbose (-l), vertical (-C)
    --full-time Like -l --time-style=full-iso
    -g Like -l, but do not list owner
    --group-directories-first Group directories before files
    -G, --no-group In a long listing, don't print group names
    -h, --human-readable Print sizes like 1K, 234M, 2G, etc.
    --si Likewise, but use powers of 1000 not 1024
    -H, --dereference-command-line Follow symbolic links listed on the command line
    -i, --inode Print the index number of each file
    -I, --ignore=PATTERN Do not list implied entries matching shell PATTERN
    -k, --kibibytes Default to 1024-byte blocks for disk usage
    -L, --dereference When showing file information for a symbolic link, show information for the file the link references rather than for the link itself
    -m Fill width with a comma separated list of entries
    -n, --numeric-uid-gid Like -l, but list numeric user and group IDs
    -N, --literal Print raw entry names (don't treat e.g. control characters specially)
    -o Like -l, but do not list group information
    -p, --indicator-style=slash Append / indicator to directories
    -q, --hide-control-chars Print ? instead of nongraphic characters
    --show-control-chars Show nongraphic characters as-is (the default, unless program is 'ls' and output is a terminal)
    -Q, --quote-name Enclose entry names in double quotes
    --quoting-style=WORD Use quoting style WORD for entry names: literal, locale, shell, shell-always, shell-escape, shell-escape-always, c, escape
    -r, --reverse Reverse order while sorting
    -R, --recursive List subdirectories recursively
    -s, --size Print the allocated size of each file, in blocks
    -S Sort by file size, largest first
    --sort=WORD Sort by WORD instead of name: none (-U), size (-S), time (-t), version (-v), extension (-X)
    --time=WORD With -l, show time as WORD instead of default modification time: atime or access or use (-u); ctime or status (-c); also use specified time as sort key if --sort=time (newest first)
    --time-style=STYLE With -l, show times using style STYLE: full-iso, long-iso, iso, locale, or +FORMAT
    -t Sort by modification time, newest first
    -T, --tabsize=COLS Assume tab stops at each COLS instead of 8
    -u With -lt: sort by, and show, access time; with -l: show access time and sort by name; otherwise: sort by access time, newest first
    -U Do not sort; list entries in directory order
    -v Natural sort of (version) numbers within text
    -w, --width=COLS Set output width to COLS. 0 means no limit
    -x List entries by lines instead of by columns
    -X Sort alphabetically by entry extension
    -Z, --context Print any security context of each file
    -1 List one file per line
    --help Display help information and exit
    --version Output version information and exit

    Examples

    How to Use These Examples

    The examples below show common ways to use the vdir command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.

    Basic Examples:

    List files in the current directory in verbose format
    vdir
    List files in a specific directory
    vdir /etc
    List files with human-readable sizes
    vdir -h

    Advanced Examples:

    List all files including hidden ones
    vdir -a
    Sort files by size (largest first)
    vdir -S
    Sort files by modification time (newest first)
    vdir -t
    List files with detailed security context information (SELinux)
    vdir -Z
    Display file sizes in human-readable format and sort by size
    vdir -hS
    List files and directories recursively
    vdir -R
    List only the directories
    vdir -d */
    Use custom format to display specific fields
    vdir --format="%n %s %TY-%Tm-%Td %TH:%TM"
    Display inode information along with other details
    vdir -i
    List files with their numeric user and group IDs
    vdir -n
    Colorize the output based on file types
    vdir --color=auto
    Display entries in a comma-separated list
    vdir -m
    Create a simple file inventory report
    echo "File listing as of $(date)" > inventory.txt
    echo "--------------------------------------" >> inventory.txt vdir -la >> inventory.txt

    Try It Yourself

    Practice makes perfect! The best way to learn is by trying these examples on your own system with real files.

    Understanding Syntax

    Pay attention to the syntax coloring: commands, options, and file paths are highlighted differently.

    Notes

    The `vdir` command is a Unix/Linux utility that is part of the GNU Coreutils package. It functions essentially as a variant of the `ls` command with a specific set of default options. While `ls` is more commonly used and versatile, `vdir` provides a standardized way to get a detailed, verbose listing of directory contents. **Relationship to ls:** `vdir` is effectively equivalent to running `ls -l` (long listing format) with some minor formatting differences. It displays detailed information about files in a vertical, columnar format with one file per line. The main difference between `vdir` and `ls -l` is that `vdir` might use a slightly different default format on some systems, but for most practical purposes, they produce nearly identical output. **Output Format:** The output of `vdir` typically includes: 1. File permissions (read, write, execute for owner, group, and others) 2. Number of hard links 3. Owner name 4. Group name 5. File size in bytes 6. Last modification timestamp 7. Filename For example: ``` -rw-r--r-- 1 user group 12345 Jan 15 14:30 example.txt drwxr-xr-x 2 user group 4096 Jan 10 09:15 directory ``` **Usage Context:** The `vdir` command is less commonly used than `ls` for several reasons: 1. **Redundancy**: Since it's essentially `ls -l`, most users simply use the latter. 2. **Familiarity**: The `ls` command is more widely known and has become the standard for listing directory contents. 3. **Flexibility**: While `vdir` accepts most of the same options as `ls`, users typically prefer to customize `ls` directly. However, `vdir` can be useful in scripts or environments where a consistent, detailed listing format is needed without having to specify options explicitly. **Historical Context:** The `vdir` command is part of the GNU Coreutils, which aims to provide replacements for the basic utilities found in Unix systems. It exists primarily for compatibility with certain standards and expectations about available commands rather than for providing unique functionality. **Practical Considerations:** 1. **Scripting**: In shell scripts, using `vdir` instead of `ls -l` might make the intention clearer that a detailed, verbose listing is specifically required. 2. **Consistency**: On different systems or with different user configurations, the default behavior of `ls` might vary, whereas `vdir` is more likely to provide consistent output. 3. **Aliases**: Some users might have aliases for `ls` that change its default behavior, but are less likely to have customized `vdir`. **Modern Alternatives:** For more advanced file listing and navigation, modern alternatives to both `ls` and `vdir` include: 1. **`exa`**: A modern replacement for `ls` with color-coding, Git integration, and extended attributes. 2. **`tree`**: Shows directory contents in a tree-like format, which can be more intuitive for viewing directory hierarchies. 3. **`find`**: For more complex file searching and listing capabilities. 4. **File managers**: GUI-based file managers provide visual browsing of directories with detailed information. While `vdir` is not among the most frequently used commands in modern Linux systems, understanding its purpose and relationship to `ls` helps in appreciating the design and evolution of Unix/Linux command-line utilities.

    Related Commands

    These commands are frequently used alongside vdir or serve similar purposes:

    Use Cases

    Learn By Doing

    The best way to learn Linux commands is by practicing. Try out these examples in your terminal to build muscle memory and understand how the vdir command works in different scenarios.

    $ vdir
    View All Commands
    Linux vdir Command - Verbose Directory Listing