Results 1 to 6 of 6

Thread: alias for updating all packages

  1. #1
    Join Date
    Nov 2005
    Location
    Chicagoland
    Beans
    110
    Distro
    Ubuntu

    alias for updating all packages

    I created the following alias by hand and it gave me an error:

    alias updater='sudo apt-get update | apt-get upgrade | apt-get autoclean | apt-get autoremove'

    Error:
    E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
    E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?
    E: Could not open lock file /var/cache/apt/archives/lock - open (13: Permission denied)
    E: Unable to lock the download directory
    E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
    E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?
    [sudo] password:

    Entering my password does nothing.

    How can I make this work?
    Thanks

  2. #2
    Join Date
    Sep 2009
    Location
    Freiburg/Germany
    Beans
    1,112
    Distro
    Ubuntu 12.10 Quantal Quetzal

    Re: alias for updating all packages

    This runs sudo apt-get update feeds its output into apt-get upgrade (without sudo).

    Use
    Code:
     sudo sh -c 'apt-get update; apt-get upgrade; apt-get autoclean; apt-get  autoremove'
    ClassicMenu Indicator - classic GNOME menu for Unity
    Unsettings - configuration program for the Unity
    Privacy Indicator - easily switch privacy settings in Unity
    Arronax - create and modify app starters

  3. #3
    Join Date
    Apr 2007
    Location
    (X,Y,Z) = (0,0,0)
    Beans
    3,715

    Re: alias for updating all packages

    Quote Originally Posted by diesch View Post
    This runs sudo apt-get update feeds its output into apt-get upgrade (without sudo).

    Use
    Code:
     sudo sh -c 'apt-get update; apt-get upgrade; apt-get autoclean; apt-get  autoremove'
    I would avoid placing the sudo in the alias definition. Following Python's philosophy, explicit is better than implicit... specially with regards to sudo and other similar root-privileges granting programs. That way you'll always know when you're root and when not; no, you may sometimes forget that works using sudo.

    It's just about being aware what one does with one's own computer.

  4. #4
    Join Date
    Sep 2009
    Location
    Freiburg/Germany
    Beans
    1,112
    Distro
    Ubuntu 12.10 Quantal Quetzal

    Re: alias for updating all packages

    For me an alias is just a shortcut to avoid typing the same things over and over again. As sudo asks for the password in any case I don't see a problem here.
    ClassicMenu Indicator - classic GNOME menu for Unity
    Unsettings - configuration program for the Unity
    Privacy Indicator - easily switch privacy settings in Unity
    Arronax - create and modify app starters

  5. #5
    Join Date
    Apr 2007
    Location
    (X,Y,Z) = (0,0,0)
    Beans
    3,715

    Re: alias for updating all packages

    Quote Originally Posted by diesch View Post
    As sudo asks for the password in any case I don't see a problem here.
    No, it doesn't if the timeout is set and you didn't do sudo -k. But well, it's not going to be a super security risk either.

  6. #6
    Join Date
    May 2008
    Location
    UK
    Beans
    1,451
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: alias for updating all packages

    Quote Originally Posted by cajunlibra View Post
    I created the following alias by hand and it gave me an error:

    alias updater='sudo apt-get update | apt-get upgrade | apt-get autoclean | apt-get autoremove'

    Error:
    E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
    E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?
    E: Could not open lock file /var/cache/apt/archives/lock - open (13: Permission denied)
    E: Unable to lock the download directory
    E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
    E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?
    [sudo] password:

    Entering my password does nothing.

    How can I make this work?
    Thanks
    The reason it did not work initially is that you used the "|" pipe - which runs each command as a seperate process and streams the output of one process into the input of the next - and since all those apt-get's run at the same time under your command, each one tries to lock the file - and only the first one that starts up is able to lock it - and the rest generate an error. To get this working you should use the ";" (semicolon) as diesch suggested - this will run each command when the previous one completes - which i am fairly sure that is what you intended.
    Tony - Happy to try to help.
    Unless otherwise stated - all code posted by me is untested. Remember to Mark the Thread as Solved.
    Ubuntu user number # 24044 Projects : TimeWarp - on the fly Backups

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •