
ubuntu 22.04 通过`apt upgrade` 安装完新版本的 kernel 后会进入一个`text-based user interfaces`，提示用户哪些服务需要重启。

有以下两种方法

## 更改配置

```bash
echo "\\$nrconf{kernelhints} = 0;" >> /etc/needrestart/needrestart.conf
echo "\\$nrconf{restart} = 'l';" >> /etc/needrestart/needrestart.conf

```

或者增加一个配置片段

```bash
cat > /etc/needrestart/conf.d/silence_kernel.conf <<'EOF'
$nrconf{kernelhints} = 0;
$nrconf{restart} = 'l';
EOF

```

## 卸载 needrestart

```bash
sudo apt autoremove -y --purge needrestart

```

## 参考

- [https://askubuntu.com/questions/1367139/apt-get-upgrade-auto-restart-services](https://askubuntu.com/questions/1367139/apt-get-upgrade-auto-restart-services)
- [https://serverfault.com/questions/743707/how-to-disable-the-newer-kernel-warning-in-debian-jessie](https://serverfault.com/questions/743707/how-to-disable-the-newer-kernel-warning-in-debian-jessie)
- [https://manpages.ubuntu.com/manpages/trusty/man1/needrestart.1.html](https://manpages.ubuntu.com/manpages/trusty/man1/needrestart.1.html)
- [https://packages.ubuntu.com/jammy/needrestart](https://packages.ubuntu.com/jammy/needrestart)

