purge-old-kernels deprecated

Bret Busby bret at busby.net
Sat Jan 7 18:09:26 UTC 2023


On 07/01/2023 17:51, Bo Berglund wrote:
> On Thu, 05 Jan 2023 19:54:21 +0100, Ralf Mardorf via ubuntu-users
> <ubuntu-users at lists.ubuntu.com> wrote:
> 
>> On Fri, 2023-01-06 at 02:09 +0800, Bret Busby wrote:
>>> apt update
>>> apt full upgrade -y
>>> apt autoremove
>>> apt autoclean
>>
>> My update script runs
>>
>>             sudo apt update $quiet$color && \
>>             sudo apt-file update && \
>>             sudo auto-apt updatedb && \
>>             sudo auto-apt update-local && \
>>             sudo apt full-upgrade $keepp$color && \
>>             sudo apt autoremove $color;;
>>         esac
>>         printf "\nsudo mv -i /var/cache/apt/archives/* /root/tmp_trash/\n"
>>         sudo mv -i /var/cache/apt/archives/* /root/tmp_trash/
>>
>> that is more or less the same as you run, with one big exception. The
>> content of the variables $keepp, $color is unimportant, since the
>> content is at least not "-y".
>>
> 
> I don't understand the above commands fully, for example the esac and color
> parts. Should esac not be preceded by case somewhere?
> 
> But want to put the process into a script so it can be executed simply by
> calling the script with sudo.
> 
> After seeing the Bret Busby post I started writing this, will that work or do I
> have to handle other stuff as well:
> 
> ----
> #!/bin/bash
> # This script will do a full system update-upgrade-clean process
> # It must be called using sudo with argument Y
> 
> if [ "$1" != "Y" ]; then
>    echo "Error! Call syntax: sudo $0 Y"
>    echo "Try again!"
>    exit -1
> fi
> 
> apt update
> if [ $? != "0" ]; then
>    echo "Unable to run apt update command! Exiting..."
>    exit 1
> fi
> 
> apt full-upgrade -y
> if [ $? != "0" ]; then
>    echo "Unable to run apt full-upgrade -y command! Exiting..."
>    exit 2
> fi
> 
> apt autoremove
> if [ $? != "0" ]; then
>    echo "Unable to run apt autoremove command! Exiting..."
>    exit 3
> fi
> 
> apt autoclean
> if [ $? != "0" ]; then
>    echo "Unable to run apt autoclean command! Exiting..."
>    exit 4
> fi
> 
> echo "System updated/upgraded successfully"
> exit 0
> ----
> 
> Grateful for comments!
> 
> 
I think that a simpler way, is to do the following.

Run the combined command

sudo apt update && sudo apt full-upgrade -y && sudo apt autoremove -y && 
sudo apt autoclean

and then, when you want to run it again (providing that you do not apply
clear history
), simply, at the command line, use the up arrow (keep pressing it) to 
step backward through the command history, until that combination 
command is found, then, apply it.

That works for me (in Ubuntu, but, not in Linux Mint, which seems to not 
like the combined command).

..
Bret Busby
Armadale
West Australia
(UTC+0800)
..............




More information about the ubuntu-users mailing list