How to clone a specific git branch

If you need to copy an already existing branch into a new or seperate repository just use this command:

cd ~/projects/
git clone --single-branch --branch <branchname> <remote-repo> project1
cd project1/
git branch

It will create a repo inside of projects/project1 inside your Home folder which contains a branch called <branchname> copied from <remote-repo>. This source <remote-repo> could be a remote reference (https..) but also a local folder.

Thanx to stackoverflow 😉

Create GPG Key

Not even to encrypt email content but files too it’s easily done using GPG2. So here we go:

gpg2 --full-gen-key

List your keys and get more detailed information:

gpg2 --list-keys
gpg2 --fingerprint <KEY-ID>

Generate revocation certificate or export key:

gpg --output revoke.asc --gen-revoke <KEY-EMAIL>
gpg --armor --output public-key.gpg --export <KEY-EMAIL>

To link your gpg key to an email address open your mail software, e.g. Evolution or Thunderbird, and add <KEY-ID> to your account settings.

A more detailed guide can be found on linode.com.

Set or Extend PGP Expiration Date

If expiration date of a pgp key got reached this key cannot be used for encryption. In general it’s a good choice to set an expiration date as mentioned on riseup.net:

People think that they don’t want their keys to expire, but you actually do. Why? Because you can always extend your expiration date, even after it has expired! This “expiration” is actually more of a safety valve or “dead-man switch” that will automatically trigger at some point. If you have access to the secret key material, you can untrigger it. The point is to setup something to disable your key in case you lose access to it (and have no revocation certificate).

It’s not hard to extend the expiration date. So here you go:

gpg2 --list-keys
gpg2 --edit-key <KEY-ID>

Now you’re in the gpg console. (By default, you’re working on the primary key.) If you need to update a sub-key:

gpg> expire
(follow prompts)
gpg> save

Now that you’ve updated your key, you can send it out:

gpg2 --keyserver pgp.mit.edu --send-keys <KEY-ID>

Thanks to the comment at superuser.com.

Debian-Derivates and Antivirus

ClamAV

installation

sudo apt install clamav
sudo apt install clamtk # install GUI 

update

sudo freshclam

If update is not possible:

# -> Your ClamAV installation is OUTDATED!
wheris freshclam
wheris clamscan
ldd $(which freshclam)

and check for (old) libclamav.so

usage

clamscan -r -i /dir/to/scan/recursively

or start ClamTk-GUI.

chkrootkit

sudo apt install chkrootkit
chkrootkit -l
sudo chkrootkit

lock Screen using i3

I use i3 for a short time now (hosted by ArcoLinux) and it’s great. It’s fast – even on older hardware – and after a while easy to use. One thing that’s not working out of the box is to lock the screen after a specific time of inactivity. That’s how I did it…

First I installed xautolock and i3lock:

pacman -S xautolock i3lock

Afterwards the configuration of i3 – located in ~/.config/i3/config – had to be modified:

#Press $mod (super) and X to exit - check toolbar for next choices
bindsym $mod+X mode "$mode_system"
bindsym control+mod1+Delete mode "$mode_system"

set $Locker i3lock --color=000000 && sleep 1

set $mode_system System (k) lock, (l) logout, (u) suspend, (h) hibernate, (r) reboot, (s) shutdown
mode "$mode_system" {
bindsym k exec --no-startup-id $Locker, mode "default"
bindsym l exec --no-startup-id ~/.config/i3/scripts/i3exit.sh logout, mode "default"
bindsym u exec --no-startup-id ~/.config/i3/scripts/i3exit.sh suspend, mode "default"
bindsym h exec --no-startup-id ~/.config/i3/scripts/i3exit.sh hibernate, mode "default"
bindsym r exec --no-startup-id ~/.config/i3/scripts/i3exit.sh reboot, mode "default"
bindsym s exec --no-startup-id ~/.config/i3/scripts/i3exit.sh shutdown, mode "default"

# back to normal: Enter or Escape
bindsym Return mode "default"
bindsym Escape mode "default"
}


exec --no-startup-id xautolock -time 5 -locker 'i3lock --color=000000' -corners +00-

The bold text are modified lines. These settings activates the screenlock by hitting MOD+x k or automatically after five minutes of inactivity.

There’s one question left: How am I able to restart xautolock daemon without restarting my PC?

BSOD auf Grund fehlerhaftem Windows-Update beheben

Gerade im Zusammenhang mit dem Wirrwarr um Meltdown / Spectre kann es zu Komplikationen auf Windows-Installationen kommen. Im mir untergekommenen Fall handelt es sich um ein Windows 7 mit AMD-Prozessor. Nach Download des Betriebssystem-Updates KB4056894 und erfolgtem Neustart wurde lediglich ein BSOD (Blue Screen of Death) angezeigt.

Um dieses Problem zu lösen half auch der abgesicherte Modus nicht weiter, da selbst dieser durch den Bluescreen abgefangen wurde.

Also musste die Systemwiederherstellung weiterhelfen: Mit F8 in die Boot-Optionen, mit erneutem F8 in die Systemwiederherstellungsoptionen.

In eben diesem wird oben das Windows-Laufwerk genannt: „Betriebssystem: Windows 7 auf (E:) Lokaler Datenträger“. Nun starte ich die Eingabeconsole und wechsle in das Systemlaufwerk:

> dir e:

Nun liste ich alle installierten Updates auf:

> dism /format:table /image:e:\ /get-packages

Innerhalb der gezeigten Pakete sollte sich eines namens Package_for_RollupFix befinden, welches kürzlich installiert wurde. Dieses entferne ich nun, beende die Konsole und starte das System danach neu:

> dism /image:e:\ /remove-package /packagename:Package_for_RollupFix~31bf3856ad364e35~amd64~~7601.24002.1.4 /norestart
> exit

Windows startet nun wieder. Die automatischen Updates deaktiviere ich jetzt erst einmal, bis sich die Update-Situation seitens Microsoft etwas stabilisiert hat.

Noch ein kleiner Tipp zum Schluss: um sich Optionen/Hilfe zu Konsolen-Befehlen anzeigen zu lassen, einfach ein /? abschließend eintippen, z.B.:

> dism /image:e:\ /?

Dank an dieser Stelle an pcgameshardware.de und winboard.com.

Festplatten formatieren & partitionieren

Zwar kann jedes aktuelle Betriebssystem eine grafische Oberfläche zum Bearbeiten von HDD/SDD-Inhalten bieten, doch nicht immer erzielen diese das gewünschte Ergebnis, z.B.

„The driver descriptor says the physical block size is 2048 bytes, but Linux says it is 512 bytes.“ (gnome-disk-utility).

Um nun eine fehlgeschlagene Partitionierung zu berichtigen oder generell auszuführen, bietet sich das Terminal an.

Der MBR (Master Boot Record) wird mittels

$ dd if=/dev/zero of=/dev/hdX bs=512 count=1

überschrieben.

Zur manuellen Partitionierung bietet sich die Anleitung unter hecticgeek.com an.

Schritt 1: Auflisten der vorhandenen Platten/Partitionen:

$ sudo fdisk -l

Schritt 2: Platte formatieren; wichtig dabei, den richtigen Pfad anzugeben, da alle dortigen Daten unwiderbringlich gelöscht werden

$ sudo fdisk /dev/sdX

Mit `p` werden die vorhandenen Partitionen gelistet, mit `d` wird entfernt. Nach Abschluss einer Aktion wird stets ein neues Kommando angefordert. `t` selektiert den Partitionstyp (FAT, NTFS, ext4, ..), 86 wählt NTFS. Mit `w` werden die Aktionen ausgeführt und auf die Hardware geschrieben.

Eine weitere Möglichkeit wäre das Ausführen von `sudo mkfs -t nfts -f -L your_label_here /dev/sdX1`, was die Partition sdX1 mit dem Dateisystem NTFS formatiert.

Weitere Anregungen finden sich auf how-to.wikia.com.

Festplatten-Backups per dd

$ sudo dd if=/dev/sda of=~/sda.img bs=1M status=progress

Dadurch wird von der kompletten Disk sda ein Image nach /home/<USER>/sda.img geschrieben. Der Parameter bs bestimmt die Blockgröße, Standard sind 512 Bytes – die Angabe von 1M beschleunigt den Kopiervorgabe doch erheblich.

Ein Zurückspielen des Abbildes funktioniert mit:

$ sudo dd=~/sda.img of=/dev/sda bs=1M

Weitere Details sind unter ubuntuusers.de zu finden.

txt2pdf

Angelehnt an meinen letzten Post hier ein Script zum Konvertieren einer Textdatei zu PDF bei Benutzung des Terminals.

#!/bin/bash

# convert txt to pdf
#
# usage: txt2pdf FileWithoutExt
#
# sudo apt install enscript ps2pdf

FILE="$1"

enscript $FILE.txt -o - | ps2pdf - $FILE.pdf

Dieses Skript unter /usr/bin/txt2pdf speichern und die Rechte entsprechend setzen (sudo chmod 755 /usr/bin/txt2pdf). Nun entsteht mittels

$ txt2pdf datei

aus datei.txt datei.pdf.

Das Web und ich