---
# System prepended metadata

title: Disable Ubuntu auto update and upgrade
tags: [linux, ubuntu, tutorials]

---

###### tags: `tutorials` `linux` `ubuntu`
# Disable Ubuntu auto update and upgrade
## 禁止 ubuntu 自動更新 kernel
### 使用 `apt-mark`
#### 鎖住 kernel
```bash=
$ sudo apt-mark hold $(uname -r)
```
#### 檢視被鎖住的套件
```bash=
$ apt-mark showhold
```
#### 取消鎖定 kernel
```bash=
$ sudo apt-mark unhold $(uname -r)
```
:::warning
更多相關指令用法請看
```bash= !
$ apt-mark --help
```
:::

## 禁止 ubuntu 自動更新套件
```bash= !
$ sudo systemctl disable --now apt-daily{,-upgrade}.{timer,service} && sudo sed -i 's/APT::Periodic::Update-Package-Lists "1"/APT::Periodic::Update-Package-Lists "0"/' /etc/apt/apt.conf.d/20auto-upgrades
```