今天我在中创建了一个新的别名~/.bash_aliases
:
alias upgrade='aptitude update && aptitude full-upgrade -y'
但是当我运行时upgrade
,它显示:
E: Could not open the lock file "/var/lib/apt/lists/lock" - open (13: Permission denied)
E: Could not lock /var/lib/apt/lists/
我尝试输入:
alias upgrade='sudo aptitude update && aptitude full-upgrade -y'
但我遇到了同样的错误,并尝试运行:
sudo upgrade
但我遇到了同样的错误。我该如何解决?
如果您需要更多信息,请告诉我。
答案1
您的别名必须包含sudo
两次,分别位于您使用以下命令组合的两个命令的前面&&
:
alias upgrade='sudo aptitude update && sudo aptitude full-upgrade -y'
或者,你可以启动一个子 shell,在sudo
内部运行这两个命令:
alias upgrade='sudo bash -c "aptitude update && aptitude full-upgrade -y"'