Turn On/Off display monitor windows API
To turn off monitor in Windows, SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, (LPARAM)2) is most widely used.
Instead, we can use low-level monitor configuration functions.
Create Swapfile on CentOS
adopted from Tutorial of Digitalocean
1. dd if=/dev/zero of=/swapfile count=4096 bs=1MiB
2. chmod 600 /swapfile
3. mkswap /swapfile
4. swapon /swapfile
+ Add「/swapfile swap swap sw 0 0」in /etc/fstab
BitLocker with CMD
To lock the volume,
C:\>manage-bde -lock [volume]
To unlock the volume,
C:\>manage-bde -unlock -pw [volume]
otp helper script for oathtool
Moved to WordPress
Blogs are now moved to WordPress.
How to prevent resizing terminal when using screen
# Long time I had this in my private screenrc file. But many people
# seem to want it (jw):
# we do not want the width to change to 80 characters on startup:
# on suns, /etc/termcap has :is=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;3;4;6l:
#termcap xterm ‘is=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;4;6l’
#terminfo xterm ‘is=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;4;6l’
in /etc/screenrc
RDP Wrapper Library
Remote Desktop Protocol (RDP) is a graphical interface protocol to connect to server over internet connection, developed by Microsoft.
However, there is a restriction on the number of connections simultaneously. (except windows server)
This limitation, can be solved by RDP Wrapper Library.
https://github.com/stascorp/rdpwrap
And ini updater can be found here
https://github.com/asmtron/rdpwrap/blob/master/binary-download.md
Turn on/off mobile hotspot on windows 10 via powershell
To turn on mobile hotspot:
PS C:\> [Windows.Networking.NetworkOperators.NetworkOperatorTetheringManager,Windows.Networking.NetworkOperators,ContentType=WindowsRuntime]::CreateFromConnectionProfile([Windows.Networking.Connectivity.NetworkInformation,Windows.Networking.Connectivity,ContentType=WindowsRuntime]::GetInternetConnectionProfile()).StartTetheringAsync()↵
To turn off mobile hotspot:
PS C:\> [Windows.Networking.NetworkOperators.NetworkOperatorTetheringManager,Windows.Networking.NetworkOperators,ContentType=WindowsRuntime]::CreateFromConnectionProfile([Windows.Networking.Connectivity.NetworkInformation,Windows.Networking.Connectivity,ContentType=WindowsRuntime]::GetInternetConnectionProfile()).StopTetheringAsync()↵
Windows Equivalents for Chown and Chmod
TAKEOWN [/S system [/U username [/P [password]]]] /F filename [/A] [/R [/D prompt]]
Description:
This tool allows an administrator to recover access to a file that
was denied by re-assigning file ownership.
Parameter List:
/F – Specifies the filename or directory name pattern.
/A – Gives ownership to the administrators group instead of the current user.
/R – Recurse: instructs tool to operate on files in specified directory and all subdirectories.
Examples:
TAKEOWN /?
TAKEOWN /F * /R /A
ICACLS name [/grant[:r] Sid:perm[…]]
Description:
Sid:perm grants the specified user access rights.
Parameter List:
/T – Recurse
Permission List:
N – no access
F – full access
M – modify access
RX – read and execute access
R – read-only access
W – write-only access
D – delete access
Examples:
ICACLS /?
ICACLS * /grant “Administrators:(F)” /T