# How do I stop a destructive command on a production server before it runs?

Set a host's environment to Production in Valakes. A destructive command on it opens a red card, and you type the host name before it runs.

Source: https://valakes.com/guides/stop-rm-rf-on-production/

Last updated: 2026-11-27

Mark the host as Production once. Valakes then holds a dangerous command on a card until you type the host name.

A mistyped `rm -rf` on the wrong server is hard to undo: the shell has no trash and no undo. Valakes does two things about it. It makes production hard to miss, and it makes a dangerous command ask before it runs. [Production marking](https://valakes.com/features/production-marking/) has the details on the first. To run one command on several hosts at once, production included, see [Broadcast a command to several servers safely](https://valakes.com/guides/run-one-command-on-several-servers/). The whole day on live servers is in [working on production servers without fear of one wrong command](https://valakes.com/use-cases/production-servers/).

## Steps

1. **Mark the host as production**

   In the host editor, set **Environment** to Production. Valakes will not save a host without an environment. It pre-selects Production when the name, address or tags contain `prod`, `production`, `live` or `prd`, and says why ("Looks like production"). You confirm or change it. Hosts you import from `~/.ssh/config` go through the same step. The picture shows the editor with Production selected.

   Changing a host away from Production asks for a confirmation in a native window.

2. **Look for the red**

   On a production host you see red in six places: a stripe and a `PROD` badge on the tab, a thin line along the top of the terminal, a `prod` badge in the composer, a `PROD` segment in the status bar, a red focus ring on the composer and a Run button that reads **Run on PROD**.

   The environment always comes from the host record you saved, never from anything the server prints, so a server cannot make a production tab look like a development one. The terminal background stays untinted so that `vim` and `htop` keep their colors.

3. **Type the command in the composer**

   Type the command and press Enter. Valakes reads the line before it runs. A dangerous command opens the "High risk" card. It gives the reason and, for a delete, the blast radius: "3 files" in the picture, where the test folder holds three files.

   **Cancel** has the focus, so pressing Enter does not run the command. On a production host the card carries the red `PROD` badge, and **Run anyway** stays disabled until you type the host name. On production, a command rated Medium counts as High and asks too.

4. **Cancel, or type the host name**

   If the command is wrong, press **Cancel**. If you mean it, type the host name in the field and press **Run anyway**.

   Do not use **Don't ask on this host** on a production server. It switches the card off for that host after one native confirmation. In Settings, Command check, the choice Off silences the check for every host. The default is "Dangerous only", and "Explain all" also explains every command in one line.

5. **Know that the Files panel asks too**

   Delete on the server pane of the [Files panel](https://valakes.com/features/files/) always asks, with Cancel focused. On a production host, deleting a folder with content shows "Delete ... on PROD", the number of files and their size, and you type the host name. The typed host name applies while Command check is on for that host. The picture shows a folder with 17 files and folders.

   Valakes refuses to delete `/`, your home directory on the server and every folder above it. Dropping files on a production server pane first asks "Upload ... to PROD?".

## What it does not do

The check reads the line you typed in the composer. It does not see inside a script (`sh x.sh`), a remote alias or function, SQL read from a file, or what a program does after it starts. Commands you type in Raw mode, in a full-screen program or in a nested shell never reach it. A keystroke broadcast runs no check either.

The count of affected files assumes the default shell options. `rm -rf "$HOME/x"` still asks, but the path depends on shell expansion, so no count is shown.

The check is mistake prevention for you. The typed host name and **Run anyway** guard your own hand, not a window that something else has taken over. The second question in Files protects you from a slip in the same way, and it goes away with the command check for that host.

## Documentation and help

[Read the docs: Command check](https://docs.valakes.com/command-check/)

[Help centre: A command was held](https://support.valakes.com/a-command-was-held/)

## Read next

- [Dangerous commands wait for you](https://valakes.com/features/command-check/): The command check reads each command you type before it runs. A dangerous one stops on a card that says why, and it runs only when you choose.
- [How do I use rm safely on a server?](https://valakes.com/learn/safe-rm-on-servers/): List what a command will remove before you run it, with ls, find or echo. Use rm -I so that rm asks once before a recursive delete, and write variables as "${dir:?}" so that an empty one stops the command. The built-in --preserve-root protects only the path /.
- [How do I find the largest files on a Linux server?](https://valakes.com/learn/find-large-files/): Run find /path -type f -size +100M to list the files above 100 MiB, or du -ah /path | sort -h | tail to see the biggest files and folders together. Add -xdev so find stays on one disk. If df says the disk is full and du cannot find the space, look for deleted files that a program still holds open with lsof +L1.

The screenshots show Valakes built from commit 0b8738d, taken on 25 November 2026.
