# scutil — Query and Set System Configuration

> Practical guide to scutil: set the computer name, hostname and LocalHostName, query DNS and proxy settings, and read the dynamic system store on macOS.

Source: https://www.jpkc.com/db/en/cheatsheets/macos/scutil/

<!-- PROSE:intro -->
`scutil` is the command-line tool for querying and setting the dynamic system configuration on macOS – the same configuration that sits behind System Settings. With it you read and change the three computer names (ComputerName, HostName, LocalHostName), inspect the active DNS and proxy configuration, and check whether a host is reachable on the network. Through its interactive shell you also reach the dynamic store, where macOS keeps the current network and system state as key-value pairs. This guide walks you through the commands you actually need day to day – from reading the machine name to peeking into the network state.
<!-- PROSE:intro:end -->

## Computer Names

`scutil --get ComputerName` — Show the computer name (user-friendly name).

```bash
scutil --get ComputerName
```

`scutil --set ComputerName '<name>'` — Set the computer name.

```bash
sudo scutil --set ComputerName 'My MacBook Pro'
```

`scutil --get HostName` — Show the hostname (FQDN-style).

```bash
scutil --get HostName
```

`scutil --set HostName '<name>'` — Set the hostname.

```bash
sudo scutil --set HostName 'macbook.local'
```

`scutil --get LocalHostName` — Show the local hostname (Bonjour name, used for .local).

```bash
scutil --get LocalHostName
```

`scutil --set LocalHostName '<name>'` — Set the local hostname (no spaces, used for .local).

```bash
sudo scutil --set LocalHostName 'macbook'
```

## DNS

`scutil --dns` — Show all DNS configuration (resolvers, search domains).

```bash
scutil --dns
```

`scutil --dns | grep nameserver` — Show only the active DNS nameservers.

```bash
scutil --dns | grep nameserver
```

## Proxy

`scutil --proxy` — Show current proxy configuration.

```bash
scutil --proxy
```

## Network Reachability

`scutil -r <host>` — Check network reachability for a host.

```bash
scutil -r www.apple.com
```

`scutil -W -r <host>` — Watch for reachability changes (blocks until change).

```bash
scutil -W -r www.apple.com
```

## Dynamic Store (Interactive)

`scutil` — Enter the interactive scutil shell.

```bash
scutil
```

`> list` — List all keys in the dynamic store (inside scutil).

```bash
> list
```

`> show <key>` — Show the value of a dynamic store key.

```bash
> show State:/Network/Global/IPv4
```

`> show State:/Network/Interface/en0/IPv4` — Show IPv4 config of a specific interface.

```bash
> show State:/Network/Interface/en0/IPv4
```

`> quit` — Exit the interactive scutil shell.

```bash
> quit
```

<!-- PROSE:outro -->
## Conclusion

scutil is the go-to tool on macOS when you want to manage system names and network state in a scriptable, reproducible way rather than clicking through the graphical settings. The `--get` queries and a look into the dynamic store are harmless and safe to run at any time. `--set` is a different matter: setting ComputerName, HostName or LocalHostName requires `sudo`, changes system-wide names, and immediately affects Bonjour and `.local` reachability on the network – wrong or inconsistent values can cause confusion there. Keep the three names consistent where possible, and avoid spaces and special characters in the LocalHostName.

## Further Reading

- [scutil(8) – macOS man page](https://keith.github.io/xcode-man-pages/scutil.8.html) – official Apple man page covering all options
- [SystemConfiguration – Apple Developer](https://developer.apple.com/documentation/systemconfiguration) – documentation of the underlying framework
<!-- PROSE:outro:end -->

## Related Commands

- [caffeinate](https://www.jpkc.com/db/en/cheatsheets/macos/caffeinate/) – prevent the Mac from going to sleep
- [defaults](https://www.jpkc.com/db/en/cheatsheets/macos/defaults/) – read and write the preferences system (plists)
- [diskutil](https://www.jpkc.com/db/en/cheatsheets/macos/diskutil/) – manage disks, partitions and volumes

