shell

Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen angezeigt.

Link zu dieser Vergleichsansicht

Beide Seiten der vorigen Revision Vorhergehende Überarbeitung
Nächste Überarbeitung
Vorhergehende Überarbeitung
shell [21/11/2023 - 08:33] adminshell [25/12/2024 - 17:00] (aktuell) – [Shell Basics] thommie_netzwissen.de
Zeile 1: Zeile 1:
-====== Shell allgemein ======+====== Shell Basics ======
  
 [[http://www.gnu.org/software/bash/manual/bashref.html|http://www.gnu.org/software/bash/manual/bashref.html]] [[http://www.gnu.org/software/bash/manual/bashref.html|http://www.gnu.org/software/bash/manual/bashref.html]]
  
 [[https://www.shellscript.sh/|https://www.shellscript.sh/]] [[https://www.shellscript.sh/|https://www.shellscript.sh/]]
- 
-[[http://www.linux-services.org/shell/|http://www.linux-services.org/shell/]] 
  
 ===== GB keyboard ===== ===== GB keyboard =====
Zeile 62: Zeile 60:
 [[https://manpages.ubuntu.com/manpages/trusty/de/man8/update-alternatives.8.html|https://manpages.ubuntu.com/manpages/trusty/de/man8/update-alternatives.8.html]] [[https://manpages.ubuntu.com/manpages/trusty/de/man8/update-alternatives.8.html|https://manpages.ubuntu.com/manpages/trusty/de/man8/update-alternatives.8.html]]
  
-===== Diverses =====+===== Random string erzeugen =====
  
-Random string erzeugen 
 <code> <code>
- 
 tr -dc A-Za-z0-9 </dev/urandom | head -c 25 ; echo '' tr -dc A-Za-z0-9 </dev/urandom | head -c 25 ; echo ''
- 
 </code> </code>
 +
 ===== Links ===== ===== Links =====
  
-<language-none> 
 ''ln -s /Zieldatei /Referenz ''ln -s /Zieldatei /Referenz
-</language-none> 
  
 +=====   Find   =====
  
 +Alle Dateien älter als 365 Tage finden
 +
 +<code>
 +find /mnt/pve/sb_u203461/dump/ -mtime +365 -type f
 +</code>
 +
 +Mit löschen:
 +
 +<code>
 +find /mnt/pve/sb_u203461/dump/ -mtime +365 -type f -delete
 +</code>
 +
 +Luxus Variante mit Backup
 +
 +<code>
 +#!/bin/bash
 +path="/data/backuplog/"
 +timestamp=$(date +%Y%m%d_%H%M%S)    
 +filename=log_$timestamp.txt    
 +log=$path$filename
 +days=7
 +
 +START_TIME=$(date +%s)
 +
 +find $path -maxdepth 1 -name "*.txt"  -type f -mtime +$days  -print -delete >> $log
 +
 +echo "Backup:: Script Start -- $(date +%Y%m%d_%H%M)" >> $log
 +
 +
 +... code for backup ...or any other operation .... >> $log
 +
 +
 +END_TIME=$(date +%s)
 +
 +ELAPSED_TIME=$(( $END_TIME - $START_TIME ))
 +
 +echo "Backup :: Script End -- $(date +%Y%m%d_%H%M)" >> $log
 +echo "Elapsed Time ::  $(date -d 00:00:$ELAPSED_TIME +%Hh:%Mm:%Ss) "  >> $log
 +</code>
 +
 +===== sed =====
 +
 +replace "-d" with "-d "
 +<code>
 +
 + <font inherit/monospace;;inherit;;#000000background-color:#ffffff;>sed s/-d/'-d '/g domains3.txt> domains4.txt</font> 
 +</code>
 +
 +trim string and remove newlines
 +
 +<code>
 + <font inherit/monospace;;inherit;;#000000background-color:#ffffff;>tr --delete '\n' <domains2.csv> domains3.txt</font> 
 +</code>
 +
 +
 +===== Alte Kernels raus schmeissssen =====
 +
 +<code>
 +uname -mrs = current kernel
 +dpkg --list | egrep -i --color 'linux-image|linux-headers'
 +aptitude purge linux-image-5.10.0-{18,19,20}-amd64
 +update-grub
 +reboot
 +<code>
  • shell.1700555584.txt.gz
  • Zuletzt geändert: 17/08/2024 - 07:06
  • (Externe Bearbeitung)