Appunti Vari LINUX

##CUSTOM ALIAS SHELL (~/.bashrc):
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval “$(dircolors -b ~/.dircolors)” || eval “$(dircolors -b)”
alias ls=’ls –color=auto’
alias Ssh=’ssh -o HostKeyAlgorithms=ssh-dss -o KexAlgorithms=diffie-hellman-group14-sha1 ‘
alias ping=’ping -O’
alias Ping=’ping -a -O’
#alias dir=’dir –color=auto’
#alias vdir=’vdir –color=auto’
fi

##VIRTUALBOX REBUILD MODE:
sudo dpkg-reconfigure virtualbox-dkms
——————————————

##SSH CONNECTION MY SHELL:
– SSH Nuovo protocollo:
ssh -l root 192.168.XXX.XXX
– SSH Vecchio protocollo:
Ssh root@192.168.XXX.XXX
——————————————

##MC LOCAL CONNECTION:
MC left pc -> F9 – Shell link.. – root@192.168.XXX.XXX
——————————————

##RASPBERRY CONFIGURATION:
autostart.sh -> remmina -c /home/pi/RDP.remmina
——————————————
##GRUTILITY CRASH
/etc/init.d/apache2 start
——————————————
##ENABLE CONNECT SSH:
passwd root
systemctl stop iptables
——————————————
##MOUNT:
mkdir /mnt/usb
mount -t vfat /dev/sdb1 /mnt/usb
ntfs-3g /dev/sda1 /mnt/windows
——————————————
##CHANGE PSW WINDOWS:
cd Windows/System32/config
chntpw -l SAM (o sam)
chntpwd -u Administrator SAM
2
q
y
——————————————
##CLONE:
Clonazione disco (pv=avanzamento)
dd if=/dev/sda | pv | dd of=/dev/sdb

Clonazione da disco grande a piccolo
– Gparted -> Resize e poi spostare partizione di recupero lasciando spazio vuoto alla fine
– Usare il dd
– gdisk -> w -> y
– riporto disco normale

# backup
dd if=/dev/hdx | gzip > /path/to/image.gz

# restore
gzip -dc /path/to/image.gz | dd of=/dev/hdx

——————————————
Clonazione disco RESCUE
ddrescue -r2 -f /dev/sdc /dev/sdb

-> -r + numero = tentativi retray
-> -f = Force overwrite of outfile. Needed when outfile is not a regular file, but a device or partition.
——————————————
##SAMBA NETWORK SHARE CONNECT
sudo mount -t cifs //192.168.84.11/c$ /mnt/Temp -o uid=1000,gid=1000,rw,user,username=Administrator,domain=gruppo-grigolin.local
——————————————
##CONTROL PRINTERS VIA CMD:
@echo off
REM RUNDLL32 PRINTUI.DLL,PrintUIEntry /y /n “HP Officejet Pro 8500”

@echo Add a network printer from windows command line
rem cscript C:\windows\system32\Printing_Admin_Scripts\it-IT\prnmngr.vbs -p “printername” -s “servername”

@echo Get the list of printers added to the system from Windows command line(CMD).
rem cscript C:\windows\system32\Printing_Admin_Scripts\it-IT\prnmngr.vbs -l

@echo Get the default printer details from command line.
rem cscript C:\windows\system32\Printing_Admin_Scripts\it-IT\prnmngr.vbs -g

@echo Set default printer from windows command line.
rem cscript C:\windows\system32\Printing_Admin_Scripts\it-IT\prnmngr.vbs -t -p “\\Servername\printername”
pause
—————————————–
##DISABLE/ENABLE NETMASK:
netsh interface set interface “Ethernet 2” disable
netsh interface show interface
—————————————–
##CHANGE TYPE CONNECTION:
Get-NetConnectionProfile
Set-NetConnectionProfile -InterfaceIndex xx -NetworkCategory Private
—————————————–
##PREVIEW KEYS:
Word Preview : HKCR\CLSID\{84F66100-FF7C-4fb4-B0C0-02CD7FB668FE}
PowerPoint Preview : HKCR\CLSID\{65235197-874B-4A07-BDC5-E65EA825B718}
Excel Preview : HKCR\CLSID\{00020827-0000-0000-C000-000000000046}
——————————————-
##FUNCTION MAIUSCOLO:
Sub Maiuscolo()
For Each Cell In Selection
If Not Cell.HasFormula Then
Cell.Value = UCase(Cell.Value)
End If
Next Cell
End Sub
——————————————-
#Per proxy ovveride (c’è la sezione ProxyOvveride dove mettere gli indirizzi separati da 😉
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings
——————————————-
Solo cartelle vuote:
Get-ChildItem ‘Y:\’ -Recurse -Directory | Where-Object {[System.IO.Directory]::GetFileSystemEntries($_.FullName).Count -eq 0} | ForEach-Object {$_.FullName}
——————————————-
Framework Offline .Net3
Dism.exe /online /enable-feature /featurename:NetFX3 /All /Source:D:\sources\sxs /LimitAccess
——————————————-
Framework Offline .Net2
DISM /Online /Enable-Feature /FeatureName:NetFx3 /All
——————————————-
Powershell Fix App:
Get-AppXPackage -allusers | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register “$($_.InstallLocation)\AppXManifest.xml”}
——————————————-
TPM 2.0 Not trusted:
from C:\users\$dir\AppData\Local\Packages\Microsoft.AAD.BrokerPlugin_cw5n1h2txyewy
to C:\users\$dir\AppData\Local\Packages\Microsoft.AAD.BrokerPlugin_cw5n1h2txyewy.old
——————————————-

##CHECK NAME FILE/FOLDER LENGHT:

dir /s /b | sort /r /+261 > out.txt
——————————————-
#GET FILE FROM HTML
wget -r -np -nH –cut-dirs=3 -R index.html http://hostname/aaa/bbb/ccc/ddd/

Explanation:

It will download all files and subfolders in ddd directory
-r : recursively
-np : not going to upper directories, like ccc/…
-nH : not saving files to hostname folder
–cut-dirs=3 : but saving it to ddd by omitting first 3 folders aaa, bbb, ccc
-R index.html : excluding index.html files
——————————————

##Excel Psw Breaker:

Sub PasswordBreaker()
‘Breaks worksheet password protection.
Dim i As Integer, j As Integer, k As Integer
Dim l As Integer, m As Integer, n As Integer
Dim i1 As Integer, i2 As Integer, i3 As Integer
Dim i4 As Integer, i5 As Integer, i6 As Integer
On Error Resume Next
For i = 65 To 66: For j = 65 To 66: For k = 65 To 66
For l = 65 To 66: For m = 65 To 66: For i1 = 65 To 66
For i2 = 65 To 66: For i3 = 65 To 66: For i4 = 65 To 66
For i5 = 65 To 66: For i6 = 65 To 66: For n = 32 To 126
Debug.Print Chr(i) & Chr(j) & Chr(k) _
& Chr(l) & Chr(m) & Chr(i1) _
& Chr(i2) & Chr(i3) & Chr(i4) _
& Chr(i5) & Chr(i6) & Chr(n)
DoEvents
ActiveSheet.Unprotect Chr(i) & Chr(j) & Chr(k) & _
Chr(l) & Chr(m) & Chr(i1) & Chr(i2) & Chr(i3) & _
Chr(i4) & Chr(i5) & Chr(i6) & Chr(n)
If ActiveSheet.ProtectContents = False Then
MsgBox “One usable password is ” & Chr(i) & Chr(j) & _
Chr(k) & Chr(l) & Chr(m) & Chr(i1) & Chr(i2) & _
Chr(i3) & Chr(i4) & Chr(i5) & Chr(i6) & Chr(n)
Exit Sub
End If
Next: Next: Next: Next: Next: Next
Next: Next: Next: Next: Next: Next
End Sub

vmware errori schede

$ git clone -b workstation-16.1.2 https://github.com/mkubecek/vmware-host-modules.git
$ cd vmware-host-modules/
$ make
# make install
# /etc/init.d/vmware restart

Backup Linux Polyedro

sudo TEAMPORTAL backup
sudo TEAMPORTAL stop quiet
sudo mkdir /dati/backup-tp-preupgrade-$(date +%F)
cd /dati/teamportal/data
sudo tar cvzf /dati/backup-tp-preupgrade-$(date +%F)/polyedro-exp-backup-htdocs-$(date +%F).tar.gz htdocs/
sudo tar cvzf /dati/backup-tp-preupgrade-$(date +%F)/polyedro-exp-backup-www-$(date +%F).tar.gz –-exclude=filestorage/www/_* filestorage/www/
sudo TEAMPORTAL start quiet
chmod +x tsx-linux-20200200-x64.exe
sudo ./tsx-linux-20200200-x64.exe

 

Montare Iso Raspberry per caricare modifiche

Lanciare fdisk -l nomeiso

Nella schermata sopra prendiamo come riferimento la seconda partizione uscita col comando fdisk e teniamo come riferimento il settore Start della partizione Linux della iso (in questo caso 94208)

Creiamo una cartella per il punto di mount della iso che vogliamo montare

a questo punto prima di montare la nostra iso moltiplichiamo il valore Start della partizione iso per 512 bytes.

A risultato ottenuto andremmo ad applicare il seguente comando

mount -v -o offset=VALORECALCOLATOPRIMA -t ext4 nomeiso.img /mnt/iso

 

Comandi Linux

 

 netstat -tnlp  --> Connessioni attive
du -sh nomecartella --> Vedere lo spazio directory occupato

du -sh * / --> Vedere lo spazio per cartella

ls -al /dir/  | less  --> vedere per pagina con permessi

ls -b /   -->  per colonna ma senza permessi

Estrarre solo determinate cartelle

tar -zxf nomefile.tar.gz --directory /cartella/ --exclude="_*"

 

Comprimere Cartelle

7z a teamportal.7z /dati/teamportal/

Decomprimere Cartelle con Destinazione

7z x nomfile.7z  -o/dati/teamportal/destinazionecartella

Permessi specifici per polyedro experience >> 202002000(tsx)

 

cd /dati/aggiornamenti
sudo umask 0002
sudo chgrp tsx_group .     ( notare il punto finale )
sudo chmod g+s .           ( notare il punto finale )

Problemi con cartelle WEBDISK

sudo chown -R teamsy:tsx_group /dati/webdisk

sudo chmod -R 770 /dati/webdisk

Aggiornamenti con samba

Guardare sambaguest nel tsx_group

Backup teamportal

Ho creato uno script per la creazione del backup di Teamportal/Polyedro. Basta eseguirlo con in comando

sudo TPBACKUP

Questo comando esegue il dump del DB, arresta il gestionale e crea il backup in una sottocartella di /dati/backup/.

Alla fine riavvia il gestionale.

Installazione / aggiornamento / upgrade di Teamportal / Polyedro

Ho creato un altro script che vi permette di installare / aggiornare / upgradare Teamportal/Polyedro ( fino alla versione 20200100 ) in automatico.

Il supporto per TSX ( Polyedro Exp 20200200 e superiore verrà aggiunto in seguito )

Occorre copiare l’eseguibile in /dati/aggiornamenti ed eseguire il comando

    sudo POLYINSTALL /dati/aggiornamenti/<nome-installer.exe> INSTALL|UPDATE|UPGRADE

INSTALL = installazione da zero

UPDATE = aggiornamento ( da teamportal -> teamportal oppure polyedro -> polyedro)

UPGRADE = upgrade ( teamportal -> polyedro )

Al termine rimuovere manualmente il file in /dati/aggiornamenti

Se aveste dei problemi a scaricare o modificare un file, accertatevi di lanciare prima

sudo chmod 777 nomefile