作業メモです。
ある試験環境の Ubuntu で less
コマンドが使えず、使えるようにした時のメモです。
状況
# Ubuntu 20.04.01 の環境
$cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION="Ubuntu 20.04.1 LTS"
# 実行すると command not found でエラー
$less
bash: less: command not found
# パスも不明
$which less
# 実際になさそう
$ll /usr/bin/less
ls: cannot access '/usr/bin/less': No such file or directory
# インストールはされている?
$dpkg -l less
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-==============-============-============-=================================
ii less 487-0.1 amd64 pager program similar to more
やったこと
まずインストールしようとしたが失敗
# インストールしようとするとエラー
$apt-get update
$apt-get install less -y
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
libc-ares2 libhttp-parser2.7.1 libnetplan0 libuv1 linux-headers-4.15.0-29
linux-headers-4.15.0-29-generic linux-image-4.15.0-29-generic linux-modules-4.15.0-29-generic
linux-modules-extra-4.15.0-29-generic nodejs-doc python3-netifaces
Use 'apt autoremove' to remove them.
The following additional packages will be installed:
libtinfo6
The following NEW packages will be installed:
libtinfo6
The following packages will be upgraded:
less
1 upgraded, 1 newly installed, 0 to remove and 665 not upgraded.
Need to get 210 kB of archives.
After this operation, 567 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://archive.ubuntu.com/ubuntu focal/main amd64 libtinfo6 amd64 6.2-0ubuntu2 [87.0 kB]
Get:2 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 less amd64 551-1ubuntu0.1 [123 kB]
Fetched 210 kB in 0s (1398 kB/s)
debconf: delaying package configuration, since apt-utils is not installed
dpkg: unrecoverable fatal error, aborting:
unknown system group 'crontab' in statoverride file; the system group got removed
before the override, which is most probably a packaging bug, to recover you
can remove the override manually with dpkg-statoverride
E: Sub-process /usr/bin/dpkg returned an error code (2)
dpkg-statoverride
というのをマニュアルで消せば良いらしい
システム管理者が配布状態の Debian パッケージと異なる所有者またはパーミッションでファイル (またはディレクトリなど) をインストールしたい場合、 ファイルがインストールされる際に毎回異なった設定を使うよう dpkg に指示を出すため dpkg-statoverride を使うことができます。 これによって、パッケージメンテナは標準のパーミッションでファイルを配布しておき、システム管理者が望む変更を加えられるようにすることができます
特に必要ないので一旦移動させる
$mv /var/lib/dpkg/statoverride /tmp/
$apt-get install less -y
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
libc-ares2 libhttp-parser2.7.1 libnetplan0 libuv1 linux-headers-4.15.0-29
linux-headers-4.15.0-29-generic linux-image-4.15.0-29-generic linux-modules-4.15.0-29-generic
linux-modules-extra-4.15.0-29-generic nodejs-doc python3-netifaces
Use 'apt autoremove' to remove them.
The following additional packages will be installed:
libtinfo6
The following NEW packages will be installed:
libtinfo6
The following packages will be upgraded:
less
1 upgraded, 1 newly installed, 0 to remove and 665 not upgraded.
Need to get 210 kB of archives.
After this operation, 567 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu focal/main amd64 libtinfo6 amd64 6.2-0ubuntu2 [87.0 kB]
Get:2 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 less amd64 551-1ubuntu0.1 [123 kB]
Fetched 210 kB in 0s (1442 kB/s)
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package libtinfo6:amd64.
(Reading database ... 145436 files and directories currently installed.)
Preparing to unpack .../libtinfo6_6.2-0ubuntu2_amd64.deb ...
Unpacking libtinfo6:amd64 (6.2-0ubuntu2) ...
Preparing to unpack .../less_551-1ubuntu0.1_amd64.deb ...
update-alternatives: error: alternative path /usr/bin/less doesn't exist
dpkg: error processing archive /var/cache/apt/archives/less_551-1ubuntu0.1_amd64.deb (--unpack):
new less package pre-installation script subprocess returned error exit status 2
Errors were encountered while processing:
/var/cache/apt/archives/less_551-1ubuntu0.1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
エラーは変わったが失敗
upgrade しようとして失敗している
方針を変えて一旦消してから再インストールする
$apt-get remove less -y
$apt-get install less -y
良さそう
確認
# 成功
$which less
/usr/bin/less
$less .bashrc
OK