解决apt安装deb包时_apt用户无法访问文件的问题
·
博文背景
ubuntu@shanghai:~ $ sudo apt install ./jenkins_2.254_all.deb
Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'jenkins' instead of './jenkins_2.254_all.deb'
The following additional packages will be installed:
daemon
The following NEW packages will be installed:
daemon jenkins
0 upgraded, 2 newly installed, 0 to remove and 182 not upgraded.
Need to get 99.5 kB/66.0 MB of archives.
After this operation, 67.4 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://mirrors.tencentyun.com/ubuntu bionic/universe amd64 daemon amd64 0.6.4-1build1 [99.5 kB]
Get:2 /home/ubuntu/jenkins_2.254_all.deb jenkins all 2.254 [65.9 MB]
Fetched 99.5 kB in 1s (105 kB/s)
Selecting previously unselected package daemon.
(Reading database ... 77822 files and directories currently installed.)
Preparing to unpack .../daemon_0.6.4-1build1_amd64.deb ...
Unpacking daemon (0.6.4-1build1) ...
Selecting previously unselected package jenkins.
Preparing to unpack .../ubuntu/jenkins_2.254_all.deb ...
Unpacking jenkins (2.254) ...
Processing triggers for ureadahead (0.100.0-21) ...
Processing triggers for systemd (237-3ubuntu10.38) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Setting up daemon (0.6.4-1build1) ...
Setting up jenkins (2.254) ...
Processing triggers for systemd (237-3ubuntu10.38) ...
Processing triggers for ureadahead (0.100.0-21) ...
N: Download is performed unsandboxed as root as file '/home/ubuntu/jenkins_2.254_all.deb' couldn't be accessed by user '_apt'. - pkgAcquire::Run (13: Permission denied)
ubuntu@shanghai:~ $ echo $?
0
在最后显示N: Download is performed unsandboxed as root as file ‘/home/ubuntu/jenkins_2.254_all.deb’ couldn’t be accessed by user ‘_apt’. - pkgAcquire::Run (13: Permission denied)
解决办法
网上很多搜到的都是使用chown给_apt用户授予某些文件的权限,但是在我这里我都是以失败告终,我已经考虑了尽可能多的情况,进行了最充分的授权,但是都是失败的。所以在其他博主提出建设性的解决方案和实例之前我不会再对此问题进行研究。我的解决办法是把要安装的文件移动到/tmp目录下再进行安装工作,示例如下:
ubuntu@shanghai:~ $ sudo cp ./jenkins_2.254_all.deb /tmp
ubuntu@shanghai:~ $ sudo apt install /tmp/jenkins_2.254_all.deb
Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'jenkins' instead of '/tmp/jenkins_2.254_all.deb'
The following additional packages will be installed:
daemon
The following NEW packages will be installed:
daemon jenkins
0 upgraded, 2 newly installed, 0 to remove and 182 not upgraded.
Need to get 99.5 kB/66.0 MB of archives.
After this operation, 67.4 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://mirrors.tencentyun.com/ubuntu bionic/universe amd64 daemon amd64 0.6.4-1build1 [99.5 kB]
Get:2 /tmp/jenkins_2.254_all.deb jenkins all 2.254 [65.9 MB]
Fetched 99.5 kB in 1s (97.8 kB/s)
Selecting previously unselected package daemon.
(Reading database ... 77822 files and directories currently installed.)
Preparing to unpack .../daemon_0.6.4-1build1_amd64.deb ...
Unpacking daemon (0.6.4-1build1) ...
Selecting previously unselected package jenkins.
Preparing to unpack /tmp/jenkins_2.254_all.deb ...
Unpacking jenkins (2.254) ...
Processing triggers for ureadahead (0.100.0-21) ...
Processing triggers for systemd (237-3ubuntu10.38) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Setting up daemon (0.6.4-1build1) ...
Setting up jenkins (2.254) ...
Processing triggers for systemd (237-3ubuntu10.38) ...
Processing triggers for ureadahead (0.100.0-21) ...
ubuntu@shanghai:~ $ echo $?
0
更多推荐
已为社区贡献5条内容
所有评论(0)