Skip to main content

Hacks und Commands

**Images mit dd:**
Komprimiertes Image Vom Laufwerk erstellen:
dd if=/dev/sda | gzip --best >kodi-Image.gz

Zurückschreiben:
gunzip -c kodi-Image.gz | dd of=/dev/sda


**Dateiliste erstellen und die Liste mit einem Befehl abarbeiten:
**
*#/bin/bash
find /media/usbhd/Multimedia/Video/recordings/  -name "*.mpeg">liste
for f in $(cat liste) ; do 
rm $f
done

***Encodieren nach Liste***

*#/bin/bash
find /Media/Video/recordings/ -mtime 90 -name "*.mpeg">mpeg_liste
for mpeg in $(cat mpeg_liste) ; do 
mencoder -ovc x264 -oac mp3lame -ofps 25 -o $mpeg.mp4 $mpeg
done

--------------------------------------------------------------------

Find and do something...serial

find -iname '*.pdf' -exec cp {} /home/willi/pdf/ \;

-----------------------------------------------------------------------
**Audio extraieren aus *.mp4**
ffmpeg -i "The Eagles - Hotel California.mp4" -vn -acodec flac file.flac

**JPG aus *mp4 extraieren**
ffmpeg -i "vlc-record.mp4" -an -f image2 "output_%05d.jpg"

**mp4 aus jpg + Text einfügen

Insert Text in Video:
ffmpeg -i output_Montag2.mp4 -vf  drawtext="fontfile=/usr/share/fonts/truetype/ttf-dejavu/DejaVuSerif.ttf:text='12.04.21':fontsize=20:fontcolor=blue:x=1800:y=10" with_text3.mp4

ffmpeg -framerate 25 -start_number 4 -i Photo/Montag/image-%04d.jpg -c:v libx264 -profile:v high -crf 20 -pix_fmt yuv420p /home/willi/Montag_16-20output.mp4

ffmpeg -framerate 25  -i install/MO/image%04d.jpg -c:v libx264 -profile:v high -crf 20 -pix_fmt yuv420p /home/willi/Montag_19output.mp4

------------
**Video kodieren x265**
ffmpeg -i "Der Auftragskiller - Zimmer 164.mp4" -c:v libx265 -preset medium -x265-params crf=25 -c:a aac -strict experimental -b:a 128k output.mp4

------------
**HD-Streams bearbeiten**
1. ffmpeg  -i 'vlc-record-.ts' -vcodec copy -acodec copy  'Wallander.ts'
     -korrigiert Fehler im Stream

2. ffmpeg -ss 00:05:55 -i 'Wallander.ts' -vcodec copy -acodec copy -bsf:a aac_adtstoasc -f mp4 'Wallander.mp4'
    - ss: schneidet die ersten 34 Sekunden ab
    - t : Schnitt an Streamposition 1:35:44 (gemessen ab -ss)
    - bsf:  behebt Fehler in der Audiospur
------------


**Leerzeichen in Dateinamen entfernen**
*#/bin/bash
 for i in *\ *
do mv "$i" "${i// /_}"
done*
oder:
*#/bin/bash
 for i in /media/usbhd/Multimedia/Video/recordings/Deutsches_Europa_Kino/*.mp4
do mv "$i" "${i// /_}" 
done

------------

**Installation nach Paketliste**
#/bin/bash
for pkg in $(cat installed_packages.list) ; do 
        apt-get -y install $pkg
    done

#Paketliste erstellt mit: dpkg -l|grep ii|awk '{print$2}'>installed_packages.list

------------
**Verschlüsseln/entschlüsseln mit ssl**

*
*#!/bin/bash*
*# make sure we get a file name*
if [ $# -lt 1 ]; then
  echo "Usage: $0 filename"
  exit 1
fi
openssl enc -e -aes256 -in "$1" -out "$1".enc*


*#!/bin/bash*
*# make sure we get 2 files*
if [ $# -lt 2 ]; then
  echo "Usage: $0 encrypted_file decrypted_file"
  exit 1
fi
openssl enc -d -aes256 -in "$1" -out "$2"

------------
**Streaming mit vlc**
**
**#/bin/bash
cvlc .mplayer/Sender.conf --extraintf http --sout udp:172.16.1.164&
exit

------------

#### Phpmyadmin für weiteren Server einrichten:
 **Datei: /etc/phpmyadmin/config.inc.php**:

<?php 
$cfg['blowfish_secret']='multiServerExample70518';
//any string of your choice (max. 46 characters)
$i = 0; 
 
$i++; // server 1 :
$cfg['Servers'][$i]['auth_type'] = 'cookie'; // needed for pma 2.x
$cfg['Servers'][$i]['verbose']   = 'no1'; 
$cfg['Servers'][$i]['host']      = 'localhost';
$cfg['Servers'][$i]['extension'] = 'mysqli';
// more options for #1 ...
 
$i++; // server 2 :
$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['verbose']   = 'no2'; 
$cfg['Servers'][$i]['host']      = 'banapi';//or ip:'10.9.8.1'
// this server must allow remote clients, e.g., host 10.9.8.%
// not only in mysql.host but also in the startup configuration
$cfg['Servers'][$i]['extension'] = 'mysqli';
// more options for #2 ... 
 
// end of server sections
$cfg['ServerDefault'] = 0; // to choose the server on startup
 
// further general options ...
?>

------------
#### Teamviewer auf 64bit

Vielleicht zur Erklärung:
Das 64-Bit-Paket verwendet zum installieren das Paket Debiania32-libs, welches seit Wheezy nicht mehr vorhanden ist.
Du musst also die 32Bit Version installieren und vorher Multiarch freischalten mit:

dpkg --add-architecture i386

Danach ein

apt-get update

Jetzt das Paket herunterladen:

wget http://download.teamviewer.com/download/teamviewer_i386.deb

Das Paket installieren:

dpkg -i teamviewer_i386.deb

Und fehlende Abhängigkeiten installieren:

apt-get install -f


Steht auch sonst alles hier:
-> http://www.teamviewer.com/en/help/363-How-do-I-install-TeamViewer-on-my-Linux-distribution.aspx

------------


#### Samba meckert uber Cups -das gar nicht installiert ist...

#####prevent logsentries about cups####
     load printers = no
     printing = bsd
     printcap name = /dev/null
     disable spoolss = yes

------------
#### NATNAT: Dem Kernel das Weiterleiten beibringen
Wir möchten also dem Kernel das folgende mitteilen: Bei Paketen aus dem lokalen Netz, dessen IP-Adresse 
nicht mit seiner übereinstimmt, soll er die Absender-Adresse auf sich selbst ändern. Dazu machen wir noch 
die Annahme, dass das erste Netzwerk-Interface des Linux-Routers "eth0" mit dem lokalen Netz verbunden ist 
und die Internet-Verbindung am zweiten Interface "eth1" verfügbar ist. 
Der Befehl zur Freigabe der Internet-Verbindung lautet dann:

   *Anbinden eines LAN an das Internet*
   $> iptables -t nat -A POSTROUTING -o tun0 -j MASQUERADE
   iptables-Tabellen speichern

**Beispiel um iptables-Tabellen zu speichern**:

sudo iptables-save > /etc/iptables_01.save 

**Beispiel um iptables-Tabellen wieder zu laden. Vorhandenen Regeln werden dabei gelöscht bzw. überschrieben.**

sudo iptables-restore < /etc/iptables_01.save 

**So werden bereits vorhandene Regeln nicht gelöscht:**

sudo iptables-restore -n < /etc/iptables_01.save
sudo iptables-restore --noflush < /etc/iptables_01.save 

So können natürlich auch mehrere Tabellen gespeichert und je nach Bedarf wieder geladen werden.
**iptables-Tabellen löschen**

sudo iptables --flush 
#### [Linux Nat Toutorial](http://www.karlrupp.net/de/computer/nat_tutorial "Linux Nat Toutorial")
------------

#### Mit sed alle Zeilen löschen, die "pattern" enthalten
sed '/pattern to match/d' ./infile
To directly modify the file (and create a backup):
sed -i.bak '/pattern to match/d' ./infile

#/bin/bash
mount -t cifs //fritz.box/fritz.nas /home/willi/smb -o username=Maria,password=oma

**SSH Passwordless Login** 
ssh-keygen -t rsa 
ssh-copy-id -i ~/.ssh/id_rsa.pub user@remote-system

** Dateiberechtigungen sichern**

To back up permissions in the current directory and its subdirectories recursively:

getfacl -R  >permissions.facl
To restore permissions:
setfacl --restore=permissions.facl

**Filesystemcheck:**

umount /media/veracrypt1
fsck /dev/mapper/veracrypt1

**Splitten von MP3:**
mp3splt:
Automatisch:
mp3splt -c query file.mp3
Manuell
mp3splt -s -p min=2 file.mp3

**Mount Winfreigabe:**
mount -t cifs //fritz.box/fritz.nas /home/willi/smb -o username=Maria,password=oma

wget komplette Seite

wget -r -l 0 -p -k -D alan-g.me.uk -L -np    http://www.alan-g.me.uk/l2p/

PiHole Docker Unbound – Error starting userland proxy: listen tcp4 0.0.0.0:53: bind: address already in use
systemctl disable systemd-resolved.service
systemctl stop systemd-resolved.service
rm /etc/resolv.conf
echo 1.1.1.1 > /etc/resolv.conf
Photoprism   - Hinzufügen von Exif-Daten

gps-Breddeberg:     exiftool -gpsposition="52.954431,7.612263"
gps-Münster:        exiftool -gpsposition="51.962474,7.641221"
gps-Woldendorp:        exiftool -gpsposition="53.264325,7.032647"
gps-Texel:        exiftool -gpsposition="53.042425,4.847604"
gps-Sögel:              exiftool -gpsposition="52.843778,7.525737"
gps-Hiddensee:          exiftool -gpsposition="54.566119,13.105373"
gps-Irland:             exiftool -gpsposition="52, -9"
gps-isselmeer:        exiftool -gpsposition="52.801742,5.404546"
gps-fanö:        exiftool -gpsposition="55.424075,8.369926"
gps-Martha Herford:    exiftool -gpsposition="52.120931,8.668131"
gps-Meck-Pomm:        exiftool -gpsposition="53.5,12.6"
gps-Kalkriese:        exiftool -gpsposition="52.413609,8.101240"
gps-DTV1847:        exiftool -gpsposition="51.243694,6.829081"
gps-Ittertal:        exiftool -gpsposition="51.190094,7.035310"
gps-Borkum        exiftool -gpsposition="53.600894,6.664150"
gps- Rom        exiftool -gpsposition="41.8,12.4"
gps- Langeoog        exiftool -gpsposition="53.751632,7.474670"
gps- Brasmsche        exiftool -gpsposition="52.404503, 7.978780"
gps-Hannover         exiftool -gpsposition="52.388348, 9.682896"
-----------------------------------------------------------------

exiftool -preserve -d "%Y%m%d %H%M%S" -AllDates="$DATESTR $TIMESTR" $FILE

exiftool -preserve -d "%Y%m%d %H%M%S" -AllDates="20200101 1200" 

exiftool -gpsposition="51.962474,7.641221"
exiftool -preserve -d "%Y%m%d %H%M%S" -AllDates="20140726 2000" *

----------------------------------------------------------------------------------------------

Paperless-Backup-Restore*

docker exec paperlessngx-webserver-1 document_exporter ../export

docker exec paperlessngx-webserver-1 document_importer ../export

  • Paperlessversionen sollten übereinstimmen!

---------------------------------------------------------------------------------------------------

ln -s {source-filename} {symbolic-filename}

--------------------------------------------------------------------------------------------------

mysql Wordpress URL-Update

Step 2: Select the WordPress Database:

Once you are logged into MySQL, you need to select the WordPress database. If you know the name of your WordPress database, use the following command:

use database_name;

Replace ‘database_name’ with the actual name of your WordPress database.

For example:

mysql> use wordpressdb;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed

Check current value for ‘siteurl’ and ‘home’:

mysql> SELECT option_name, option_value FROM wp_options WHERE option_name IN ('siteurl', 'home');
+-------------+-----------------------------------+
| option_name | option_value                      |
+-------------+-----------------------------------+
| home        | https://www.webhostinggeeks.local |
| siteurl     | https://www.webhostinggeeks.local |
+-------------+-----------------------------------+
2 rows in set (0.00 sec)

If you are not sure about the database name, you can list all the available databases using the following command:

show databases;

Then, select the appropriate database using the use command as shown above.

Step 3: Update the URLs:

To change the URLs in the database, you need to update two specific tables: wp_options and wp_posts. Execute the following commands:

UPDATE wp_options SET option_value = replace(option_value, 'old_url', 'new_url') WHERE option_name = 'home' OR option_name = 'siteurl';

Replace ‘old_url’ with the current URL of your WordPress site and ‘new_url’ with the new URL you want to set.

For example:

mysql> UPDATE wp_options SET option_value = 'https://webhostinggeeks.com/howto' WHERE option_name IN ('siteurl', 'home');
Query OK, 2 rows affected (0.00 sec)
Rows matched: 2  Changed: 2  Warnings: 0

Check the updated value for ‘siteurl’ and ‘home’ :

mysql> SELECT option_name, option_value FROM wp_options WHERE option_name IN ('siteurl', 'home');

+-------------+-----------------------------------+
| option_name | option_value                      |
+-------------+-----------------------------------+
| home        | https://webhostinggeeks.com/howto |
| siteurl     | https://webhostinggeeks.com/howto |
+-------------+-----------------------------------+
2 rows in set (0.00 sec)

Next, execute the following command to update the URLs in the wp_posts table:

UPDATE wp_posts SET post_content = replace(post_content, 'old_url', 'new_url');

Again, replace ‘old_url’ with the current URL and ‘new_url’ with the new URL.

Step 4: Confirm the Changes:

To ensure that the changes have been made successfully, execute the following commands:

SELECT option_value FROM wp_options WHERE option_name = 'home' OR option_name = 'siteurl';
SELECT guid FROM wp_posts WHERE post_type = 'post' OR post_type = 'page';

These commands will display the updated URLs in the wp_options table and the guid column of the wp_posts table.

-----------------------------------------------------------------------------------------------------------------------