dir
List directory contents
TLDR
List all files, including hidden files
List files including their author (-l is required)
List files excluding those that match a specified blob pattern
List subdirectories recursively
Display help
SYNOPSIS
dir [OPTION]... [FILE]...
PARAMETERS
`-a`, `--all`
Do not ignore entries starting with `.`
`-A`, `--almost-all`
Do not list implied `.` and `..`
`-b`, `--escape`
Print C-style escapes for nongraphic characters
`-C`
List entries by columns
`--color[=WHEN]`
Control whether color is used to distinguish file types. WHEN may be `never`, `always`, or `auto`
`-d`, `--directory`
List directories themselves, not their contents
`-f`
Do not sort; enable `-aU`; disable `-ls --color`
`-g`
Like `-l`, but do not list group information
`-G`, `--no-group`
In a long listing, don't print group names
`-h`, `--human-readable`
With `-l` and/or `-s`, print human readable sizes
`-i`, `--inode`
Print the index number of each file
`-l`
Use a long listing format
`-n`, `--numeric-uid-gid`
List numeric user and group IDs
`-o`
Like `-l`, but do not list group information
`-r`, `--reverse`
Reverse order while sorting
`-R`, `--recursive`
List subdirectories recursively
`-s`, `--size`
Print the size of each file, in blocks
`-S`
Sort by file size
`-t`
Sort by modification time, newest first
`-u`
With `-lt`: sort by, and show, access time; with `-l`: show access time and sort by name; otherwise: sort by access time
`-U`
Do not sort; list entries in directory order
`-w`, `--width COLS`
Set screen width to COLS
`-x`
List entries by lines instead of by columns
`-1`
List one file per line
`--help`
Display help message and exit
`--version`
Output version information and exit
DESCRIPTION
The `dir` command in Linux is a utility that displays a list of files and directories within a specified directory. It's similar to the `ls` command, but with a slightly different default output. The default behavior of `dir` is to list entries in color, indicating file types (e.g., directories in blue).
It provides a human-readable output, making it easy to visually identify files and directories. `dir` is primarily used for simple directory listing and is often aliased to `ls` in many systems. It's a quick and convenient way to get a basic overview of the contents of a directory from the command line.
CAVEATS
The default output of `dir` and `ls` can vary slightly between distributions and depending on user configurations (aliases). Therefore, always verify the behavior using the `--help` flag.
DISTINCTION FROM `LS`
While very similar to `ls`, `dir`'s default behavior is to show colored output and list entries in columns. This can be useful when you want to quickly differentiate file types visually. The main difference is the default options enabled.
HISTORY
The `dir` command has been a part of Unix-like operating systems for a long time. Its purpose has remained consistent: to provide a basic means of listing directory contents. Over time, options have been added to control the output format and sorting behavior. It's often found as a separate command or aliased to `ls` on many systems.