GNU find
March 30, 2018 — 14:51

Author: silver  Category: linux windows  Comments: Off

Just a few useful ‘find’ examples

Exclude:

find . -path ./foo -prune -o -name bar
find /home \( -path /usr/data -prune -o -path /usr/src \) -prune -o -name foo -print
find . -name Makefile -not -path foo
find . -type d ! -regex .*\/\(foo\|bar\).* \;

Permissions:

find . -perm -775
find . -perm /u+w,g+
find . -printf "%m:%f\n"
find . -printf "%m %h/%f\n"|grep -v '^\(644\|755\)'

Print date:

find -type f -printf '%TF %.8TT %p\n'

Windows:

find.exe . -name *.exe -exec certutil -hashfile {} SHA512 ; >c:\hash.txt

Python 3
March 30, 2018 — 14:26

Author: silver  Category: dev  Comments: Off

Print modules:

python3 -c "import sys;print (sys.path)"
python3 -c "import sys;print (sys.modules)"
python3 -c "help('modules')"
python3 -c "help('modules package')"
pydoc3 modules

Packages:

  • Location in Debian: /usr/lib/python{3}/dist-packages/pkgname/{__init__.py}
  • Other distro’s use “site-packages”

pip3 install pkgname
pip3 uninstall pkgname
pip3 freeze
python3 -m pip install pkgname

python3
import pip
sorted(["%s==%s" % (i.key, i.version) for i in pip.get_installed_distributions()])

Virtualenv:

$ pip3 install virtualenv
$ mkdir workdir && cd workdir
$ virtualenv project
$ source project/bin/activate
$ pip3 install requests

(and/or git clone + python3 setup.py install / etc)

$ deactivate
$ rm -rf project

Strings:

Besides %-format  and str.format() there’s now also f-Strings (since Python 3.6).

Example:

foo="value"

print(f'This string has a variable: {foo}.')

Notes:

  • make sure your script.py does not have the same name as package
  • print syntax changed from python2 to 3: print ("foo")
Perl
March 30, 2018 — 9:50

Author: silver  Category: dev  Comments: Off

List installed modules:

Pick one :)

  • perl -V
  • perldoc <module name>
  • perldoc perllocal
  • instmodsh
  • cpan -[l,a]

or:

perl -e 'use ExtUtils::Installed; foreach (ExtUtils::Installed->new()->modules()) {print $_ . "\n";}'

Install modules in homedir:

  • install “local::lib” module
  • print settings: perl -Mlocal::lib
  • add to .bashrc: eval "$(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib)"

Then there’s also “Perlbrew“.

Updating CPU Microcode
March 28, 2018 — 12:50

Author: silver  Category: hardware linux windows  Comments: Off

BITS

Tool from Intel called “BIOS Implementation Test Suite”. Bootable (usb) image which can do several things including handling microcode:


Linux

load/update microcode using pkg:

Debian

  • Intel: apt install intel-microcode iucode-tool
  • AMD: apt install amd64-microcode
  • Doc: /usr/share/doc/{intel,amd64}-microcode/README.Debian.gz

CentOS/RH

load/update intel microcode manually:

  • get latest tgz from intel: see below
  • backup/copy files: /lib/firmware/intel-ucode
  • check kernel config: grep MICROCODE /boot/config-*
  • run iucode_tool:
    /usr/sbin/iucode_tool -tb -lS /lib/firmware/intel-ucode/*
  • update initramfs: update-initramfs -u -k all

reloading microcode:

  • echo 1 > /sys/devices/system/cpu/microcode/reload
  • or: rmmod cpuid; modprobe cpuid

show version:

  • dmesg | grep microcode
  • grep microcode /proc/cpuinfo

skip loading microcode on boot:

  • add to grub cmdline: dis_ucode_ldr


Windows

Microsoft includes microcode updates in Windows for certain CPU’s. For example: KB4090007, KB3064209, KB2970215.

load/update microcode:

show version:

  • get hwinfo64 and goto “Central Processor(s)” > “Microcode Update Revision”
  • or get “Read & Write Everything” (RWEverything) from http://rweverything.com


Get Microcode

Download the latest version from Intel:
https://downloadcenter.intel.com/download/27431/Linux-Processor-Microcode-Data-File?v=t.

Windows IPv6 tunnel
March 28, 2018 — 11:39

Author: silver  Category: network windows  Comments: Off

How to create a 6to4 tunnel in Windows using CLI (for use with HE’s free Tunnel Broker service for example).

netsh interface teredo set state disabled
netsh interface ipv6 add v6v4tunnel TunnelName  
netsh interface ipv6 add address TunnelName 2001:a:b:c::2
netsh interface ipv6 add route ::/0 TunnelName 2001:a:b:c::1

Where:

  • “2001:a:b:c::” is your prefix
  • “2001:a:b:c::1” is the gateway
  • “2001:a:b:c::2” is your ipv6 address

Delete the tunnel:

netsh interface ipv6 delete address TunnelName 2001:a:b:c::2
netsh interface ipv6 delete route ::/0 TunnelName 2001:a:b:c::1
netsh interface ipv6 delete interface TunnelName

A HE tunnel can be requested here: https://tunnelbroker.net.








We use Matomo free and open source web analytics
We also use Jetpack WordPress.com Stats which honors DNT