IPMI
March 26, 2021 — 20:06

Author: silver  Category: hardware linux windows  Comments: Off

Intelligent Platform Management Interface

  • Linux kernel module: ipmi_devintf
  • Debian packages: apt install openipmi ipmitool

ipmitool

Get info:

ipmitool lan print
ipmitool user list
ipmitool channel getaccess 1

Add new user and permissions:

ipmitool user set name 3 myusername
ipmitool user set password 3 <password> 16
ipmitool channel setaccess 1 3 link=on ipmi=on callin=on privilege=4
ipmitool test 3 16 <password>

* where ‘3’ is user id and ’16’ is length of password

SuperMicro

  • IPMIView is a GUI app specific to SM BMC (Linux/Windows)
  • Since 2019 the default "ADMIN" password is no longer used
  • Every device now has a "Unique BMC Password" printed on sticker (pdf)
  • ADMIN user has id 2
Partitions
January 22, 2021 — 17:21

Author: silver  Category: linux windows  Comments: Off

Linux

Create new partition with parted:

# mbr
parted /dev/sda mklabel msdos
parted /dev/sda mkpart primary ext4 0% 100%

# gpt
parted /dev/sda mklabel gpt
parted /dev/sda mkpart part-label ext4 0% 100%

Note that ‘part-label’ cannot be empty, to remove: fdisk /dev/sda x n <enter> r w

To resize: parted /dev/sdX then resizepart X

Clone MBR partition table:

Use sfdisk:

sfdisk -d /dev/sda > partitions.txt
sfdisk /dev/sdb < partitions.txt

sfdisk -d /dev/sda | sfdisk /dev/sdb
sfdisk -d /dev/sda | sfdisk --force /dev/sdb

Clone GPT partition table:

  • use sgdisk
  • or gdisk

Windows

Partitioning tools:

  • diskpart (cli)
  • diskmgmt.msc
  • Minitool Partition Wizard (3rd party)
  • EaseUS Partition Master (3rd party)

Scoop
February 14, 2020 — 14:49

Author: silver  Category: dev windows  Comments: Off

Besides Chocolatey there’s also https://scoop.sh. A more "dev" oriented package manager for Windows PowerShell.

It installs "UNIXy" packages such as Git, cURL and vim. Languages such as Perl, PHP Python and Go are available just like Apache, Nginx and MySQL. Packages are installed into your homedir/profile, no UAC needed or changing PATH env var.

Password Managers
December 11, 2019 — 15:34

Author: silver  Category: encryption linux windows  Comments: Off

There are basically 3 different categories to choose from, depending on location of service and db: Local, "Cloud"/SaaS or selfhosted On-Premise.

For single user/home usage KeePass is fine or perhaps even the password manager included in web browsers. Using one of the SaaS options such as LastPass adds ease of access.

For company/enterprise usage sharing passwords in groups/teams should be supported and preferably an on-prem option.

PowerShell
July 9, 2019 — 9:17

Author: silver  Category: dev linux windows  Comments: Off

I’ve been using PS for a while now and I don’t hate it anymore :) In fact I think it’s very usable for lots of tasks and automation.

Some Useful commands:

  • Get-Command *help* or Get-Command-Module PackageManagement
  • Get-Member to view properties e.g. Get-Disk | Get-Member
  • Get-Alias
  • Get-ExecutionPolicy -List
  • Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
  • piping to select, sort and where
  • Invoke-WebRequest $url

CSV, XML and JSON support is included:

  • Import-CSV Export-CSV
  • ConvertTo-XML
  • ConvertFrom-Json ConverTO-Json

And stuff like:

  • Logging sessions: Start-Transcript Stop-Transcript
  • Viewing Certificates: cd Cert:\ (now you can ‘dir’ etc)
  • Run as admin: powershell.exe -Command "Start-Process cmd -Verb RunAs"
  • PS Linting: https://github.com/PowerShell/PSScriptAnalyzer

Remote usage is also possible over WinRM (or OpenSSH):

  • Enter-PSSession -ComputerName <host>

Then there’s Loops, Params, Arrays and Hash Tables e.g. foreach, Param([string]$arg), @() and @{}

More info:

Chocolatey
December 8, 2018 — 18:19

Author: silver  Category: windows  Comments: Off

Chocolatey is a CLI based package manager for Windows

https://chocolatey.org
https://chocolatey.org/packages
https://github.com/chocolatey

Install:

choco install <pkg>

Search:

choco search <pkg> [-l] for local pkgs

List upgradable pkgs:

choco outdated

Upgrade options:

choco upgrade <pkg> --reinstall
choco upgrade <pkg> --force
choco upgrade <pkg> --[checksum|checksum64]

Upgrade all:

FOR /F "delims=|" %i IN ('choco outdated -r') DO ( @choco upgrade %i )

Using parameters:

choco install nvidia-display-driver --params="'/FOO /BAR'"

Log:

C:\ProgramData\chocolatey\logs\chocolatey.log

GUI:

https://github.com/chocolatey/ChocolateyGUI
Install with chocolatey: choco install chocolateygui

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

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.

Windows 10 Licensing
August 23, 2017 — 14:40

Author: silver  Category: windows  Comments: Off

Product Key can now be a “Digital License”. This seems to be true for upgraded Windows 7 keys.
To prevent activation issues after hardware changes: link MS account to digital license asap (Settings > Accounts).

View current license:

slmgr.vbs /dlv
wmic path softwarelicensingservice get OA3xOriginalProductKey

powershell "(Get-WmiObject -query 'select * from SoftwareLicensingService').OA3xOriginalProductKey"

Update product key:

run slui.exe or goto Settings > Activation

MS Activation servers:

activation-v2.sls.microsoft.com
validation-v2.sls.microsoft.com

More info:

https://support.microsoft.com/en-us/help/20530/windows-10-reactivating-after-hardware-change

Windows Uptime
August 23, 2017 — 14:07

Author: silver  Category: windows  Comments: Off

How to find out Windows Uptime?

Using PowerShell:

powershell ((Get-Date) - (gcim Win32_OperatingSystem).LastBootUptime).ToString('g')
powershell ((Get-Date) - ([wmi]'').ConvertToDateTime((Get-WmiObject win32_operatingsystem).LastBootUpTime)).ToString("dd' days 'hh\:mm\:ss")

Also, I cobbled together this little script that looks like the Linux uptime cmd. It’s embedded in a batch file so for ease of running (https://blogs.msdn.microsoft.com/jaybaz_ms/2007/04/26/powershell-polyglot/ for more info). Gist: https://git.io/v5tx0.

@PowerShell -ExecutionPolicy RemoteSigned -Command Invoke-Expression $('$args=@(^&{$args} %*);'+[String]::Join(';',(Get-Content -LiteralPath '%~f0') -notmatch '^^@PowerShell.*EOF$')) & goto :EOF

$d = Get-Date
$upTime = (($d) - ([wmi]'').ConvertToDateTime((Get-WmiObject win32_operatingsystem).LastBootUpTime)).ToString("d' days,  'h\:mm")
$ActiveUsers = @()
foreach($User in (Get-WmiObject Win32_LoggedOnUser).Antecedent) { $ActiveUsers += $User.Substring($User.LastIndexOf('=') + 2, $User.Length - $User.LastIndexOf('=') -3) }
$UserText = "$($ActiveUsers.Count) user"
if ( $ActiveUsers.Count -gt 1 ) { $UserText += "s" }
$TotalProcTime = (Get-Counter "\Processor(_total)\% Processor Time") | foreach {$_.CounterSamples[0].CookedValue}

Write-Host -NoNewLine (" {0}, up {1},  {2},  total proctime: {3}%" -f $d.toString("HH:mm:ss"), $upTime, $UserText, [math]::Round($TotalProcTime,2))

Output looks like this:

C:\Users\silver>uptime
 14:45:41, up 5 days,  20:15,  3 users,  total proctime: 2,26%

 

GUI (Windows 10):

Task Manager (taskmgr) > More details > Performance tab > CPU

Boot Time:

net stats <workstation/server>
systeminfo | findstr "System Boot Time"

Anti-Malware Software
March 4, 2017 — 15:55

Author: silver  Category: windows  Comments: Off

Windows Anti-Malware Software:

Start program if not running
March 3, 2017 — 12:55

Author: silver  Category: windows  Comments: Off

Check if a program if not already running before starting it in a Windows batch file.
Uses C:\Windows\System32\find.exe (findstr should work equally well).

Example:

tasklist /nh /fi "imagename eq explorer.exe" | find /i "explorer.exe" > nul || ( start "" C:\WINDOWS\explorer.exe )

Function:

:func_runImageTask
  tasklist /nh /fi "imagename eq %~1" | find /i "%~1" > nul || ( start "" "%~2" )
GOTO :EOF

Function using window titles:

:func_runTitleTask
  tasklist /v | find "%~1" > nul || ( start "" "%~2" )
GOTO :EOF

Call function:

CALL :func_runImageTask "Calculator.exe" "C:\WINDOWS\System32\calc.exe"
CALL :func_runTitleTask "Calculator" "C:\WINDOWS\System32\calc.exe"

From:

  • http://superuser.com/questions/654088/start-programs-via-command-line-but-only-if-not-already-running
  • http://stackoverflow.com/questions/162291/how-to-check-if-a-process-is-running-via-a-batch-script
  • http://stackoverflow.com/questions/15449034/batch-program-to-to-check-if-process-exists
  •  


     

    This batch file takes program names (IMAGENAMES variable) or window titles (WINDOWTITLES and starts them if they are not already running. Programs can have arguments (e.g. outlook.exe).

    ReOpen.bat

    
    ::
    :: ReOpens programs which are not already running 20161220 slv
    ::
    
    @echo off
    setLocal EnableDelayedExpansion
    
    ::
    :: Configure programs here making sure to use ,^ at eol for continuation
    ::
    
    SET IMAGENAMES=^
     "chrome.exe,C:\Program Files (x86)\Google\Chrome\Application\chrome.exe",^
     "Xshell.exe,C:\Program Files (x86)\NetSarang\Xshell 5\Xshell.exe",^
     "outlook.exe,C:\Program Files\Microsoft Office\Office14\OUTLOOK.EXE,/recycle"
    
    FOR %%x in (%IMAGENAMES%) DO (
      FOR /f "tokens=1-3 delims=," %%a in (%%x) do (
        CALL :func_runImageTask "%%a" "%%b" "%%c"
      )
    )
    
    SET WINDOWTITLES=^
      "www@webserver,C:\Program Files (x86)\PuTTY\putty.exe,-load webserver",^
      "user@debian,C:\Program Files (x86)\PuTTY\putty.exe,-load debian"
    
    FOR %%x in (%WINDOWTITLES%) DO (
      FOR /f "tokens=1-3 delims=," %%a in (%%x) DO (
        CALL :func_runTitleTask "%%a" "%%b" "%%c"
      )
    )
    
    GOTO :EOF
    
    :func_runImageTask
      tasklist /nh /fi "imagename eq %~1" | %windir%\system32\find.exe /i "%~1" > nul || ( start "" "%~2"^ %~3 )
    GOTO :EOF
    
    :func_runTitleTask
      tasklist /v | %windir%\system32\find.exe "%~1" > nul || ( start "" "%~2"^ %~3 )
    GOTO :EOF
    
    ::
    :: Examples:
    ::
    :: MANUAL: tasklist /nh /fi "imagename eq explorer.exe" | %windir%\system32\find.exe /i "explorer.exe" > nul || ( start "" C:\WINDOWS\explorer.exe C:\Users\%USERNAME%\Desktop )
    :: FUNCTION: CALL :func_runImageTask "Calculator.exe" "C:\WINDOWS\System32\calc.exe"
    ::
    
    Windows SSH Clients
    January 21, 2017 — 17:39

    Author: silver  Category: windows  Comments: Off

    I’ve been searching for an alternative for plain PuTTY for a while now.

    My requirements are:

    • free, preferably open source
    • in active development
    • ssh-agent
    • GUI
    • Tabs
    • Window transparency

    I’ve looked at the following:

    • PuTTY based:
      • MTPuTTY, KiTTY, PuTTYTray (https://puttytray.goeswhere.com) etc
      • mRemoteNG, PuTTYCM, PuTTYTabManager, PuTTYMan, SuperPuTTY, …
    • Cygwin + OpenSSH (no GUI)
    • SecureCRT (not free)
    • ConEmu (https://conemu.github.io) + PuTTY
    • XShell (https://www.netsarang.com/products/xsh_overview.html)

    However none of them work flawlessly (I probably have used ConEmu and PuTTY the longest).
    Currently I’m using XShell instead which is it’s own thing instead of being PuTTY based.
    I also still use PuTTYTray which is one of the more useful PuTTY derivatives (eg transparency, tray, cygterm and can save sessions to file).

    Update: I’ve forked over the cheese and completely switched to XShell. I also use (the free version of) Xftp more and more.
    These are supposed to be good alternatives too and I might look at them in the future:

    • Poderosa

    Jan 2017: Just noticed Termius (previously Serverauditor) which I use on iOS – to my full satisfaction – will be getting a Windows version.

    Dec 2018: There’s also Hyper, an Electron and node.js based alternative: https://hyper.is. It supports tabs and can be extended with plugins. Imo it’s a bit resource heavy and can get sluggish with many tabs and plugins loaded, but not bad.. not bad.

    Jun 2019: Been using the quite nice MobaXterm at work the past few months. It’s basically a tabbed GUI around PuTTY with Cygwin and X11 support etc. I use it with WSL for local terminals and that’s been working well for me.

    Aug 2019: Microsoft finally decided to offer the competent Windows Terminal. Tabs, colors, theming, supports both Cmd and PS… and ssh works fine. Very useful. This is what I now use as Windows Console and for WSL. Also still using XShell 6.

    Windows 2012 Core
    December 10, 2016 — 0:04

    Author: silver  Category: windows  Comments: Off

    PS = Run in Powershell

    System config:

    sconfig
    netdomf

    slmgr.vbs /skms kms.domain.local:1688

    wmic product
    wmic softwarefeature list brief

    # PS:
    wmi Win32_SoftwareFeature | Select ProductName, Caption, Version | ft *
    # change name
    Rename-Computer
    # remove from domain & reboot
    Remove-Computer -credential domain\account -passthru -verbose -force
    Restart-Computer
    

    Diskpart:

    list disk
    select disk X

    If disk is set as read-only, first run:
    attributes disk clear readonly

    create partition primary (or size = )
    select partition X
    format fs=ntfs quick
    assign
    list volume
    select volume X
    remove letter=D
    assign letter=L

    Network:

    # PS:
    Get-NetIPInterface
    New-NetIPAddress -InterfaceIndex 12 -IPAddress 192.0.2.2 -PrefixLength 24 -DefaultGateway 192.0.2.1
    Set-DNSClientServerAddress -InterfaceIndex 12 -ServerAddresses 192.0.2.4,192.0.2.5
    

    netsh interface ip set address name="Local Area Connection" static 10.94.45.213 255.255.255.224 10.94.45.193

    Firewall:

    netsh advfirewall set allprofiles state off
    netsh advfirewall set allprofiles state on

    RDP:

    # PS:
    Get-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server' -name 'fDenyTSConnections'
    Get-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -name 'UserAuthentication'
    Get-netfirewallrule -DisplayGroup 'Remote Desktop' | ft -autosize  Name, Enabled
    New-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server' -name 'fDenyTSConnections' -Value 0 -PropertyType dword
    New-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -name 'UserAuthentication' -Value 1 -PropertyType dword
    Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server' -name 'fDenyTSConnections' -Value 0
    Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -name 'UserAuthentication' -Value 1
    Enable-NetFirewallRule -DisplayGroup 'Remote Desktop'
    

    Task Scheduler:

    schtasks /create /tn 'Task Name' /tr 'D:\Dir\file.exe' /ru DOMAIN\user /rp /sc daily /st 03:30
    schtasks /change /tn 'Task Name' /ru DOMAIN\user
    schtasks /delete /tn 'Task Name'
    schtasks /run /tn 'Task Name' /i
    schtasks /query /fo table /nh
    schtasks /query /tn 'Task Name' /fo list /v
    

    Telnet:

    # PS:
    Import-Module servermanager
    Add-WindowsFeature telnet-client
    

    TS Share:

    # PS:
    cd \\tsclient\c
    
    Windows Disk Encryption
    November 26, 2016 — 14:35

    Author: silver  Category: encryption windows  Comments: Off

    Before I chose to replace TrueCrypt with VeraCrypt I was looking for/comparing alternatives.
    I also use Bitlocker and EFS that are included with Windows.

    Except for DiskCryptor and LibreCrypt all these programs also run on Linux.

    More here: http://www.surfsafely.com/truecrypt-alternatives

    Compile PuTTY under Cygwin
    November 25, 2016 — 17:16

    Author: silver  Category: windows  Comments: Off
    1. Download dev snapshot:
    gpg --verify putty-src.zip.gpg putty-src.zip
    grep $( sha512sum putty-src.zip ) sha512sums
    
    1. Run the compile.sh script below
    #!/bin/sh
    
    echo
    echo "putty needs the following pkgs under cygwin64:"
    echo "mingw64-x86_64-headers w32api w32api-headers"
    echo
    #export PERL5LIB=/usr/lib/perl5/5.22/CPAN
    perl mkfiles.pl
    sed -i.bak 's/^M//g' licence.h
    make distclean
    cd windows
    make clean -f Makefile.mgw
    
    make -j4 \
    TOOLPATH="x86_64-w64-mingw32-" \
    CFLAGS="-Wall -O2 -D_WINDOWS -DDEBUG -DWIN32S_COMPAT -D_NO_OLDNAMES -I.././ \
    -I../charset/ -I../windows/ -I../unix/ \
    -D_WIN32_IE=0x0500 \
    -DWINVER=0x0500 -D_WIN32_WINDOWS=0x0410 -D_WIN32_WINNT=0x0500 \
    -DNO_MANIFESTS" \
    LDFLAGS="-s" \
    RCFLAGS="--define WIN32=1 --define _WIN32=1 --define WINVER=0x0400 \
    -I.././ -I../charset/ -I../windows/ -I../unix/" \
    COMPAT="-DWINSOCK_TWO -DNO_MULTIMON" \
    -f Makefile.mgw
    

    It’s also possible to make with version variables:

    make VER="-DSNAPSHOT=$(date '+%Y-%m-%d') -DSVN_REV='$(svnversion)' -DMODIFIED" TOOLPATH=i586-mingw32msvc- -f Makefile.cyg putty.exe
    
    Deleting songs in iTunes
    May 2, 2015 — 21:21

    Author: silver  Category: windows  Comments: Off

    From http://lifehacker.com/5917787/how-to-delete-a-song-from-your-itunes-library-from-the-playlist-view

    How to Delete a Song from Your iTunes Library from the Playlist View

    If you find a song in one of your iTunes playlists that you no longer want, you
    usually have to go all the way back to the “Music” view and find it inorder to
    delete it. This keyboard shortcut saves you the hassle, deleting the item right
    from the playlist view.

    Ordinarily, pressing the delete key while in a playlist will only prompt you to
    remove the song from that playlist. If you want to remove it from yourlibrary
    entirely, just press Shift+Delete (on Windows) or Option+Delete (on OS X), and
    you’ll get the prompt to remove the song from your libraryentirely. Pretty handy
    for us playlist junkies.

    From http://trevinchow.com/blog/2010/01/03/deleting-song-in-itunes-library-from-within-a-playlist/

    So when you’re in an iTunes playlist and want to remove the song from the playlist only, use Delete. If you want to remove it from both the playlist AND your iTunes Library, use Shift+Delete !

    (There is also another undocumented shortcut – CTRL + SHIFT + Delete which will do the same thing as Shift+Delete except it will add an extra confirmation for sending the file to the recycle bin. Since you already get one prompt using Shift+Delete, there’s no reason for this extra step)

    MySQL
    October 14, 2014 — 16:37

    Author: silver  Category: linux windows  Comments: Off

    Show databases:

    mysql -u root -p -e 'show databases;'
    

    Create new database:

    CREATE database username
    GRANT ALL ON username.* TO 'username'@'localhost' IDENTIFIED BY 'password';
    

    Create admin user:

    $ mysql --user=root -p mysql
    CREATE USER 'admin'@'localhost' IDENTIFIED BY 'KNOWNPW';
    GRANT ALL PRIVILEGES ON *.* TO 'admin'@'localhost' WITH GRANT OPTION;
    

    Password reset root user:

    Linux:

    $ /etc/init.d/mysql stop
    $ mysqld_safe --skip-grant-tables 
    $ mysql --user=root mysql
    
    SELECT * FROM user;
    
    update user set Password=PASSWORD('MyNewPass') where user='root';
    flush privileges;
    exit
    
    $ /etc/init.d/mysql start
    

    Windows:

    C:\mysql\bin\mysqld-nt --init-file=C:\\mysql-init.txt --console
    UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root';
    FLUSH PRIVILEGES;
    

    Various:

    (run mysql interactively)

    Set password hash:

    set password for 'root'@'localhost' = '*H4SHH4SHH4SHH4SHH4SHH4SHH4SHH4SHH4SHH4SH';
    

    Show user:

    SELECT user, host FROM mysql.user WHERE user='root'
    

    List databases/tables:

    SHOW databases;
    SHOW tables;
    

    Import from cli:

    source path/to/file.sql;
    

    INSERT IF NOT EXISTS:

    INSERT IGNORE INTO

    Dump binary data

    use option --hex-blob

    Windows 32 or 64 bit executable
    January 21, 2014 — 17:48

    Author: silver  Category: windows  Comments: Off

    PE header:

    "PE..L" (hex: 504500004C) = 32 bit
    "PE..d†" (hex: 504500006486) = 64 bit
    Windows add to “Send To”
    January 21, 2014 — 17:43

    Author: silver  Category: windows  Comments: Off

    Create shortcut here:

    %UserProfile%\AppData\Roaming\Microsoft\Windows\SendTo
    shell:sendto
    C:\Users\USER\AppData\Roaming\Microsoft\Windows\SendTo
    PuTTY Window Colours
    January 21, 2014 — 17:38

    Author: silver  Category: windows  Comments: Off

    Green fg text and a readable blue:

    R
    G
    B

    Default Foreground:
    0
    255
    0

    Default Bold Foreground:
    106
    255
    106

    ANSI Blue:

    Colour 14
    64,64,255

    64
    64
    255

    ANSI Blue Bold:

    Colour 15
    94,94,255

    94
    94
    255

    Robocopy
    January 20, 2014 — 22:52

    Author: silver  Category: windows  Comments: Off

    My Documents C: -> D:

    robocopy "C:\Users\silver\Documents" "D:\backups\Documents" /copyall /efsraw /mir /sl /zb

    D: -> E:

    for %i in (dir1 dir2 dir2) do robocopy D:\%i E:\%i /copyall /mir /sl /zb /MT:128 /XD_exclude_this_dir

    /XD dirs [dirs]… :: eXclude Directories matching given names/paths.

    For loop Windows cmdline
    June 22, 2012 — 20:19

    Author: silver  Category: windows  Comments: Off
    C:\>for /f %i IN ('dir /b') do echo %i
    C:\>for /f %i IN (bla.txt) do echo %i
    Wipe SSD/HDD
    March 19, 2012 — 12:27

    Author: silver  Category: hardware linux windows  Comments: Off

    Linux:

    First check the drive (see if erase operations are supported):

    # hdparm -I /dev/X 
    
    # hdparm --user-master u --security-set-pass Password /dev/X
    
    # time hdparm --user-master u --security-erase Password /dev/X
    

    or (if supported):

    # time hdparm --user-master u --security-erase-enhanched Passwrd /dev/X
    

    Works also for HDD’s.

    More info:
    https://ata.wiki.kernel.org/articles/a/t/a/ATA_Secure_Erase_936d.html
    https://www.thomas-krenn.com/en/wiki/SSD_Secure_Erase

    Alternatively boot into Parted Magic and use GUI.

    Windows/DOS:

    http://cmrr.ucsd.edu/people/Hughes/SecureErase.shtml








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