Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Beide Seiten der vorigen Revision Vorhergehende Überarbeitung Nächste Überarbeitung | Vorhergehende Überarbeitung | ||
commands-general-tools [2018/07/26 18:09] alex [Process Stuff] Abschnitt hinzugefügt |
commands-general-tools [2020/07/11 11:22] (aktuell) alex [Conversion Stuff] add rounded corners to an image (for app icon with rounded corners in the style of iPhone‘s SpringBoard) |
||
---|---|---|---|
Zeile 33: | Zeile 33: | ||
clang++ -dM -E -x c /dev/null | clang++ -dM -E -x c /dev/null | ||
</ | </ | ||
+ | |||
==== OpenSSL ==== | ==== OpenSSL ==== | ||
Zeile 95: | Zeile 96: | ||
curl test.schrimpe.de -x 127.0.0.1: | curl test.schrimpe.de -x 127.0.0.1: | ||
</ | </ | ||
- | [[https:// | + | [[https:// |
=== measure duration of HTTP request === | === measure duration of HTTP request === | ||
Zeile 101: | Zeile 102: | ||
curl https:// | curl https:// | ||
</ | </ | ||
- | [[https:// | + | [[https:// |
=== check whether a TCP connection can be established with a three second timeout === | === check whether a TCP connection can be established with a three second timeout === | ||
Zeile 107: | Zeile 108: | ||
nc -w3 -z 192.168.0.1 80 ## return code zero on success | nc -w3 -z 192.168.0.1 80 ## return code zero on success | ||
</ | </ | ||
- | [[https:// | + | [[https:// |
=== mDNS query === | === mDNS query === | ||
Zeile 113: | Zeile 114: | ||
dig somehostname.local @224.0.0.251 -p 5353 | dig somehostname.local @224.0.0.251 -p 5353 | ||
</ | </ | ||
- | [[https:// | + | [[https:// |
=== verify DNSSEC chain of a domain === | === verify DNSSEC chain of a domain === | ||
<code bash> | <code bash> | ||
- | ## obtain | + | ## if you don't have the root keys yet, obtain them first |
+ | unbound-anchor -a / | ||
+ | ## if the root key file is at the standard path of your unbound/ | ||
drill -S -k / | drill -S -k / | ||
- | ## if your resolver does not support DNSSEC use e.g. Quad9 | + | ## if your resolver does not support DNSSEC, use a public one, e.g. Hurricane Electric |
- | drill -S -k / | + | drill -S -k / |
</ | </ | ||
+ | [[https:// | ||
=== check whether your DNS resolver discards invalid DNSSEC domains === | === check whether your DNS resolver discards invalid DNSSEC domains === | ||
Zeile 127: | Zeile 131: | ||
dig www.dnssec-failed.org | dig www.dnssec-failed.org | ||
</ | </ | ||
+ | [[https:// | ||
+ | |||
+ | === check whether your DNS resolver uses QNAME minimisation === | ||
+ | <code bash> | ||
+ | dig txt qnamemintest.internet.nl +short | ||
+ | </ | ||
+ | [[https:// | ||
=== scan all TCP ports of a host === | === scan all TCP ports of a host === | ||
Zeile 132: | Zeile 143: | ||
nmap -p- somehost.example.com | nmap -p- somehost.example.com | ||
</ | </ | ||
- | [[https:// | + | [[https:// |
+ | |||
+ | === reverse DNS lookup of an IP subnet === | ||
+ | <code bash> | ||
+ | nmap -R -sL 198.51.100.96/ | ||
+ | nmap -R -sL -6 2001: | ||
+ | </ | ||
+ | [[https:// | ||
+ | |||
+ | === scan for responding hosts in an IP subnet === | ||
+ | <code bash> | ||
+ | ## probe TCP connect on Port 80 with five attempts for each host | ||
+ | nping 198.51.100.96/ | ||
+ | ## probe ICMP with five attempts for each host | ||
+ | nping --icmp 198.51.100.96/ | ||
+ | ## probe ICMP with one attempt for each host and 200ms between requests (and decrease verbosity) | ||
+ | nping -q --count 1 --delay 200ms --icmp 198.51.100.96/ | ||
+ | </ | ||
+ | [[https:// | ||
==== File Stuff ==== | ==== File Stuff ==== | ||
=== count lines of a certain file type recursively (e.g. C++ source files) === | === count lines of a certain file type recursively (e.g. C++ source files) === | ||
<code bash> | <code bash> | ||
- | find . -name " | + | find / |
</ | </ | ||
+ | [[https:// | ||
=== check recursively for broken symlinks === | === check recursively for broken symlinks === | ||
<code bash> | <code bash> | ||
- | find . -type l ! -exec test -e {} \; -print | + | find / |
+ | </ | ||
+ | [[https:// | ||
+ | |||
+ | === delete recursively all files with a certain name (e.g. “.DS_Store”) === | ||
+ | <code bash> | ||
+ | find /your/dir -type f -name .DS_Store -print -delete | ||
</ | </ | ||
+ | [[https:// | ||
=== create checksums of directory tree and verify them === | === create checksums of directory tree and verify them === | ||
Zeile 155: | Zeile 192: | ||
rhash -cr --crc-accept=sfv, | rhash -cr --crc-accept=sfv, | ||
</ | </ | ||
- | [[https:// | + | [[https:// |
=== create a file with specific timestamps === | === create a file with specific timestamps === | ||
Zeile 164: | Zeile 201: | ||
## -t = timestamp - use [[CC]YY]MMDDhhmm[.ss] time format | ## -t = timestamp - use [[CC]YY]MMDDhhmm[.ss] time format | ||
</ | </ | ||
- | [[https:// | + | [[https:// |
=== handle sparse files === | === handle sparse files === | ||
Zeile 173: | Zeile 210: | ||
dd if=inputSparse.ext of=outputSparse.ext bs=4096 conv=sparse | dd if=inputSparse.ext of=outputSparse.ext bs=4096 conv=sparse | ||
</ | </ | ||
- | [[https:// | + | [[https:// |
+ | |||
+ | === create a 7-ZIP archive encrypted with a password === | ||
+ | |||
+ | <code bash> | ||
+ | 7z a -p -mhe=on the_new_archive.7z -r dir_containing_stuff another_file.bin | ||
+ | </ | ||
+ | [[https:// | ||
+ | |||
+ | === view contents of ZIP or TAR files without complete extracting === | ||
+ | <code bash> | ||
+ | ### example of " | ||
+ | unzip -l SomeAndroidApp.apk | ||
+ | unzip -p SomeAndroidApp.apk META-INF/ | ||
+ | ### example of an "Open Virtual Appliance" | ||
+ | tar -tf SomeAppliance.ova | ||
+ | tar -xfO SomeAppliance.ova SomeAppliance.ovf | ||
+ | </ | ||
+ | [[https:// | ||
+ | |||
==== Disk and Partition Stuff ==== | ==== Disk and Partition Stuff ==== | ||
Zeile 188: | Zeile 245: | ||
ssh user@src.example.com "cat / | ssh user@src.example.com "cat / | ||
</ | </ | ||
+ | |||
==== Conversion Stuff ==== | ==== Conversion Stuff ==== | ||
- | === make a big image small with ImageMagick === | + | === convert |
<code bash> | <code bash> | ||
+ | ## make a big image small | ||
convert big_input.tif -resize 256x256 small_output.png | convert big_input.tif -resize 256x256 small_output.png | ||
+ | ## make an image grayscale and remove any transparency | ||
+ | convert input.png -alpha deactivate -colorspace Gray output.png | ||
+ | ## create PNG with transparency from SVG, determine it's pixel dimensions from a DPI parameter | ||
+ | convert -background none -density 1200 input.svg output.png | ||
+ | ## create PNG with transparency from SVG, specify it's pixel dimensions directly | ||
+ | convert -background none -size 512x512 input.svg output.png | ||
</ | </ | ||
- | [[https:// | + | [[https:// |
+ | |||
+ | === batch convert | ||
+ | <code bash> | ||
+ | ### for JPGs | ||
+ | exiftool -ext jpg ' | ||
+ | mogrify -resize 375 -define preserve-timestamp=True *.JPG | ||
+ | ### for PNGs | ||
+ | exiftool -ext png ' | ||
+ | mogrify -resize 375 -define preserve-timestamp=True *.PNG | ||
+ | ### Comments: | ||
+ | ## the " | ||
+ | ## the " | ||
+ | ## for case-sensitive filesystems in the " | ||
+ | </ | ||
+ | [[https:// | ||
+ | |||
+ | === add rounded corners to an image (for app icon with rounded corners in the style of iPhone‘s SpringBoard) === | ||
+ | <code bash> | ||
+ | ### Adjust the corner radius (in pixel) to your needs. | ||
+ | ### For a 1024x1024 image a value of 128 looks good. | ||
+ | RADIUS=128 | ||
+ | |||
+ | ### The whole ImageMagick command is quite complex. The resulting rounded image is written to a new file. | ||
+ | ### The cascade of parenthesized options defines the operations to cut out the transparent arcs in the corners. | ||
+ | convert AppIconRaw.png \( +clone -alpha extract \ | ||
+ | \( -size ${RADIUS}x${RADIUS} xc:black -draw "fill white circle ${RADIUS}, | ||
+ | \( mpr:arc \) -gravity northwest -composite \ | ||
+ | \( mpr:arc -flip \) -gravity southwest -composite \ | ||
+ | \( mpr:arc -flop \) -gravity northeast -composite \ | ||
+ | \( mpr:arc -rotate 180 \) -gravity southeast -composite \) \ | ||
+ | -alpha off -compose CopyOpacity -composite AppIconRounded.png | ||
+ | </ | ||
+ | [[https:// | ||
+ | |||
+ | === Unix timestamp to human readable time === | ||
+ | <code bash> | ||
+ | ## with BSD date | ||
+ | date -r 1523210382 | ||
+ | ## with GNU date | ||
+ | date -d @1523210382 | ||
+ | </ | ||
+ | [[https:// | ||
=== format XML === | === format XML === | ||
Zeile 203: | Zeile 310: | ||
xmllint --noblanks input_pretty.xml > output_ugly.xml | xmllint --noblanks input_pretty.xml > output_ugly.xml | ||
</ | </ | ||
+ | [[https:// | ||
=== C array of the content of some file === | === C array of the content of some file === | ||
Zeile 208: | Zeile 316: | ||
xxd -i someFile.bin | xxd -i someFile.bin | ||
</ | </ | ||
- | [[https:// | + | [[https:// |
- | === Unix timestamp to human readable time === | + | === change the character encoding of a file‘s content |
- | < | + | < |
- | ## with BSD date | + | ## convert from " |
- | date -r 1523210382 | + | recode utf8...latin1 test.dat |
- | ## with GNU date | + | ## autodetect and convert to "ISO-8859-1" |
- | date -d @1523210382 | + | recode ..latin1 test.dat |
+ | ## list available encodings available in your " | ||
+ | recode --list | ||
+ | </ | ||
+ | [[https:// | ||
+ | |||
+ | === occurrences of non-ASCII characters in a file‘s content (with GNU grep) === | ||
+ | < | ||
+ | ggrep --color=' | ||
+ | </ | ||
+ | |||
+ | === occurrences of invalid UTF-8 characters in a file‘s content (this assumes you have an UTF-8 locale set) === | ||
+ | < | ||
+ | grep -axv ' | ||
+ | </ | ||
+ | [[https:// | ||
+ | |||
+ | === count how many time each byte value occurs in a file‘s content === | ||
+ | < | ||
+ | recode latin1/ | ||
</ | </ | ||
- | [[https:// | + | [[https:// |
==== Process Stuff ==== | ==== Process Stuff ==== |