为什么 sudo apt install /path/*.deb 产生权限被拒绝,而 sudo dpkg -i /path/*.deb 工作正常?

为什么 sudo apt install /path/*.deb 产生权限被拒绝,而 sudo dpkg -i /path/*.deb 工作正常?

我很长一段时间想知道为什么sudo apt无法deb从某些文件夹安装本地并出现错误:

Failed to fetch a file... Permission denied 

最近我尝试了sudo dpkg -i同样的路径并且成功了。该路径位于安装有 的 USB 上udisks,因此它位于一个/media/user文件夹内,到目前为止我猜测它是由于ACL该文件夹 ( drwxr-x---+) 引起的。但是为什么一个命令sudo被拒绝了呢?为什么同一文件上的其他命令可以正常工作?

我会使用dpkg,但它不会按照正确的顺序处理预依赖项,而不是apt.

有什么办法可以跳过 的 fetch 部分吗apt?在获取之前,输出开始附近apt给出Note selecting abc instead of abc.20-2-a.deb.有没有一种方法可以处理apt特定deb文件,而不是尝试查找其他文件?

PS我知道安装本地debs的其他方法,例如添加本地存储库或使用非预安装apt-offline如何在没有网络的情况下安装软件包,但我想让事情变得简单(加上我怀疑本地存储库方式可能会面临相同的权限被拒绝的问题)。

添加2:

sudo mount rd -t tmpfs /media/mint/rd -o x-mount.mkdir
sudo mount ram -t tmpfs /media/ram -o x-mount.mkdir

apt fromrd失败,apt fromram工作正常,所以我猜问题出在mintACL 中,我尝试在下面展示它,我不太了解 Linux 上的 ACL。插入的USB驱动器安装在用户mint(liveUSB用户)下,所以我想解决这个问题。当我sudo -i获得 root 命令提示符时,我可以手动创建mkdir一个文件,那么为什么会失败呢?mvrdsudo touch /media/mint/rd/mpv/1sudo apt

添加:

权限公司访问控制列表:

mint@mint:~$ ls -la /media/mint/rd
total 0
drwxrwxrwt  4 root root 80 Oct 24 03:23 .
drwxr-xrw-+ 4 root root 80 Oct 24 03:22 ..
drwxrwxrwx  2 mint mint 80 Oct 12 23:01 ffmpeg
drwxrwxrwx  2 mint mint 60 Oct 11 17:53 mpv

ACL:
mint@mint:~$ getfacl /media/mint/
getfacl: Removing leading '/' from absolute path names
# file: media/mint/
# owner: root
# group: root
user::rwx
user:mint:r-x
group::---
mask::r-x
other::rw-

apt / apt-get 输出:

mint@mint:~$ sudo apt install -d /media/mint/rd/ffmpeg/*.deb
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Note, selecting 'ffmpeg' instead of '/media/mint/rd/ffmpeg/ffmpeg_7%3a4.2.4-1ubuntu0.1_amd64.deb'
Note, selecting 'libavresample4' instead of '/media/mint/rd/ffmpeg/libavresample4_7%3a4.2.4-1ubuntu0.1_amd64.deb'
Suggested packages:
  ffmpeg-doc
The following NEW packages will be installed:
  ffmpeg libavresample4
0 upgraded, 2 newly installed, 0 to remove and 71 not upgraded.
Need to get 1507 kB of archives.
After this operation, 2275 kB of additional disk space will be used.
Ign:1 http://archive.ubuntu.com/ubuntu focal-updates/universe amd64 libavresample4 amd64 7:4.2.4-1ubuntu0.1
Ign:2 http://archive.ubuntu.com/ubuntu focal-updates/universe amd64 ffmpeg amd64 7:4.2.4-1ubuntu0.1
Ign:1 http://security.ubuntu.com/ubuntu focal-updates/universe amd64 libavresample4 amd64 7:4.2.4-1ubuntu0.1
Ign:2 http://security.ubuntu.com/ubuntu focal-updates/universe amd64 ffmpeg amd64 7:4.2.4-1ubuntu0.1
Get:1 http://security.ubuntu.com/ubuntu focal-updates/universe amd64 libavresample4 amd64 7:4.2.4-1ubuntu0.1 [54.2 kB]
Err:1 http://security.ubuntu.com/ubuntu focal-updates/universe amd64 libavresample4 amd64 7:4.2.4-1ubuntu0.1
  File not found - /media/mint/rd/ffmpeg/libavresample4_70x0.07ffe00000006p-10224.2.4-1ubuntu0.1_amd64.deb (13: Permission denied)
Get:2 http://security.ubuntu.com/ubuntu focal-updates/universe amd64 ffmpeg amd64 7:4.2.4-1ubuntu0.1 [1453 kB]
Err:2 http://security.ubuntu.com/ubuntu focal-updates/universe amd64 ffmpeg amd64 7:4.2.4-1ubuntu0.1
  File not found - /media/mint/rd/ffmpeg/ffmpeg_70x0.07ffe00000002p-10224.2.4-1ubuntu0.1_amd64.deb (13: Permission denied)
E: Failed to fetch file:/media/mint/rd/ffmpeg/libavresample4_7%3a4.2.4-1ubuntu0.1_amd64.deb  File not found - /media/mint/rd/ffmpeg/libavresample4_70x0.07ffe00000006p-10224.2.4-1ubuntu0.1_amd64.deb (13: Permission denied)
E: Failed to fetch file:/media/mint/rd/ffmpeg/ffmpeg_7%3a4.2.4-1ubuntu0.1_amd64.deb  File not found - /media/mint/rd/ffmpeg/ffmpeg_70x0.07ffe00000002p-10224.2.4-1ubuntu0.1_amd64.deb (13: Permission denied)
E: Some files failed to download
mint@mint:~$ sudo apt-get install -d /media/mint/rd/ffmpeg/*.deb
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Note, selecting 'ffmpeg' instead of '/media/mint/rd/ffmpeg/ffmpeg_7%3a4.2.4-1ubuntu0.1_amd64.deb'
Note, selecting 'libavresample4' instead of '/media/mint/rd/ffmpeg/libavresample4_7%3a4.2.4-1ubuntu0.1_amd64.deb'
Suggested packages:
  ffmpeg-doc
The following NEW packages will be installed:
  ffmpeg libavresample4
0 upgraded, 2 newly installed, 0 to remove and 71 not upgraded.
Need to get 1507 kB of archives.
After this operation, 2275 kB of additional disk space will be used.
Ign:1 http://archive.ubuntu.com/ubuntu focal-updates/universe amd64 libavresample4 amd64 7:4.2.4-1ubuntu0.1
Ign:2 http://archive.ubuntu.com/ubuntu focal-updates/universe amd64 ffmpeg amd64 7:4.2.4-1ubuntu0.1
Ign:1 http://security.ubuntu.com/ubuntu focal-updates/universe amd64 libavresample4 amd64 7:4.2.4-1ubuntu0.1
Ign:2 http://security.ubuntu.com/ubuntu focal-updates/universe amd64 ffmpeg amd64 7:4.2.4-1ubuntu0.1
Get:1 http://security.ubuntu.com/ubuntu focal-updates/universe amd64 libavresample4 amd64 7:4.2.4-1ubuntu0.1 [54.2 kB]
Err:1 http://security.ubuntu.com/ubuntu focal-updates/universe amd64 libavresample4 amd64 7:4.2.4-1ubuntu0.1
  File not found - /media/mint/rd/ffmpeg/libavresample4_70x0.07fff00000006p-10224.2.4-1ubuntu0.1_amd64.deb (13: Permission denied)
Get:2 http://security.ubuntu.com/ubuntu focal-updates/universe amd64 ffmpeg amd64 7:4.2.4-1ubuntu0.1 [1453 kB]
Err:2 http://security.ubuntu.com/ubuntu focal-updates/universe amd64 ffmpeg amd64 7:4.2.4-1ubuntu0.1
  File not found - /media/mint/rd/ffmpeg/ffmpeg_70x0.07fff00000002p-10224.2.4-1ubuntu0.1_amd64.deb (13: Permission denied)
E: Failed to fetch file:/media/mint/rd/ffmpeg/libavresample4_7%3a4.2.4-1ubuntu0.1_amd64.deb  File not found - /media/mint/rd/ffmpeg/libavresample4_70x0.07fff00000006p-10224.2.4-1ubuntu0.1_amd64.deb (13: Permission denied)
E: Failed to fetch file:/media/mint/rd/ffmpeg/ffmpeg_7%3a4.2.4-1ubuntu0.1_amd64.deb  File not found - /media/mint/rd/ffmpeg/ffmpeg_70x0.07fff00000002p-10224.2.4-1ubuntu0.1_amd64.deb (13: Permission denied)
E: Some files failed to download

答案1

据我现在了解(感谢评论)sudo apt使用_aptuser.由于父文件夹缺乏执行权限,/media/mint因此无法访问文件。解决方法是添加 exec 权限,例如

setfacl -m u:_apt:x /media/mint

相关内容