Forrest logo
back to the nixos-rebuild tool

nixos-rebuild:tldr:2b0fb

nixos-rebuild: Build and switch to the new configuration, making it the boot default.
$ sudo nixos-rebuild switch
try on your machine

The command "sudo nixos-rebuild switch" is used in NixOS, a Linux distribution based on the Nix package manager.

Here is the breakdown of the command:

  • "sudo": It is a command that allows you to execute a command as a superuser or root. This is required because modifying system-wide configurations in NixOS typically requires superuser permissions.

  • "nixos-rebuild": This is a NixOS-specific command used for managing system configurations. It allows you to switch to a different system configuration without rebooting the entire system.

  • "switch": This is an argument passed to the "nixos-rebuild" command. It tells NixOS to switch to the new system configuration specified in the configuration file (/etc/nixos/configuration.nix by default).

When you run "sudo nixos-rebuild switch", NixOS will read the configuration file, build a new system configuration, and then activate it on the system. This usually involves installing or updating packages, modifying system settings, and managing the boot loader configuration.

Overall, the command is used to apply changes to the system configuration and make them effective immediately, without requiring a system reboot.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the nixos-rebuild tool