Forrest logo
back to the nixos-rebuild tool

nixos-rebuild:tldr:0a5ff

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

The command sudo nixos-rebuild switch --upgrade is used in NixOS, a Linux distribution built on top of the Nix package manager, to upgrade the system.

Here is a breakdown of the command:

  • sudo: It is a command that allows the user to run programs with the security privileges of another user, typically the superuser or root. By using sudo, you are executing the following command with administrative privileges, which is usually required for system-level operations.

  • nixos-rebuild: It is a utility command provided by NixOS for managing system configurations. It allows you to build and switch to different system configurations.

  • switch: It is an action performed by nixos-rebuild, which replaces the current system configuration with the new one specified.

  • --upgrade: It is an option/flag for the nixos-rebuild command, indicating that the system should be upgraded to the latest available version.

Therefore, executing sudo nixos-rebuild switch --upgrade will initiate a system upgrade by rebuilding and switching to a new system configuration that includes the latest available updates from NixOS package repositories.

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