Short answer: killall Dock only restarts the Dock. If the setting you wrote is misspelled, written to the wrong place, or overruled by a profile, the fresh Dock reads the same old values and looks unchanged.
Run defaults read com.apple.dock after your change. If your key and value are missing or wrong there, the problem is the write, and the restart was fine.
The Dock should vanish for about a second and come back. If Terminal printed No matching processes belonging to you were found, the name was typed in lower case. The process is Dock, with a capital D:
killall Dock
More on what the command does, and what it leaves alone, is in what killall Dock does.
defaults write accepts any key you give it and reports no error. Write tilesise or contents-immuteable and macOS stores a setting nothing ever reads. Read the key back and compare it letter by letter:
defaults read com.apple.dock tilesize
Delete a misspelled key so it does not confuse you later:
defaults delete com.apple.dock tilesise
The commands for every Dock key are collected in Mac Dock defaults commands.
Dock settings live in the domain com.apple.dock. A command copied from an old forum post sometimes writes to a different domain, or to a file path, and the Dock never looks there. Two common slips:
.plist to the end of the domain.com.apple.dock when it belongs to com.apple.spaces, or the other way round.Each key expects a type. The locks expect a true or false value, written with -bool. The size expects a number, written with -int. A value written without its type is stored as text, which the Dock may ignore:
defaults write com.apple.dock size-immutable -bool true; killall Dock
sudo defaults write com.apple.dock ... writes to the root user's preferences. Your Dock runs as you and never reads them. Run the same command without sudo. The Dock needs no administrator password to change.
macOS keeps preferences in memory, in a background process called cfprefsd. If you change ~/Library/Preferences/com.apple.dock.plist in a text editor or Xcode, the cached copy can win and write your edit away. Use defaults write, which goes through the cache. If you must edit the file, log out and back in afterwards.
On a work or school Mac, a profile from IT can set Dock values. A managed value beats yours every time, so your write lands and the Dock ignores it. Open System Settings, then General, then Device Management. A profile listed there that mentions the Dock explains the result. Managed values also show up in /Library/Managed Preferences. Ask whoever manages the Mac, and see Mac Dock settings greyed out for the signs.
Some changes do take, and then come undone. Moving the size slider in System Settings writes a new size over yours. Restoring from a backup, migrating to a new Mac, or a macOS update can bring back an older Dock file. If the Dock keeps going back to an old layout on its own, work through why the Mac Dock resets itself.
Restarting the Dock also restarts Mission Control, because the Dock runs both. Your desktops and full-screen apps survive. Two things can look like a reset:
defaults write com.apple.dock mru-spaces -bool false; killall Dock.When the Dock finally looks the way you want, the four built-in locks stop it being changed by a drag or a stray slider: size-immutable, position-immutable, contents-immutable and autohide-immutable. Lock the Mac Dock with Terminal has each command and its undo.
Still Dock puts the same locks behind switches in the menu bar. You type no commands and cannot misspell a key. It restarts the Dock for you and shows whether each lock is on. The size lock is in the free version, and the other locks are part of Still Dock Pro.
It prints nothing when it succeeds, and it also succeeds with a misspelled key. Silence tells you the value was stored, and defaults read tells you what was stored.
Rarely. Dock settings apply after killall Dock. Spaces settings that span displays need a log out. A full restart is only worth trying if the Dock does not come back at all.
No. It deletes nothing and closes no apps. The command that removes your Dock setup is defaults delete com.apple.dock, which is a reset.