Descriptionを検索)https://qiita.com/SUZUKI_Masaya/items/1fd9489e631c78e5b007
$ cat /etc/apt/sources.list
以下の内容が重要。
Ubuntuは正式リリース後、いくつかの例外を除いて、ソフトウェア自体のバージョンが変わるような更新は提供しません。
たとえばUbuntu 13.10に「1.2」というバージョンのソフトウェアがあったとして、そのパッケージのバージョンが「1.2-1ubuntu1」だったとします。このとき1.2には致命的な不具合があり、1.3では修正されていたとしましょう。それでもUbutnu 13.10がリリースされたあとであれば、1.3のパッケージが13.10のリポジトリから提供されることは稀です。多くの場合は、正しく不具合報告が行われたのなら、1.3のうち必要な修正箇所のみを1.2に取り込んだうえで、「1.2-1ubuntu1.1」としてリリースされることになります。
ref. https://gihyo.jp/admin/serial/01/ubuntu-recipe/0312
apt update:リポジトリから有効で更新可能なパッケージ一覧を取得apt upgrade:パッケージをアップグレードapt updateはパッケージの更新はしないことに注意する。
$ apt update && apt upgrade -y
$ apt list --installed
$ apt install {{package name}}
$ apt install {{package name}}$ apt install php
以下パッケージがインストールされた。
$ apt list --installed | grep php
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
libapache2-mod-php7.4/focal-updates,focal-security,now 7.4.3-4ubuntu2.4 amd64 [installed,automatic]
php-common/focal,now 2:75 all [installed,automatic]
php7.4-cli/focal-updates,focal-security,now 7.4.3-4ubuntu2.4 amd64 [installed,automatic]
php7.4-common/focal-updates,focal-security,now 7.4.3-4ubuntu2.4 amd64 [installed,automatic]
php7.4-json/focal-updates,focal-security,now 7.4.3-4ubuntu2.4 amd64 [installed,automatic]
php7.4-opcache/focal-updates,focal-security,now 7.4.3-4ubuntu2.4 amd64 [installed,automatic]
php7.4-readline/focal-updates,focal-security,now 7.4.3-4ubuntu2.4 amd64 [installed,automatic]
php7.4/focal-updates,focal-security,now 7.4.3-4ubuntu2.4 all [installed,automatic]
php/focal,now 2:7.4+75 all [installed]
※ WARNING: apt does not have a stable CLI interface. Use with caution in scripts.を表示したくない場合。
$ apt list --installed 2>/dev/null | grep php
$ apt update$ apt list --upgradable | grep {{package name}}$ apt install {{package name}}$ sudo apt upgrade {{package name}}$ apt update
// アップグレード可能なすべてのパッケージを表示
$ apt list --upgradable
// securityアップデートのみ確認
$ apt list --upgradable | grep security
// 特定パッケージを指定して確認
$ apt install -s {{package name}}
完全一致で検索
$ sudo apt list {パッケージ名}
部分一致で検索
sudo apt search {パッケージ名}
$ apt --help
...
search - search in package descriptions
...
インストール済みパッケージではなくても詳細を表示できる。
$ apt show {{package name}}
ref. https://askubuntu.com/questions/187888/what-is-the-correct-way-to-completely-remove-an-application
sudo apt list --installed | grep mysql
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
mysql-apt-config/now 0.8.12-1 all [installed,upgradable to: 0.8.24-1]
mysql-client/unknown,now 5.7.42-1ubuntu18.04 amd64 [installed,upgradable to: 8.0.35-0ubuntu0.22.04.1]
mysql-common/jammy,now 5.8+1.0.8 all [installed,automatic]
mysql-community-client/unknown,now 5.7.42-1ubuntu18.04 amd64 [installed,automatic]
mysql-community-server/unknown,now 5.7.42-1ubuntu18.04 amd64 [installed]
mysql-server/unknown,now 5.7.42-1ubuntu18.04 amd64 [installed,upgradable to: 8.0.35-0ubuntu0.22.04.1]
$ sudo apt-get --purge autoremove mysql-apt-config mysql-client mysql-common mysql-community-client mysql-com
munity-server mysql-server
上記で MySQL5.7 をアンインストールしたので MySQL8 を入れるなどできる。
Ubuntuでは、APTリポジトリの情報は下記の様に登録されます。
/etc/apt/sources.listファイルに記述 または /etc/apt/sources.list.dディレクトリ内にリポジトリ毎に別ファイルとして格納
ref. https://hibiki-press.tech/dev-env/ubuntu/add-ppa/4640
例) ppa:ondrej を追加します。
add-apt-repository を使用してリポジトリを追加します。
$ sudo apt install -y software-properties-common
$ env LC_ALL=C.UTF-8 sudo add-apt-repository ppa:ondrej/php
$ sudo apt update
/etc/apt/sources.list.d/ondrej-ubuntu-php-jammy.list が作成される。
# ondrej-ubuntu-php-jammy.list
deb https://ppa.launchpadcontent.net/ondrej/php/ubuntu/ jammy main
# deb-src https://ppa.launchpadcontent.net/ondrej/php/ubuntu/ jammy main
例) ppa:ondrej php関連
$ sudo apt-get --purge autoremove --purge php7.2-mysql php7.2-mbstring php7.2-xml php7.2-gd php7.2-curl
$ sudo apt-get --purge autoremove --purge php7.2
$ env LC_ALL=C.UTF-8 sudo add-apt-repository --remove ppa:ondrej/php
自動アップグレードの関連コマンド・ディレクトリは以下のとおり^10periodic。
unattended-upgrades:無人アップグレードコマンド/etc/apt/apt.conf.d/20auto-upgrades:無人アップグレードを実行するかを指定/etc/apt/apt.conf.d/50unattended-upgrades:無人アップグレードする対象パッケージを指定apt-daily.timer:apt updateをいつするかを指定apt-daily-upgrade.timer:無人アップグレードをいつするかを指定unattended-upgradeは通常初期状態でインストールされている$ apt list --installed 2>/dev/null | grep unattended-upgrades)   $ apt install unattended-upgradesでインストール/etc/apt/apt.conf.d/20auto-upgrades、/etc/apt/apt.conf.d/50unattended-upgrades を作成unattended-upgrades をインストールしただけでは /etc/apt/apt.conf.d/20auto-upgrades、/etc/apt/apt.conf.d/50unattended-upgrades が作成されない場合は以下コマンドを実行して作成する。
$ dpkg-reconfigure -plow unattended-upgrades
ll /etc/apt/apt.conf.d/
...
-rw-r--r-- 1 root root  129 May 14  2021 10periodic <== 現在では使用しないのが一般的
...
-rw-r--r-- 1 root root   80 Feb 17  2020 20auto-upgrades
...
-rw-r--r-- 1 root root 3800 Feb 17  2020 50unattended-upgrades
...
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "1";
Update-Package-Listsが1の場合は、自動でパッケージのリストを更新します。Unattended-Upgradeが1の場合は、自動でパッケージのアップグレードが行われます。
値を0にすることで無効にできます。
また、パッケージのアップデートに関するログは、/var/log/apt/history.logファイルから履歴を確認できます。
ref. https://qiita.com/Brutus/items/b264384361d08b7475f6
50unattended-upgrades でアップデート対象(セキュリティのみか他パッケージも対象にするか)やアップデート後の再起動などを設定する。
$ sudo unattended-upgrades --dry-run --debug
//  -d, --debug           print debug messages
// --dry-run             Simulation, download but do not install
ref. https://hirose31.hatenablog.jp/entry/2020/02/19/165738
18.04 は apt update を 6:00 と 18:00 に、 unattended-upgrade を 6:00 に実行する。
apt の自動アップデート/アップグレードは sytemd の timer を使用する。
ref. Systemd
apt update をいつするかを指定systemd の timerは以下で確認できます。
$ systemctl list-timers
NEXT                         LEFT          LAST                         PASSED       UNIT                         ACTIVATES
Fri 2022-12-30 03:41:01 UTC  40min left    n/a                          n/a          ua-timer.timer               ua-timer.service
Fri 2022-12-30 06:33:33 UTC  3h 32min left n/a                          n/a          apt-daily-upgrade.timer      apt-daily-upgrade.service
Fri 2022-12-30 08:32:38 UTC  5h 32min left n/a                          n/a          motd-news.timer              motd-news.service
Fri 2022-12-30 12:12:08 UTC  9h left       n/a                          n/a          apt-daily.timer              apt-daily.service
Sat 2022-12-31 02:57:54 UTC  23h left      Fri 2022-12-30 02:57:54 UTC  2min 42s ago systemd-tmpfiles-clean.timer systemd-tmpfiles-clean.service
Mon 2023-01-02 00:00:00 UTC  2 days left   n/a                          n/a          fstrim.timer                 fstrim.service
6 timers listed.
ref. https://gamingpc.one/dev/systemd-timer-cheat/
apt-daily.timer、apt-daily-upgrade.timerの内容は以下コマンドで確認します。
# apt-daily.timerの例
$ systemctl cat apt-daily.timer
# /lib/systemd/system/apt-daily.timer
[Unit]
Description=Daily apt download activities
[Timer]
OnCalendar=*-*-* 6,18:00
RandomizedDelaySec=12h
Persistent=true
[Install]
WantedBy=timers.target
# apt-daily-upgrade.timer
$ systemctl cat apt-daily-upgrade.timer
# /lib/systemd/system/apt-daily-upgrade.timer
[Unit]
Description=Daily apt upgrade and clean activities
After=apt-daily.timer
[Timer]
OnCalendar=*-*-* 6:00
RandomizedDelaySec=60m
Persistent=true
[Install]
WantedBy=timers.target
ref. https://hirose31.hatenablog.jp/entry/2020/02/19/165738
$ sudo unattended-upgrades --debug
//  -d, --debug           print debug messages
ref. https://hirose31.hatenablog.jp/entry/2020/02/19/165738
less /var/log/apt/history.log
aptの設定を確認。
$ apt-config dump
deb(ディーイービー)は、Debianなどで利用されるソフトウェア・パッケージのフォーマット。
拡張子 ".deb" のファイルは、Debian、Ubuntuなど多くのLinuxディストリビューションで利用されるバイナリのパッケージである。これらのパッケージはgzipやbzip2、LZMAで圧縮された2つのアーカイブで構成される。そのうち1つはコントロールの情報、もう1つはデータを含む。
dpkg、aptまたはaptitudeでコントロールすることができる。
PPA:Personal Package Archiveref. https://kazuhira-r.hatenablog.com/entry/2019/03/10/225459
インストールされている拡張モジュール(extension)を調べる
$ php -m
calendar
Core
ctype
date
exif
FFI
fileinfo
filter
ftp
gettext
hash
iconv
json
libxml
openssl
pcntl
pcre
PDO
Phar
posix
readline
Reflection
session
shmop
sockets
sodium
SPL
standard
sysvmsg
sysvsem
sysvshm
tokenizer
Zend OPcache
zlib
[Zend Modules]
Zend OPcache
WordPressに必要なモジュール以下リンクを参照。
https://make.wordpress.org/hosting/handbook/handbook/server-environment/#php-extensions
足りないモジュールをインストール
$ apt install php7.4-curl php7.4-dom php7.4-mbstring php7.4-mysqli php7.4-imagick php7.4-xml php7.4-zip
ipコマンドをインストール。
$ sudo apt install iproute2 
ifconfig、routeをインストール。
$ sudo apt install net-tools
pingをインストール。
$ sudo apt install iputils-ping
dig, nslookupをインストール。
$ sudo apt install dnsutils
tracerouteをインストール。
$ sudo apt install inetutils-traceroute
ESM Apps は Ubuntu Pro に契約すると使用できるよう。
12 additional security updates can be applied with ESM Apps.
Learn more about enabling ESM Apps service at https://ubuntu.com/esm