Not deprecated

«In Kotlin, loops are deprecated.»  That’s the title picked by Luc-Antoine Girardin. Of course they are not, in fact he starts the article with

Well… That’s not entirely true. It would not make sense to actually deprecate them as loops have been a part of programming for decades…

They reality is that programming language that offers closoures have better ways to solve most of the use cases of loops. Easier to read and understand, hence easier to debug and more robust.

If you know how to use closoures…

How to Run Shell Script as Systemd Service in Linux ?

How to Run Shell Script as Systemd Service in Linux ?

Here, we will make a manual script which will act like a process to find disk utilization of the Linux system.

To begin, Make a bash script that redirects date and disk utilization in a file. You can create files in any location. We are going to make in executable directory /usr/bin:

$ sudo vim /usr/bin/script.sh

Then, Copy and paste the following script and save your file:

#!/bin/bash
# Script generates disk utilization by the system and store in a file
while true
do
date >> /var/storage-monitor.txt
sudo du -sch / >> /var/storage-monitor.txt
sleep 120
done

Next, Make the file executable by running the following command.

$ chmod +x /usr/bin/script.sh

Now, let’s make a service for running the script. Just create a file in the following directory. Note you can give any name but it must end with .service extension:

$ vim /etc/systemd/system/monitor-disk.service

And add the following details:

[Unit]
Description=My disk monitoring service
Documentation=https://www.kernel.org/
#After=networking.service
[Service]
Type=simple
User=root
Group=root
TimeoutStartSec=0
Restart=on-failure
RestartSec=30s
#ExecStartPre=
ExecStart=/usr/bin/script.sh
SyslogIdentifier=Diskutilization
#ExecStop=
[Install]
WantedBy=multi-user.target

What is going on here is:

  • The [Unit] section consists of description, documentation details. Here we have mentioned ‘After’ which states the service that we are going to create must be running first.
  • [Service] Section defines the service type, username, group, what to do in failure, restart timeout. The main is ‘ExecStart’ which says to start our script file. You can also define ‘ExecStartPre’ to define anything before the actual script file.’SyslogIdentifier’ is the keyword to identify our service in syslog. Similarly, ExecStop is the instruction to say what to do to stop the service.
  • [Install] section is used to define different levels of target in the system.

From https://linuxapt.com/blog/496-run-shell-script-as-systemd-service-in-linux

Linux: logout automatico per inattività

In questa breve guida vi mostro come impostare il logout automatico dalla sessione su sistemi Linux e Unix-like.

Source: [GUIDA] Linux: come effettuare il logout automatico per inattività

Ovviamente dalla shell (linea di comando).

Basta impostare la variable d’ambiente TMOUT. Mai smettere d’imparare.

Ovviamente si può Configurare l’uscita automatica anche dall’interfaccia grafica.

How to get the most out of your Terminal

How to get the most out of your Terminal | by Reagan McFarland | Medium

the recipe is basically three steps:

  1. a “modern” terminal. He suggest Alacritty becuase is fast. Like really fast. This is because it uses OpenGL to offload some of the processing to your GPU, a feature very few terminal emulators have. I’m quite satisfied by Gnome Terminal, thanks.
  2. Then he suggests
    1. Starship is a cross-shell prompt that not only looks great out of the box, but has a tremendous amount of features. Fine, I’ll try it
    2. DistroTube’s Shell Color Scripts
  3. He tells us to use shell configuration files (aka ~/.bashrc or ~/.bash_profile). I discovered them many years ago
  4. SpaceVim, a “Modern Vim distribution”. He says it is optional. It seems great. I’ll surely try it