Commands Collection
Collection of helpful Linux commands.
List File With Leading Line Numbers
nl -w2 -s"| " testfile.txt
1| This is a test file
2| with line break.
List group of files
find . -type f | awk -F. '{print $NF}' | sort | uniq -c | sort -n
Generate and Read QR Codes
# Generate
echo "some data" | base64 -w 0 | qrencode -l Q -t SVG -o /tmp/qr.svg
# Read
zbarimg -q /tmp/qr.svg | cut -c 9- | base64 -d
Generate Duplex PDF from Single Page Scan
# Change order of even pages
/usr/bin/pdftk EvenPages.pdf cat end-1 output BackWardsEvenPages.pdf
# Merge even and odd pages
/usr/bin/pdftk ODD=OddPages.pdf EVEN=backWardsEvenPages.pdf shuffle ODD EVEN output FinalDocument.pdf
# Remove last blank page, if necessary
/usr/bin/pdftk FinalDocument.pdf cat 1-r2 output FinalDocumentWithoutLast.pdf
Media Files
Download Videos
Provide a selection of possible variations of audio and video format.
yt-dlp -f- <URL>
yt-dlp -f "AUDIO_ID_1+AUDIO_ID_2+AUDIO_ID_3+VIDEO_ID" --audio-multistreams <URL>
docker run --user="1000:1000" --rm -it --volume=.:/downloads:rw jauderho/yt-dlp:latest -f "bv*+ba/best" "${1}"
Rename mass files
Rename Media Files to Create Date
exiftool -d '%Y-%m-%d_%H%M%S.%%e' '-filename<CreateDate' -v 1 *
exiftool -d '%Y-%m-%d_%H%M%S.%%e' '-filename<DateTimeOriginal' -v 1 *
Rename File based on Modified Date
for f in *.jpg
do
mv -n "$f" "$(date -r "$f" +"%Y-%m-%d_%H%M%S").jpg"
done
Copy Metadata Media
exiftool -TagsFromFile source.mp4 -all:all -overwrite_original destination.mp4
Geotag Pictures
exiftool -geotag=geolocation.gpx -geosync=-1 ./photos/
-geosync defines offset in hours
Create Empty File
# create file with size but does not allocate space on disc
truncate -s 1G foo.file
# create file with size also llocate space on disc
fallocate -l 1G foo.file
Remove DRM from PDF
Manual Process
# Login to Adobe DRM
adept_activate --username ADOBE_LOGIN_USERNAME --password ADOBE_LOGIN_PASSWORD
# Download PDF from ASCM File
acsmdownloader --acsm-file downloadfile.ascm --output-file outputfile
# Remove DRM
adept_remove TMPOUT
DRM PDF Setup with Docker
# Create Adobe Credentials Files
docker run \
-v $(pwd)/adept/:/home/libgourou/.adept \
--rm \
--entrypoint adept_activate -u <USERNAME> --output-dir /home/libgourou/.adept \
bcliang/docker-libgourou
# Remove DRM
docker run \
-v $(pwd)/adept/:/home/libgourou/.adept \
-v $(pwd):/home/libgourou/files \
--rm bcliang/docker-libgourou \
book.acsm
Rename File in Folder to Lowercase
find . -type f -exec perl-rename -v 'y/A-Z/a-z/' {} \;
Convert
Convert AVI to mp4
ffmpeg -i input.avi -c:v libx264 -b:v 800k -c:a mp3 output.mp4
Convert Markdown to PDF
# Set alias
alias pandocker="docker run --rm --volume "`pwd`:/data" --user `id -u`:`id -g` pandoc/latex:2.6"
#Use the command
pandocker in.md -o out.pdf
Clear log journal
sudo journalctl --rotate --vacuum-time=1s
ZFS
Destroy all Snapshots from Dataset
zfs list -H -o name -t snapshot <POOL/DATASET> | xargs -n1 sudo zfs destroy -v -n
Remote RDP connection Gnome Shell
# Enable RDP
gsettings set org.gnome.desktop.remote-desktop.rdp enable true
gsettings set org.gnome.desktop.remote-desktop.vnc enable true
# Get Fingerprint of Encryption Certificate
openssl x509 -in ~/.local/share/gnome-remote-desktop/certificates/rdp-tls.crt -noout -text -fingerprint -sha256
# Disable RDP
gsettings set org.gnome.desktop.remote-desktop.rdp enable false
gsettings set org.gnome.desktop.remote-desktop.rdp view-only true
Remote RDP connection Gnome Shell
# Enable VNC
gsettings set org.gnome.desktop.remote-desktop.vnc enable true
gsettings set org.gnome.desktop.remote-desktop.vnc view-only false
grdctl vnc set-password
# Disable VNC
gsettings set org.gnome.desktop.remote-desktop.rdp enable false
gsettings set org.gnome.desktop.remote-desktop.rdp view-only true
SIP
Telekom
Baresip Configuration
<sip:+49yournumber@tel.t-online.de>;auth_user=anonymous@t-online.de;auth_pass=1234;outbound="sip:tel.t-online.de;transport=tcp"
| Key | Value |
|---|---|
| SIP URI | sip:+49yournumber@tel.t-online.de |
| Nickname | +49yournumbe |
| Display Name | +49yournumbe |
| Authentication Username | anonymous@t-online.de |
| Authentication Password | random |
| SIP URI of Proxy Server | sip:tel.t-online.de;transport=tcp |
| Telephony Provider | sip:tel.t-online.de;transport=tcp |
| Register | true |
| Check Origin | true |