User:Awebb

From ArchWiki

Careful with *NIX stuff on Windows!

rsync

Be careful with rsync --no-perms on Windows in Cygwin on NTFS, it will mess up the ownership so badly, that you will probably be unable to fix it via the GUI (rogue files). This doesn't seem to be a problem in WSL.

rogue files and file associations

If you've destroyed the Windows attributes of a file with some Cygwin or WSL stunt and cannot use the security tab of the properties GUI anymore, fix it with takeown /F.

As my Razer drivers recently taught me, groups/users regarding permissions in Windows and/or NTFS are sorted in some sort of hierarchy. Windows prompts you if you view the permissions tab in case anything is severely wrong. This might be security relevant.

Use assoc and ftype, if you've destroyed system wide file type associations. The user assocs are stored in [HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts]

integration

Use cygpath or wslpath to convert Windows paths to the respective Unix paths.

More Windows, partially useful in Wine

  • Numpad on in the #windows 8.1 and 10 login screen: Increment [HKEY_USERS\.DEFAULT\Control Panel\Keyboard\InitialKeyboardIndicators] twice.
  • Turn off automatic reboot in Windows 10 after an update: deactivate Task planner > \Microsoft\Windows\UpdateOrchestrator\Reboot.

Disable start menu web search

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Search]
 "BingSearchEnabled"=dword:00000000
 "CortanaConsent"=dword:00000000

Powershell

Environment

  • Set-Location Env: allows you to navigate the environment variables like a folder.
    • $env:property and $env:path are shortcuts.

Registry

{Get,Set,New}-Item{,Property} and Registry::HKEY... or HKCU:\..., HKLM:\...

Examples:

Get-Item Registry::HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Search
New-Item Registry::HKCU:\MyNewItem
Get-ItemProperty Registry::HKCU:\MyNewItem\

Linux stuff I wish I didn't forget all the time

bash

three forms of arithmetics

  • expr a + b (man 1 expr)
  • let c=a+b (man 1 bash ARITHMETIC EVALUATION)
  • c=$((a+b)) (man 1 bash)

declaring variables

  • declare/typeset/local declare local variables
  • local only works in a function and shows the local env without args
  • typeset is legacy

arrays

  • indexed arrays: declare -a
  • associative arrays: declare -A

last results

  • $? contains the result of the last command
  • echo $? will present boolean results from tests as 0 or 1

shells

  • Change your shell with chsh.
  • type > which
  • If groups is not enough, try id.
  • The Arch installer uses ZSH.
    • ZSH can echo $somearray, while bash will only echo the first element. Use ${somearray[@]} in bash.

sftp

  • prepending an "l" to a command might make it local instead of remote
    • lls, lcd, lpwd...
      • see sftp(1)

dotfiles and configs

  • Look at GNU-stow + git to manage dotfiles
  • Use etckeeper for soft-versioning and backing up /etc.

git

  • Git might refuse to push into a non-bare repository. "git config --bool core.bare true" and delete everything but ".git".

GUI of DOOM

  • C-w seems to be a hotkey to close the active document (like a browser tab) in many GUI programs. Not a good system wide hotkey.

CLI of DOOM

  • There are two common "rename" implementations, one from util-linux and one from perl-rename. Some distros ship perl-rename as rename. Not very portable => avoid.
    • vidir (coreutils) and mvim (AUR) are also worth a look.

Quick and dirty

python file server

Serve folder over HTTP:

cd somefolder
python -m http.server [PORT]

KODI

Path substitution

You can now override source paths (v18.3+): https://kodi.wiki/view/Path_substitution Example:

<advancedsettings>
 <pathsubstitution>
  <substitute>
    <from>special://profile/Thumbnails/</from>
    <to>PROTOCOL://YOUR_NETWORK_SHARE/Kodi/userdata/Thumbnails/</to>
  </substitute>
 </pathsubstitution>
</advancedsettings>

I use it to switch between a show folder on the Laptop for "on the run" and the general media server at home.