Today I created a new alias in ~/.bash_aliases:

alias upgrade='aptitude update && aptitude full-upgrade -y'

but when I run upgrade, it shows:

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

I tried putting:

alias upgrade='sudo aptitude update && aptitude full-upgrade -y'

but I have the same error, and I try running:

sudo upgrade

but I have the same error. How can I solve this?

If you need more information, tell me.


Your alias must contain sudo twice, one inn front of each of the two commands you combined using &&:

alias upgrade='sudo aptitude update && sudo aptitude full-upgrade -y'

Alternatively you could start a subshell with sudo which runs both commands internally:

alias upgrade='sudo bash -c "aptitude update && aptitude full-upgrade -y"'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.