• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

dir Command Examples in Linux

by admin

The dir command lists directory contents. It also lists information about the FILEs (the current directory by default). Sort entries alphabetically if none of -cftuvSUX nor –sort is specified.

dir Command Examples

1. To list all the directories:

# dir -a
# dir --all 

2. To skip listing implied directory contents:

# dir -A 

3. To list the author of the each file:

# dir --author 

4. To print octal escapes for nongraphic characters:

# dir -b
# dir --escapes

5. To list the output using specified block size:

# dir --block-size=1024
# dir -k=1024 

6. To skip listing entries ending with ~:

# dir -B
# dir --ignore-backups 

7. To list the contents with last modification time:

# dir -c 

8. To list the entries by column:

# dir -C

9. To print the output in color:

# dir --color 

10. To list only the directory entries:

# dir -d
# dir --directory 

11. To not to sort the output:

# dir -f 

12. To list the directories with specified format:

# dir -x (across)
# dir -m (Commas)
# dir -x (Horizontal)
# dir -l (Long)
# dir -1 (Single-column)
# dir -l (Vebose)
# dir -c (Vertical) 

13. To list the directories with specifying the full time:

# dir --full-time 

14. To skip listing owner with long list:

# dir -g 

15. To group directories before files:

# dir --group-directories-first 

16. Do not list entries with specified pattern:

# dir --hide=ana*
# dir -I=ana*
# dir --ignore=ana* 

17. To print the inode number of each file:

# dir -i
# dir --inode 

18. To list the entries with comma seperated list:

# dir -m 

19. To list the entries with owner and group IDs:

# dir -n
# dir --numeric-uid-gid 

20. To print the raw entry names:

# dir -N
# dir --literal 

21. To list the entries without group info:

# dir -o 

22. To append the indicators to the directories:

# dir -p / 

23. To enclose the entry names in double quotes:

# dir -Q
# dir --quote-name 

24. To use quoting style:

# dir --quoting-style=slash
# dir --quoting-style=literal
# dir --quoting-style=locale
# dir --quoting-style=shell-always
# dir --quoting-style=shell
# dir --quoting-style=c
# dir --quoting-style=escape 

25. To reverse order while sorting:

# dir -r
# dir --reverse

26. To list sub directories recursively:

# dir -R
# dir --recursive 

27. To print the allocated size of each file in blocks:

# dir -s
# dir --size 

28. To sort by file size:

# dir -S 

29. To sort by work instead of name:

# dir --sort=WORD

none -U, extension -X, size -S, time -t, version -v 

30. To list the files specified times (used with -l option):

# dir --time=WORD -l

atime -u, access -u, use -u, ctime -c, or status -c; use specified time as sort key if --sort=time 

31. To list the time with style (used with -l option):

# dir --time-style=STYLE

full-iso, long-iso, iso, locale, +FORMAT.

32. To sort entries by modification time:

# dir -t

33. To list entries with specifying the tab size:

# dir --tabsize=8

34. To list entries in sorted order:

# dir -ult
# dir -ul 

35. To not to sort the entries:

# dir -U 

36. To list entries with natural sort:

# dir -v 

37. To list entries by line instead of columns:

# dir -x

38. To sort alphabatically:

# di -X 

39. To list one file per line:

# dir -1 

40. To display the security context:

# dir -Z 

41. To display only security context and file name:

# dir --scontext 

42. To display security context with long list:

# dir --lcontext 

Filed Under: Linux

Some more articles you might also be interested in …

  1. How To Configure SNMP Daemons: snmpd and snmptrapd on CentOS/RHEL 5,6 and 7
  2. “Read-only locking type set. Write locks are prohibited. Can’t get lock for [volume group]” – error during lvextend
  3. CentOS / RHEL 7 : GRUB2 configuration file /boot/grub2/grub.cfg explained
  4. lsns Command Examples in Linux
  5. fcrackzip Command Examples in Linux
  6. Where to find ASMLib / oracleasm RPMs for CentOS/RHEL, SUSE, OEL
  7. maim: command not found
  8. How to view file size/details from ls command in Unix
  9. xz: command not found
  10. expect Command Examples in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • Chezmoi: A multi-machine dotfile manager, written in Go
  • cheat: Create and view interactive cheat sheets on the command-line
  • chars: Display names and codes for various ASCII and Unicode characters and code points
  • chafa: Image printing in the terminal

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright