🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.os.linux.mint
Article #94

Re: had my first major LM issue today :(

#94
From: Paul
Date: Sun, 18 Oct 2026 07:27
158 lines
7379 bytes
On Sun, 10/18/2026 1:20 AM, Axel wrote:
> Alan K. wrote:
>> On 10/17/26 2:27 PM, George wrote:
>>> On 17/10/2026 13:04, Axel wrote:
>>>>
>>>> One of the PC's running 21.3 failed to boot after the latest update
>>>> manager software install. I tried dropping back to an older kernal,
>>>> then recovery mode, but no joy, so I did a timeshift which worked.
>>>> however, Update Manager now shows three packages that won't install
>>>> and remain there... https://auslink.info/linux/updates.png ...so I
>>>> clicked 'refresh' and I got this...
>>>> https://auslink.info/linux/refreshed.png ...can I safely ignore them,
>>>> or remove them somehow, or are they necessary? also, the timeshift
>>>> file was 10 days old so I expected lots of updates, but only those
>>>> three are there. ??
>>>>
>>>
>>>
>>> Every month, I run the following commands in the Terminal:
>>>
>>> sudo apt-get update
>>> sudo apt-get upgrade
>>> sudo apt autoremove
>>> sudo apt purge --autoremove
>>> sudo apt autoclean
>>> sudo apt clean
>>>
>>> This ensures that the system is updated and that old, useless files are
>>> removed. It's all manual work, but it only takes five minutes!
>>>
>>>
>> You could just copy and paste that into a batch file and it's one click.
>> Not a lot of manual work then.
>>
> 
> what would be the code for that?
> 

When you write your first bash script "autoclean.sh" it might look like this.
The first line identifies the shell which will be interpreting the code.

#!/bin/bash
# A simple script
sudo apt-get update
sudo apt-get upgrade
sudo apt autoremove
sudo apt purge --autoremove
sudo apt autoclean
sudo apt clean

To determine what shells are available, you can do this.
The /bin/sh is the Bourne Shell, but most of the time
this is aliased to the Bourne Again Shell (bash), so there
aren't actually two shells there, just the one shell, and the
/bin/sh line exists for "backward compatibility".

$ cat /etc/shells
# /etc/shells: valid login shells
/bin/sh
/bin/bash
/usr/bin/bash
/bin/rbash
/usr/bin/rbash
/bin/dash
/usr/bin/dash
/usr/bin/tmux
/usr/bin/screen

When writing any programmable materials, you include error
handlers, because you have to "expect the unexpected". Each
command returns a $status or so, which can be conditionally checked.
With the sequence above, you don't actually want to drop through
all those, neither would you want those to "execute in parallel".
This captures the return code from the "date" command, before
the execution of any other command stomps on that return code.

#! /bin/bash
date
status=$?
echo "The date command exit status : ${status}"

# Conditional check that some arg list is present, includes exiting with a "status code"
# That's in case some other script.sh calls your date.sh script. The conditional
# logic execution, the second clause does not execute if the first one fails.
# Even if you don't *write* code like this, you still have to be able to *read* it.

files="$@"
[[ "$_files" == "" ]] && { echo "Usage: $0 file1.png file2.png"; exit 1; }

If you do this in a shell

ls &
ls &

then there will be at least two copies of listdir running
at the same time. If you want them to run sequentially and
one not proceeding until the one before it is finished, then
you don't include the & to cause them to be forked.

Not everyone will agree, but generally speaking, you want a
thin book from the computer store, on each individual shell.
There was the "Sea Shell Book" for the csh shell. To get a Bourne book (/bin/sh)
I had to accept a single chapter in a book that had more topics in it.
Like any programming language, you get the best results when you know
what all the commands do :-)

This is not to dissuade you from trying stuff. And this does not
even constitute a "primer". I don't remember enough to write a primer.

The /bin/bash line can include parameters like -e after it.
There are some global properties you can assign, like echoing
the execution of the lines so you know where the script is
right now.

If you look around, you can find articles for people new to the topic.
But this still isn't nearly enough, as it has not addressed "defensive programming"
and the things you should be doing in a script.

  https://www.linuxfoundation.org/blog/blog/classic-sysadmin-writing-a-simple-bash-script

The above script, one without any error status checks, you can do that if you
don't really care about what happens. For example

#!/bin/bash
# A simple script
# We specify absolute paths for executable, if "we don't want surprises" :-)
/bin/ls a*
/bin/ls b*
/bin/ls c*
exit(0)

That script has very little in the way of "side effects".
If the directory doesn't exist, if the files aren't there,
nobody is harmed, the wheels do not fall of the computer.

On the other hand, if the second command critically depends
on the first command completing, then you had better check for that.
That the first command completed.

Even efforts like this are not enough, as there isn't enough
reinforcement here.

  https://indico.cism.ucl.ac.be/event/149/contributions/162/attachments/242/516/Bash-1.pdf

When I was at work, one day some commercial UNIX software showed up.
There was a 2000 line Bourne shell script which was their installer.
I didn't get too curious at first, as getting the thing installed
was the priority. But a few hours later, I started looking at that
file, and that was the single best .sh I'd ever seen. A real pro wrote
it. Nicely structured. Good reuse of subroutines. Usage of all
the features the shell had, *without* resorting to thousand character
"sed magic" to hide what they were doing :-) I made multiple references
to that, when I had to write something, as there was bound to be
a similar programming pattern in that file. If you couldn't get a
book, that's the kind of material you'd want to acquire. I regret
not bringing a copy of that script home :-)

   Paul
Technical Details
Message-ID: <11b1scn$u8ih$1@dont-email.me>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
References: <njh6i1F919dU3@mid.individual.net> <11b0evm$3irg5$1@paganini.bofh.team> <11b0fsu$glis$1@dont-email.me> <njj38pFk99eU1@mid.individual.net>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
From: Paul <nospam@needed.invalid>
Newsgroups: alt.os.linux.mint
Subject: Re: had my first major LM issue today :(
Date: Sun, 18 Oct 2026 03:27:17 -0400
Organization: A noiseless patient Spider
Lines: 158
Message-ID: <11b1scn$u8ih$1@dont-email.me>
References: <njh6i1F919dU3@mid.individual.net>
 <11b0evm$3irg5$1@paganini.bofh.team> <11b0fsu$glis$1@dont-email.me>
 <njj38pFk99eU1@mid.individual.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 18 Oct 2026 07:27:20 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="991825"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1/qrhMfWewVXvqL6bjzldZX39ufYYaUJMU="; posting-host="79f2a202ed5163891b428884d93edc5f"
User-Agent: THIS SPACE FOR RENT
Cancel-Lock: sha1:IS3cWbzKOsBq/qskEXr2A63Glys= sha256:U2jIT9D12C86G2FThLbU8eMwlZrjWRG3TcPlmQtxLBs=
	sha1:Aie+tNMvrfLYjLWW+hMvHUejR00= sha256:rTj2hvEudP5CivRftCSWcHf5/nM6iV4AVa0EDY7irVI=
Content-Language: en-US
In-Reply-To: <njj38pFk99eU1@mid.individual.net>