-1

I have added this to .bashrc

alias a='ap update && ap dist-upgrade -y && do-release-upgrade -d && ap check && ap autoremove -y && ap autoclean'

So i can run the long command just by entering a

but the command stops after do-release-upgrade -d and when I remove it from the alias and run a again the command works.

alias ap='apt-get'
user289256
  • 531
  • 1
  • 4
  • 4

2 Answers2

2

Where to start?

  • ap isn't a command. You want apt-get.. If ap is an alias —sigh— see my final point.

  • Do you understand what do-release-upgrade -d does? It's the tool used for upgrading Ubuntu to a new release (in this case a development release). It'll only ever work once every 6 months and it will keep you nailed to the nasty, rusty, dripping, bleeding edge that is Ubuntu development. Never use this (especially not regularly) on a computer that you might need at any given point.

  • The direct answer to your question: do-release-upgrade -d will exit code 1 if there is nothing to upgrade to. As above, it'll only ever fire code 0 (success) twice a year. && only continues when the previous command exits code 0 so you either want:

    • ; continue whatever, or more likely,
    • || the opposite of &&, run on fail.
  • More than that, do-release-upgrade is interactive when there is something to upgrade to.

  • The -y flag is dangerous. It can —no, will— ruin your day at least once. This is 100× truer on a development release (which it looks like you're trying to stick to). You should want every opportunity to avoid Apt accidentally removing all your packages.

  • Why an alias? You've sandwiched a hundred commands into one line, why don't you just write a script named a and stick it in ~/bin/ (create it if it doesn't exist then run source ~/.profile to update your $PATH).

  • And why are you doing any of this at all? If you want automatic updates, why don't you just use one of the many existing tools that does this for you? Shazaam, now you don't need a script.

  • And finally, if you're really so bored of typing commands that you're aliasing the entire alphabet, it might be time to learn to hit the tab key with your left little finger when you're typing. It'll auto-complete as far as it can (and works inside a lot of commands too; try it with apt-get).

Oli
  • 293,335
  • (6)what is the advantage of having it a script instead of all aliases in one file? (7) I just start it manually whenever I want to but I could make a cronjob because those tools don't do what's in the alias. (8) entering in just a is much quicker and tab doesn't work in sudo su – user289256 Jun 07 '14 at 12:08
  • A script makes it easier to maintain and easier to call if you're not in your session (sudo ~/bin/a would still work for terminal calls and /home/username/bin/a would work for external calls — like from cron). Or you could stick it in /usr/local/bin, something that should be globally accessible. – Oli Jun 07 '14 at 13:30
1

When you do an release upgrade, many problems can occur : the computer brutally stops, internet access stops, ... It is then possible to have an incomplete upgrade or some problem with dependencies.

  • In case you have dependencies errors, try theses commands :

    sudo dpkg --configure -a

    and then :

    sudo apt-get install -f

  • If your upgrade was interrupted or a major issue occured, you can try this command :

    sudo dpkg-reconfigure -phigh -a

This will reinstall and reconfigure every package needed for the release-upgrade. Please note that this can be very long, up to 1 hour.