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 [17/08/2024 - 07:06] – Externe Bearbeitung 127.0.0.1shell [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>
  
Zeile 75: Zeile 70:
 ''ln -s /Zieldatei /Referenz ''ln -s /Zieldatei /Referenz
  
-=====   Code snippets   =====+=====   Find   =====
  
-==== sed ====+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 " replace "-d" with "-d "
Zeile 92: Zeile 127:
  
  
 +===== 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.1723878391.txt.gz
  • Zuletzt geändert: 17/08/2024 - 07:06
  • von 127.0.0.1