Skip to content

Instantly share code, notes, and snippets.

View techie2000's full-sized avatar

techie2000

  • Probably somewhere quiet
  • 01:00 (UTC +01:00)
View GitHub Profile
@techie2000
techie2000 / secureMySsh.sh
Last active May 5, 2023 19:20
Secure ssh related files an folder
#!/bin/bash
find $HOME/.ssh/ -type f -exec chmod 600 {} \;; find .ssh/ -type d -exec chmod 700 {} \;; find .ssh/ -type f -name "*.pub" -exec chmod 644 {} \;
To login to alpine Linux LXD vm from host use the lxc command:
lxc exec alpine-lxd-vm-name-here bash
Assumes you have bash installed on the VM - see install-bash.sh
@techie2000
techie2000 / WSL_SetupScript.ps1
Created May 30, 2022 17:41 — forked from crutkas/WSL_SetupScript.ps1
WSL_SetupScript.ps1
# Things to note
# Single script, will survive reboot
# Script needs to be run under admin (will auto correct if not)
# Script needs internet access to download files
# Script assumes WinGet is installed
#
# Why aren't we using wsl --install -d Ubuntu
# Well, we want to WSL.exe install a bunch of stuff
# Ubuntu2004 install --root can't be done above so it requires user interaction
# if you don't need to install items on linux without setting root, this script becomes much simplier
@techie2000
techie2000 / RegEditSuite.psm1
Created May 27, 2022 15:30 — forked from cameronove/RegEditSuite.psm1
PowerShell module to manage Windows Registry.
<#
2010 Scripting Games PowerShell: Advanced Event 1
Author: Cameron Ove
Date: 4/30/2010
Copyright: NONE :-D
Synopsis of functions:
I really wanted to the ability to provide credentials when contacting remote workstations.
.Net seems limited in that regard. So I used WMI.
In paticular I used the root\default namespace and StdRegProv thus enabing the ability for credentials across the network.
@techie2000
techie2000 / KnownFolderPathPS5.ps1
Last active May 27, 2022 08:17 — forked from YoraiLevi/KnownFolderPathPS5.ps1
Change windows user folders with powershell
<#
.SYNOPSIS
Requires powershell 5 or later
Provides Get and Set functions for KnownFolders
.EXAMPLE
PS> Set-KnownFolderPath Desktop $ENV:USERPROFILE/Desktop
.EXAMPLE
PS> $Path=""
PS> Get-KnownFolderPath Desktop ([ref]$Path)
.LINK
@techie2000
techie2000 / filesize_histogram
Created March 24, 2022 19:47
histogram of file sizes, and how many files are in that size range.
find . -type f -print0 | xargs -0 ls -l | awk '{ n=int(log($5)/log(2)); if (n<10) { n=10; } size[n]++ } END { for (i in size) printf("%d %d\n", 2^i, size[i]) }' | sort -n | awk 'function human(x) { x[1]/=1024; if (x[1]>=1024) { x[2]++; human(x) } } { a[1]=$1; a[2]=0; human(a); printf("%3d%s: %6d\n", a[1],substr("kMGTEPYZ",a[2]+1,1),$2) }'
--e.g.
-- 1k: 270448
-- 2k: 72548
-- 4k: 74510
-- 8k: 62799
-- 16k: 36386
-- 32k: 74070
-- 64k: 21528
@techie2000
techie2000 / showhardlinks.sh
Created July 7, 2021 07:38
Show hardlinks in a nicely formated fashion
@techie2000
techie2000 / noHardlink.sh
Created July 7, 2021 07:31
Find files with no hardlinks
@techie2000
techie2000 / safe_perms.sh
Created July 4, 2021 19:45
Setting safe directory/file permissions
# for directories: rwxr_xr_x
find . -type d -exec chmod 755 {} \;
# for files : rw_r__r__
find . -type f -exec chmod 644 {} \;
# or wrap it in one command
find YOUR_CATALOG -type f -exec chmod 644 {} + -o -type d -exec chmod 775 {} +
apt list --installed
# or
dpkg -l