Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)

最近想更新node版本到v20,根据官方文档(GitHub - nodesource/distributions: NodeSource Node.js Binary Distributions)更新:
 

Using Debian, as root
curl -fsSL https://deb.nodesource.com/setup_20.x | bash - &&\
apt-get install -y nodejs

在执行上述语句后,报如下错误:

## Installing the NodeSource Node.js 20.x repo...


## Populating apt-get cache...

+ apt-get update
Reading package lists... Done
E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)
E: Unable to lock directory /var/lib/apt/lists/
W: Problem unlinking the file /var/cache/apt/pkgcache.bin - RemoveCaches (13: Permission denied)
W: Problem unlinking the file /var/cache/apt/srcpkgcache.bin - RemoveCaches (13: Permission denied)
Error executing command, exiting

后来想了想,嗯,我当前这个用户虽然权限很高,但不是root,可能还是权限不够,查看了下文件权限,果然只能是root。

$ ls -al /var/lib/apt/lists/lock
-rw-r----- 1 root root 0 Aug 11 22:06 /var/lib/apt/lists/lock

其实人家nodejs安装上写了as root,还是有点侥幸了。

老老实实把sudo加上再执行就没问题了。

$ curl -fsSL https://deb.nodesource.com/setup_20.x | sudo bash - && sudo apt-get install -y nodejs

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值