How to use the command 'systemsetup' (with examples)
- Osx
- December 25, 2023
The ‘systemsetup’ command is a versatile tool in macOS that allows users to configure various system preferences and settings. It can be used to enable remote login, specify time zone and network time settings, control sleep behavior, manage startup disks, and more. In this article, we will illustrate each of these use cases with examples.
Use case 1: Enable remote login (SSH)
Code:
systemsetup -setremotelogin on
Motivation:
Enabling remote login allows users to access their macOS machine remotely via SSH. This is particularly useful for system administrators or users who need to manage their machine remotely.
Explanation:
The ‘-setremotelogin’ argument is used to enable or disable remote login. In this example, the ‘on’ value is passed to enable remote login.
Example output:
Remote Login: On
Use case 2: Specify timezone, NTP Server, and enable network time
Code:
systemsetup -settimezone "US/Pacific" -setnetworktimeserver us.pool.ntp.org -setusingnetworktime on
Motivation:
Setting the timezone and network time-related settings accurately is crucial for ensuring the correct time and date on the macOS machine. This is especially important for applications that rely on accurate time synchronization.
Explanation:
- ‘-settimezone “US/Pacific”’: Sets the timezone to US/Pacific.
- ‘-setnetworktimeserver us.pool.ntp.org’: Specifies the NTP (Network Time Protocol) server to use for time synchronization.
- ‘-setusingnetworktime on’: Enables network time syncing using the specified NTP server.
Example output:
Time Zone: US/Pacific
Network Time Server: us.pool.ntp.org
Using Network Time: On
Use case 3: Make the machine never sleep and automatically restart on power failure or kernel panic
Code:
systemsetup -setsleep off -setrestartpowerfailure on -setrestartfreeze on
Motivation:
In certain scenarios, it may be necessary for a macOS machine to remain awake permanently without sleeping. Additionally, automatically restarting on power failure or kernel panic can help ensure uninterrupted operation.
Explanation:
- ‘-setsleep off’: Disables sleep mode, preventing the machine from sleeping.
- ‘-setrestartpowerfailure’: Enables automatic restart in the event of a power failure.
- ‘-setrestartfreeze’: Enables automatic restart in the event of a kernel panic.
Example output:
Sleep: Off
Restart on Power Failure: On
Restart on Freeze: On
Use case 4: List valid startup disks
Code:
systemsetup -liststartupdisks
Motivation:
Listing the valid startup disks can be helpful when troubleshooting boot-related issues or when wanting to verify the available boot options on a macOS machine.
Explanation:
The ‘-liststartupdisks’ argument is used to display a list of valid startup disks on the machine.
Example output:
Available startup disks:
disk0
Use case 5: Specify a new startup disk
Code:
systemsetup -setstartupdisk path/to/directory
Motivation:
Specifying a new startup disk is useful when you want to change the default boot volume on a macOS machine or when you have multiple bootable disks and want to switch between them.
Explanation:
The ‘-setstartupdisk’ argument followed by the path to the directory of the desired startup disk is used to specify a new startup disk.
Example output:
Startup disk set to:
path/to/directory
Conclusion:
The ‘systemsetup’ command in macOS offers a wide range of functionalities to configure system preferences and settings. Whether it is enabling remote login, managing time-related settings, controlling sleep behavior, or managing startup disks, this command provides a convenient way to customize and optimize the macOS experience.