dscacheutil - macOS


The dscacheutil command in macOS is used for querying and managing the Directory Service cache. It provides tools to flush the cache, perform lookups, and gather statistics. This command is particularly useful for system administrators and developers dealing with network services and user account management, helping to verify entries in the Directory Services cache and troubleshoot related issues.


The general syntax for using dscacheutil is as follows:

dscacheutil -q category [-a key value]
dscacheutil -cachedump [-buckets] [-entries [category]]
dscacheutil -configuration
dscacheutil -flushcache
dscacheutil -statistics

Each category of the command’s operation is specified by different options and flags.


  • -q category: Query the cache for a specific category, such as user, group, host, etc. It must be followed by a category name.
  • -a key value: Used with -q, this specifies additional attributes for narrowing down the query.
  • -cachedump: Dumps cache contents. Use with optional flags for detailed output.
  • -buckets: When used with -cachedump, shows bucket information of the cache.
  • -entries [category]: Filters the cachedump to include only entries from specified categories.
  • -configuration: Shows the current configuration of the cache.
  • -flushcache: Clears the entire cache. Useful for resolving corruption issues or after changes in the network configuration.
  • -statistics: Displays statistics about cache usage.


  1. Querying User Info:

    dscacheutil -q user -a name root

    This command will provide details about the user named “root”.

  2. Flushing the DNS Cache:

    dscacheutil -flushcache

    Use this command to clear the DNS cache, potentially resolving certain connectivity issues.

  3. View Cache Statistics:

    dscacheutil -statistics

    Displays statistics about how the cache has been used, which can be helpful for troubleshooting performance issues.

Common Issues

  • Cache Not Updating: If changes in network services aren’t reflected, try flushing the cache using dscacheutil -flushcache.
  • Command not found: Ensure the command is typed correctly. It’s specific to macOS, and its absence can suggest an issue with the system’s setup or PATH configuration.


dscacheutil can be scripted with bash or used in conjunction with other commands. Below is an example of how to check if a user exists in the system and print relevant information:

if dscacheutil -q user -a name $username; then
    echo "$username exists in the system."
    echo "$username does not exist."

This script uses conditional statements to provide clear feedback based on the user query.

  • dscl: A command for interacting directly with Directory Services, which can manipulate user accounts and fetch more detailed information.
  • scutil: This command interacts with System Configuration and can modify network parameters similar to dscacheutil.

For further reading and in-depth understanding of macOS command line utilities, visit the official Apple macOS Documentation.