[Ubuntu] sudo: add-apt-repository: command not found エラーの解決方法

Ubuntu で Let’s Encrypt の自動更新設定をするために Certbot をインストールしようとしたら、sudo: add-apt-repository: command not found というエラーが発生したときの解決方法をご紹介します。

エラーメッセージ

$ sudo add-apt-repository ppa:certbot/certbot
sudo: add-apt-repository: command not found

sudo: add-apt-repository: command not found エラーの解決方法

以下の3つどれかを apt-get install すれば sudo: add-apt-repository: command not found エラーを解消できます。

sudo apt-get install software-properties-common
sudo apt-get install python3-software-properties
sudo apt-get install python-software-properties

インストールしたら再び sudo add-apt-repository ppa:certbot/certbot すると、今度は下記のようにうまくいくと思います。

$ sudo add-apt-repository ppa:certbot/certbot
 
 This is the PPA for packages prepared by Debian Let's Encrypt Team and backported for Ubuntu(s).
 More info: https://launchpad.net/~certbot/+archive/ubuntu/certbot
Press [ENTER] to continue or ctrl-c to cancel adding it
gpg: keyring `/tmp/tmpg3b8izxd/secring.gpg' created
gpg: keyring `/tmp/tmpg3b8izxd/pubring.gpg' created
gpg: requesting key 75BCA694 from hkp server keyserver.ubuntu.com
gpg: /tmp/tmpg3b8izxd/trustdb.gpg: trustdb created
gpg: key 75BCA694: public key "Launchpad PPA for certbot" imported
gpg: Total number processed: 1
gpg:               imported: 1  (RSA: 1)
OK

以上です。

参考情報