Outils pour utilisateurs

Outils du site


blog

Notes xonsh - le shell Python

Le shell Python

IPython dans sa partie shell interractive vise le même objectif.

Voir : iPython

  xonfig wizard      # Run the configuration wizard to create ~/.xonshrc
  xonfig tutorial    # Open the xonsh tutorial in the browser


    # XONSH WIZARD START
    source-foreign  "echo loading xonsh foreign shell"
    xontrib load coreutils
    # XONSH WIZARD END
2025/03/31 11:19 · Jean-Baptiste

Notes Podman

Voir aussi :

  • Apptainer/Singularity

Voir :

Rootless : https://github.com/containers/podman/blob/main/docs/tutorials/rootless_tutorial.md

Volumes / Stockage / Storage :

Installez slirp4netns (va être remplacé par pasta à partir de Podman 5)

apt-get install slirp4netns

Ensuite, configurez une quantité d'espaces de noms réseau définis par l'utilisateur :

echo "user.max_user_namespaces=28633" > /etc/sysctl.d/userns.conf
sysctl -p /etc/sysctl.d/userns.conf

Cette commande permet d'utiliser les espaces de noms réseau sans être root.

Démarrage automatique

systemctl --user enable --now podman-restart

Conf registry

/etc/containers/registries.conf

[registries.search]
registries = ['docker.io', 'quay.io', 'ghcr.io']
 
[registries.insecure]
registries = []

Exemple

podman build -t jibe/dokuwiki --build-arg http_proxy="$http_proxy" --build-arg https_proxy="$https_proxy" -f Containerfile .
 
podman run -a stdout --rm --name=dokuwiki1 -v $PWD/tmp/dokuwiki/data/:/var/www/wiki/www/data -v $PWD/tmp/dokuwiki/conf/:/var/www/wiki/www/conf -m 512m -p 8082:8080 jibe/dokuwiki

Contener - entrypoint

$ podman run --entrypoint /usr/bin/echo -ti --rm debian -e 'Test1\nTest2'
Test1
Test2
#podman generate systemd --restart-policy=always -t 1 dokuwiki1
#podman generate systemd --restart=always -t 1 dokuwiki1
 
# podman generate systemd --new --files --name httpd
# quadlet ?

Autre

echo 1 > /proc/sys/kernel/unprivileged_userns_clone

Conf UIDMAP

Voir /proc/sys/user/max_user_namespaces

Colonne Description
1 Nom de l'utilisateur système sur le hôte
2 Numéro d'UID sur le hôte correspondant à l'UID 0 du NS
3 Plage; notre d'UID à l'intérieur du NS
sudo usermod --add-subuids 10000-75535 USERNAME
sudo usermod --add-subgids 10000-75535 USERNAME

/etc/subuid

jean:100000:65536
test:165536:65536
plop:231072:65536
k8s:296608:65536

/etc/subgid

jean:100000:65536
test:165536:65536
plop:231072:65536
k8s:296608:65536

Commandes utiles

Afficher tous les mappages de ports de conteneur utilisés

podman port -a

Pour un container particulier

podman port ctn-app1

Réseau

Podman prend en charge 2 réseaux backend pour les conteneurs : Netavark et CNI.

Pour vérifier quel backend réseau est utilisé :

$ podman info --format {{.Host.NetworkBackend}}
netavark

Pour modifier le backend réseau, définissez la configuration dans /usr/share/containers/containers.conf :

[network]
[...]
# Network backend determines what network driver will be used to set up and tear down container networks.
# Valid values are "cni" and "netavark".
network_backend = "netavark"

La commande podman network create créer un réseau compatible DNS.

Création d’un réseau appelé db_network en spécifiant le sous-réseau 10.87.0.0/24 et la passerelle 10.87.0.1 :

podman network create --gateway 10.87.0.1 --subnet 10.87.0.0/24 db_network

La commande podman network inspect affiche les informations sur un réseau spécifique

La commande podman run --network permet d’ajouter le réseau DNS db_network à un nouveau conteneur

Re appliquer les règles réseau Podman

podman network reload 

Avant cette commande il faillait faire un restart des containers.

A common problem is that reloading the firewall deletes the netavark iptables rules resulting in a loss of network connectivity for rootful containers.

2025/03/28 21:22 · Jean-Baptiste

Ultra fast reboot

Technique pas recommandé

Voir

Source article complet :

echo 1 > /proc/sys/kernel/sysrq 
echo b > /proc/sysrq-trigger

Ultra fast shutdown

echo 1 > /proc/sys/kernel/sysrq 
echo o > /proc/sysrq-trigger

Autres

last | head
root     pts/0        192.168.3.81    Thu May 11 09:19   still logged in
reboot   system boot  3.10.0-327.el7.x Thu May 11 09:17 - 09:24  (00:07)
process  pts/0        192.168.3.81    Wed May 10 16:42 - down   (00:00)
root     pts/0        192.168.3.81    Wed May 10 16:34 - 16:42  (00:07)
reboot   system boot  3.10.0-327.el7.x Wed May 10 16:31 - 16:42  (00:10)
process  pts/0        192.168.3.81    Wed May 10 16:30 - 16:30  (00:00)
root     pts/0        192.168.3.81    Wed May 10 16:28 - 16:29  (00:01)
reboot   system boot  3.10.0-327.el7.x Wed May 10 16:27 - 16:42  (00:15)
root     pts/0        192.168.3.81    Wed May 10 16:19 - crash  (00:08)
reboot   system boot  3.10.0-327.el7.x Wed May 10 16:15 - 16:42  (00:26)
last -x shutdown
shutdown system down  3.10.0-327.el7.x Wed May 10 16:42 - 09:17  (16:34)
shutdown system down  3.10.0-327.el7.x Fri May  5 18:17 - 09:04 (3+14:46)
shutdown system down  3.10.0-327.el7.x Wed Apr  5 16:09 - 15:07 (29+22:58)
systemctl mask sleep.target suspend.target
uptime
ps -p 1 -o stime
lastb
chmod +s /sbin/halt
chmod +s /sbin/reboot

Autres

exec /sbin/init
2025/03/24 15:06

ulimit

Voir aussi :

  • prlimit

Depuis Redhat 6 nous avons :

/etc/security/limits.d/90-nproc.conf

# Default limit for number of user's processes to prevent
# accidental fork bombs.
# See rhbz #432903 for reasoning.
*          soft    nproc     1024
root       soft    nproc     unlimited
www-data   soft    nproc     unlimited

Options ulimit :

  • -H : Hard
  • -S : Soft
  • -a : All
  • -u : Nombre maximal de processus utilisateurs
ulimit -a -H
ulimit -a -S
help ulimit

Voir http://fr.wikipedia.org/wiki/Fork_bomb

:(){ :|:& };:

En cas de dépassement : comment le sait-on ?

Grsecurity propose un audit des dépassements des “ulimit”

Message d'erreur ?

Pourquoi ne pas utiliser les cgroups ?

Core dump

Désactiver les cores dumps (Redhat)

/etc/profile

# No core files by default
ulimit -S -c 0 > /dev/null 2>&1

Activer les cores dumps (Redhat)

su -
ulimit -c unlimited

Notes

/bin/bash -c ulimit -S -c 0 >/dev/null 2>&1 ; /usr/local/bin/plop
Temps réel

However, for systems with a Linux kernel 2.6.13 or newer, it is possible to allow processes without root privileges to set the real-time scheduling policy. When the Linux PAM module is installed (which is normally the case) you can control the maximum real-time priority for non-privileged processes on a per user or group basis via the /etc/security/limits.conf file.

For example, adding the line

   *      -      rtprio      99

Outils

Appliquez les modifications directement à un processus en cours d'exécution avec prlimit

Python

import resource
 
print(resource.getrlimit(resource.RLIMIT_NOFILE)[1])
2025/03/24 15:06

Ubuntu LTS - Quelques optimisations pour les anciens PC

Ubuntu light / allégé

Voir aussi - Distribution GNU/Linux légères basées sur Debian :

Voir aussi - Distribution GNU/Linux légères basées sur Ubuntu :

  • Trisquel Mini
  • lunbuntu

Description: Notes installation Ubuntu

Lors d'une nouvelle install, il faut d'assurer de bien aligner les partions Voir formater_une_carte_microsd_en_optimisant_les_performances_et_la_duree_de_vie

Voir :

# Services activé :
systemctl list-unit-files | grep enabled
 
# Services démarrés :
systemctl | grep running

CPU - grub Kernel param

/etc/default/grub

mitigations=off

Optimisation mémoire avec zram

FixUbuntu

git pull https://github.com/micahflee/fixubuntu

Allégement Ubuntu

apt-get -y purge --autoremove $(dpkg -l | awk '{print $2}' | grep -i ubuntuone)
apt-get -y purge --autoremove ubuntu-sso-client ubuntu-sso-client-gtk python-ubuntu-sso-client geoclue-ubuntu-geoip
apt-get -y purge --autoremove $(dpkg -l | awk '{print $2}'| grep compiz | grep -v ^lib)
apt-get -y purge --autoremove gnome-online-accounts xserver-xorg-video-vmware evolution-data-server gnome-orca gnome-accessibility-themes
apt-get -y purge --autoremove $(dpkg -l | awk '{print $2}' | grep gwibber | grep -v ^lib)
apt-get -y purge --autoremove zeitgeist-core zeitgeist rhythmbox-plugin-zeitgeist python-zeitgeist
apt-get -y purge --autoremove landscape-client-ui-install
apt-get -y purge --autoremove $(dpkg -l | grep speech | awk '{print $2}' | grep -v ^lib)
apt-get -y purge --autoremove $(dpkg -l | grep bluetooth | awk '{print $2}' | grep -v ^lib )
apt-get -y purge --autoremove $(dpkg -l | grep bluez | awk '{print $2}')
apt-get -y purge --autoremove apt-xapian-index indicator-keyboard

Bureau classique

apt-get install gnome-session-fallback gnome-panel

Autres

apt-get install atop htop fdupes check-dfsg-status sysstat apt-file rdiff-backup rsync vim synaptic vlc gimp chromium-browser powertop

note : check-dfsg-status remplace vrms

/etc/fstab

UUID=c6f15232-b71f-42a7-85bf-754ee44cac6a /               ext4    errors=remount-ro,noatime 0       1
UUID=a5d996f4-b25c-417a-9b41-941e9898431b /home           ext4    defaults,noatime,noexec,nosuid,nodev        0       2
tmpfs           /dev/shm        tmpfs   defaults,size=100m      0       0

Voir /etc/default/tmpfs

Il s'agit ici de

  • rajouter noatime sur toutes les partitions ext4 ou ext3
  • d'ajouter size=100m à la partition /dev/shm. Ici 100m est un exemple. La partition /dev/shm ne fera que 100 Mo de RAM.

Parametres système - Son - Effets sonores - Volume des alertes

sed -i -e 's/^NoDisplay=true.*/NoDisplay=false/' /etc/xdg/autostart/*.desktop
gnome-session-properties

Si MATE Desktop, remplacez gnome-session-properties par mate-session-properties

Désactivation de :

  • Onboard
  • Partage de bureau
  • Moniteur de sauvegarde
  • Discussion (Telepathy)
  • Moniteur de sauvegarde
  • Conversion des données GSettings
  • Mise à jour des dossiers utilisateur
  • Fichiers
cat > /etc/modprobe.d/jibe.conf <<EOF
blacklist minix
blacklist btrfs
blacklist xfs
blacklist reiserfs
blacklist ppdev
blacklist parport_pc
blacklist lp
blacklist parport
blacklist hfs
blacklist hfsplus
EOF

Voir :

FIXME deborphan


Notes Ubuntu 16.04

TODO: Tester de supprimer Compiz

FixUbuntu

Paramtètre système / Luminosité & verrouillage

  • Vérrouiller
  • Demander mon mot de passe lors de la sortie de veille

Sécurité et confidentialité Sécutité Demander mon mot de passe Dignostics

Unity Tweak Tool Unity / Web Apps

  • Inviers d'intégration : off

Domaines pré-autorisés Amazon : décoché Ubuntu One : Décoché

apt-get -y purge --autoremove $(dpkg -l | grep webapps | grep ^ii | awk '{print $2}')
apt-get install vim atop sysstat powertop deborphan acpi
apt-get -y purge --autoremove xul-ext-ubufox
apt-get autoremove
deborphan
apt-get -y purge --autoremove $(deborphan)
apt-get -y purge --autoremove $(deborphan)

Suppression effets sonores

Install libcss pour lire les DVD Le plus simple c'est d'installer VLC

apt-get install vlc
2025/03/24 15:06
blog.txt · Dernière modification : de 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki