Upgrading Debian and derivatives with a single command [Script]

Well you see I decided to do this because I had to use the eraser that I had in my tray rotting so I share a script that is not a big deal only has 2 lines and will ask for the root password or the sudoers.

SCRIPT: update

#! / bin / bash sudo aptitude update sudo aptitude full-upgrade

And voila, they are not going to be overwhelmed with so many lines of complicated programming (Sarcasm).

Once we save it, it gives it execution permissions, we enter as root to our file browser, copy and paste the script so that they have something like this:

Now we close, open a terminal and write 'update' (obviously without the quotes)

As you will see in the Following Image, the Repositories have been Updated:

We wrote Y to accept what will be installed and / or updated and hopefully the updates are downloaded and installed and the terminal looks like this:

And now you have Updated your system with a single command.


Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   and Xe said

    Where's the script?

    1.    merlin the debianite said

      It is located after the first 3 lines of the post.

      1.    and Xe said

        Well, I really don't understand this post.

  2.   Hugo said

    It keeps me curious that some users prefer to complicate with scripts and permissions when they can solve the problem with a simple alias. In fact, this post is very similar to one that has just been published on "simplifying commands", and for which, by the way, I put a comment with an alias that is even more complete than the one published in this post itself. . Anyway, wanting to contribute to the community is noble, but when the posts are so similar it doesn't seem to help.

    1.    Atheyus said

      When I was a Debianite I "complicated" with this:

      http://paste.desdelinux.net/4680

      The aliases are for pipes and ands ~ _ ~, but that's what GNU / Linux makes me like the many ways of doing things, you just have to take into account the permissions of the files.

  3.   verbellon said

    I understand that not all of us are good at managing an OS (either windows, GNU / Linux, etc), but at least, you have to learn a little about them (the one you use).
    As Hugo said, "Update Debian and derivatives with a single command [Script]" and "Simplify commands", at least for me, do not make sense, if this is solved by editing the .bashrc and adding:

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

    Greetings…..

    PS: You have to overwhelm yourself with code, when you really need it.

    1.    merlin the debianite said

      I admit you're right, but at least for me doing the script or aliasing it is just as easy.

      1.    msx said

        This is where the difference between the one who does things right and the one who does wrong comes into play.
        If you are just starting out and you still did not know the ALIAS command, welcome to GNU / Linux and enjoy your (dirty) hack.

        In your case it is different: you prove to be totally ignorant and negligent by misusing the standards of use of a GNU / Linux system. In your case the further away from the console, the better.

    2.    merlin the debianite said

      Have a try:
      because "alias update = 'sudo aptitude -y update && sudo aptitude -y safe-upgrade'"
      It didn't work for me and in theory it should work.

      And if you remove the script with the same name and even try another alias.

      1.    Hugo said

        If concatenating two commands in one line does not work, it is because something is broken in your system, because conditional execution is standard bash functionality.

        Could it be that on your PC you are combining packages from different Debian and / or derived versions? If I were you, I would reinstall bash or even the entire system just because of that symptom you describe, because I could no longer trust that the system will behave in a stable way.

        1.    merlin the debianite said

          the truth is that I do have a couple of repos for launchpad and linuxmint but I don't think it's severe enough to reinstall the entire system.

          1.    Hugo said

            That clears things up a bit. Clearly, we have different criteria as to the importance of the stability of a system. 😉

            After all, it is your system; you have every right to use it like that, although frankly mixing Debian with Ubuntu and Linux Mint repos… well, for a true Debianite that's like sacrilege. What's more, many Debianites frown on even using apt-pinning.

            In my opinion, to have that repository promiscuity, you'd be better off using something with Debian Cut, Sid, some derivative of Sid, or maybe something else like Ubuntu, Fedora, Arch, LFS, etc.

  4.   Christopher said

    It can be much easier to put everything on one line

    sudo aptitude update && sudo aptitude dist-upgrade

    1.    merlin the debianite said

      the truth is a one-time process and now I just have to type "update" to do it and not every line you just put.

  5.   Alf said

    Well, there is something I don't understand, since Desde linux is
    About Us

    What is <° Linux?
    <° Linux (aka DesdeLinux) is a site dedicated to topics related to Free Software and Technologies. Our objective is none other than to provide all those users who are starting out in the world of GNU/Linux, a place where they can acquire new knowledge in the easiest way possible.

    Our interests:
    Share and acquire knowledge with anyone.
    Debate on any topic, as long as it is related to GNU / Linux, Software and Free Technologies.
    Create a community space for Help and Support.
    Form a Community of Users with whom to share experiences.

    So why every time someone shares something, does the criticism jump?

    1.    Hugo said

      It's probably because most Linux users like efficient solutions, and if they see something that they think can be improved, they say so. So far and from what I know the creators of this blog, they try to respect the criteria of all users; In other words, someone has as much right to publish an article as other users to comment on it.

      Let's see, criticism is not necessarily a bad thing, since it can enrich articles a lot, if they are done in a constructive way. Obviously, destructive reviews (that is, those devoid of argument, false or offensive) are harmful, but so far I don't remember seeing many criticisms of that type around here.

      1.    msx said

        I think what can bother us the most is the total disregard for the correct use of the system made by the author of the post and also boasting about his action:

        "I admit you're right, but at least for me making the script or aliasing it is just as easy."

        If you know that you are doing something wrong when you have the possibility to do it right, at no extra cost - it's more, with added benefits - but you insist on doing it wrong, it is that:
        1. You are a rebellious little boy without a cause.
        2. you are an idiot.

        There are not many more issues, I only put in written words what any user thinks who tries to learn the best GNU / Linux practices and use it in the most efficient way.

        To create "ugly hacks" it is necessary to demonstrate competence before you are simply dirty.

        1.    merlin the debianite said

          hmm maybe it's number 2 because I didn't get the point.

          XD

        2.    merlin the debianite said

          You cannot alias 2 commands, the closest thing was what I already had in my alias, which would be update && upgrade to do what the update script does. I don't see where the problem is yet. Or am I too lazy to write update && upgrade.

          by the way my aliases that I already had before doing article.

          alias rm = 'rm -i'
          alias cp = 'cp -i'
          alias mv = 'mv -i'
          alias upgrade = 'aptitude full-upgrade'
          alias update = 'aptitude update'
          alias install = 'aptitude install'
          alias remove = 'aptitude remove'
          alias clean = 'aptitude clean'

        3.    msx said

          These are my aliases for the Ubuntu Server 12.04 LTS home server:

          $ cat ~ / .bash_aliases
          ...

          ################################
          # Ubuntu / Debian specific aliases
          # ———————————-

          alias UpdateSystem = 'sudo aptitude update && sudo aptitude safe-upgrade && sudo aptitude full-upgrade'
          alias Remove = 'sudo aptitude purge'
          alias SearchLocal = 'dpkg -l | grep -i'
          alias Search = 'aptitude search'
          alias Install = 'sudo aptitude install'
          alias Show = 'aptitude show'
          alias Clean = 'bleachbit && gksudo bleachbit && sudo apt-get autoremove && sudo apt-get autoclean && sudo deborphan | xargs sudo apt-get -y remove –purge && sudo aptitude clean && sudo aptitude autoclean && sudo deborphan | xargs sudo apt-get -y remove –purge '
          alias Cleancli = 'bleachbit -d deepscan.tmp system.desktop_entry system.localizations system.rotated_logs system.tmp && sudo bleachbit -d deepscan.tmp system.desktop_entry system.localizations system.rotated_logs system.tmp && sudo apt-get autoremove && sudo apt-get autoclean && sudo deborphan | xargs sudo apt-get -yr \
          emove –purge && sudo aptitude clean && sudo aptitude autoclean && sudo deborphan | xargs sudo apt-get -y remove –purge '

          1.    merlin the debianite said

            If I put more than 2 commands, they don't work for me :(, or in Ubuntu if they work? (It can't be the same file that is modified, right?).

          2.    msx said

            Just as we are all hargans, especially system administrators and programmers, we make use, abuse and re-abuse of aliases and hacks to have to press as few keys as possible; the ideal of every admin or coder is to get to the point of having a one-letter alias that updates the system and cleans the house (cook, I cook).
            Seriously, the point here is to automate redundant tasks in the most efficient, practical and comfortable way.

            My alias policy is as follows:
            1 as I have * many * aliases that I share in the same ~ / .bash_aliases across different systems, I almost always start my aliases with a capital letter, which also prevents me from eventually _stepping_ on some system-specific command.
            2. For the amount of aliases I use, a good alias should not make me press more than 4 keys, 5 with the key generally being the 4th key the TAB key.
            In this way it is enough for me to write the first two or three letters of the alias -> TAB -> ENTER.
            3. having well-defined aliases you can structure complex commands or automate complex tasks.
            $ Up [TAB] && Cleanc [TAB]
            or
            # UpdateSystem && Cleancli
            Update and clean the system. As I always have an instance of tmux running, I undock the terminal, disconnect the ssh session and let the server work on its own.

            Finally, keep in mind that alias commands cannot be nested, that is, you cannot use an alias within another alias.
            At some point I had an UpdateFull alias defined that would update the system and then activate the cleaners but I stopped using it because updating and cleaning the systems is not a trivial task -even though developers make our lives much easier- and I prefer to have more control fine about these actions.

          3.    Hugo said

            Some of those aliases are very interesting, hehe. Look at this one I just prepared playing with regular expressions, to solve a little problem with saved web pages desde Linux to a flash, which cannot then be opened from Windows due to having strange characters:

            alias fixnames='sudo find . -depth -regextype posix-extended -regex '\''.*(\s+|:+|\\+|>+|+|<+|"+|\*+|\?+|\|+)/_/g'\'' "{}" \;'

            By the way, forgive me to comment from Windows, is that I deleted my Linux partition to make room for some games juegos

          4.    Hugo said

            Well, excuse me, but in the first place I responded to msx (which was not very clear due to the limit of comment nesting levels), and secondly, apparently the blog ate part of my alias (it seems that you do not like them much regex), so I put it in the paste: http://paste.desdelinux.net/4685

      2.    msx said

        Excellent alias @Hugo!
        I fell in love with regular expressions when I discovered Perl (together they are unbeatable!), Too bad they are so cryptic that 20 minutes after creating them and checking that they work, I forgot what they did and I have to start unraveling them step by step! xD

        There I copy the ER that you pasted to test it, if you have more that useful, welcome to a post with all of them 😉

    2.    verbellon said

      Perhaps this script or what they did in the / bin directory seems correct to you (check the topic Simplifying commands).

      It is a constructive criticism, which highlights this error, so that future GNU / Linux users do not stumble upon such stupidity (without reference to any person).

      For this case, the correct thing is to edit the .bashrc and introduce the lines that you think are convenient.

      Greetings…..

      1.    msx said

        ~ / .bash_aliases

        1.    Hugo said

          Apparently not all distributions provide this file (something that has not stopped catching my attention). In such a case it could be easily fixed by putting something like this in the .bashrc

          if [ ! -f ~/.bash_aliases ] ; then
          {
          echo "HISTIZE=5000"
          echo "HISTCONTROL=ignoreboth"
          } > ~/.bash_aliases
          fi
          if [ -f ~/.bash_aliases ] ; then
          source ~/.bash_aliases
          fi

          1.    Hugo said

            Sorry, it's HISTSIZE. By the way, histsize is to define the number of commands to keep in the history, and HISTCONTROL = ignoreboth is so that repeated commands and those that start with a space are not saved in the history. I have found that both are very useful, together with HISTIGNORE, an option that I also put in my .bash_aliases

        2.    verbellon said

          Well, if I take Debian as an example, you will see that there is only the .bashrc, but if you are a little curious and read the lines, you will see a section:
          (a) # some more ls aliases, and
          (b) # Alias ​​definitions. You may want to put all your additions into a separate file like ~ / .bash_aliases, instead of adding them here directly. See / usr / share / doc / bash-doc / examples in the bash-doc package.

          if [-f ~ / .bash_aliases]; then
          . ~ / .bash_aliases
          fi

          And of course for that, $ vim ~ / .bash_aliases (because you have to create it). Enter, alias XX = 'XXXXXX', save and exit the file.

          Now with ArchLinux, it turns out that your .bashrc is practically empty. And if .bashrc fulfills that function (the alias one), I don't see the need to create the .bash_aliases. But you have to have it sorted.

          Greetings…..

          1.    verbellon said

            PS: Take into account that my aliases are not so special in a task.

            Greetings MSX, Hugo.

          2.    msx said

            Hi @Berbellon,
            Personally, I would like Arch's ~ / .bashrc to come more robust, that is, with various settings of environment variables that we use on a daily basis, because no matter how much one is continually learning about GNU / Linux and trying to illuminate the darkest corners there are always some turtle that escapes us (that yes, that comes with many examples of system variables but everything absolutely commented).
            Now, Arch's almost stripped ~ / .bashrc is understandable since the distro is intended for developers, scientists, sysadmins and anyone who wants to configure it in their own way, to their liking and personal use by learning about the system and reading about how to configure it - not in vain Arch is -if I am not mistaken- together with Slack one of the purest distros of GNU / Linux in that each package that is part of the system is touched as little as possible, for example the apache web server called httpd (actual name of the application) and installs in / etc / httpd in contrast to Debian which calls it apache and installs it in / etc / apache2 with a somewhat… personal file configuration.

            «And if .bashrc fulfills that function (the alias one), I don't see the need to create the .bash_aliases. But you have to keep it organized. "
            Actually ~ / .bashrc does not fulfill that function since Arch Linux seeks to encourage good practices in the use of the system, so it is expressly recommended to use ~ / .bash_aliases to save aliases.
            However, this distinction for the definition of aliases - ~ / .bashrc vs ~ / .bash_aliases- is purely administrative and is provided so that the system administrator can organize in a modular and clean way his system since the ~ file can be used well. /.bashrc to define all the aliases we use.

      2.    merlin the debianite said

        True, but sometimes you have some commands in the alias and that sometimes you need to do them separately and other times together and as they already told me above, you cannot alias a command that you already have even if it is nested in another, and by the way I do not have the broken system and I only have a jdownloader launchpad and the linuxmint debian edition one I removed it because it seemed reductive to me.

  6.   patz said

    is seriously? and this is a script that updates the system and reboots in one step
    #! / Bin / bash
    sudo aptitude update
    sudo aptitude full-upgrade
    sudo reboot

    normally the things that are done constantly are the ones that deserve to be scripted, a full upgrade is not constant, much less in debian….

    1.    merlin the debianite said

      I usually do it often. : p

      1.    msx said

        You should try Semplice (wonderfully stable and beautiful Debian Sid with Openbox + tint2), aptosid / Sidduction (Debian Sid almost stable and very bloated), Arch (best RR distro ever), Gentoo / Sabayon or any other RR distro.
        If you use debian I would give Semplice a try, it is more modern than Crunchbang (Debian Stable) and it works excellent.

        1.    merlin the debianite said

          I'm going to see how and if it convinces me I can install it to the new laptop.

          1.    msx said

            And a new post? 😉

      2.    patz said

        How often does a new version of debian appear?

        1.    merlin the debianite said

          Every 2 years approx. If you use stable in testing, it could be said that it is Rolling Release, that is, it is updated online almost daily and you don't need to reinstall the system again.

  7.   merlin the debianite said

    Hmm is likely. I guess pretending to be an idiot a second time isn't that bad.

    XD

    1.    msx said

      Uhh, go ahead, where is that champion leather !!! xD
      Let it slip you, old woman!

  8.   scraf23 said

    As a sysadmin I only script for repetitive and arduous tasks, this doesn't seem like the case xD

  9.   microzone said

    Well, call me weird but using aliases for commands that you use often is fine, but for something that is done once a year? (I use ubuntu lts I mean more) does not make sense.

    In addition to both using the alias and changing someone else's machine, I can see it pulling the -h 🙂

    1.    microzone said

      I forgot to put it but I think the same about the script