Recover grub after windows update

Run this in Windows as an administrator:

bcdedit /set {bootmgr} path \EFI\ubuntu\grubx64.efi

Or:

bcdedit /set "{bootmgr}" path \EFI\ubuntu\grubx64.efi

If you are using PowerShel.

Shell History with date


Include in /root/.bashrc

# History with date
HISTTIMEFORMAT="%F-%T "
 

 or

HISTTIMEFORMAT="%d/%m/%y %T "

 
Optional: Clear history
history -c 

Logoff and login again.




Select specific range os lines

Select specific range os lines:

head -22 file.txt | tail -5

 

Insert character at specified position


awk '{$2="#"$2;print $0}' your_file

This will add # to the start of the second (space-separated) column regardless of which position it occurs at.



sed -r -e 's/^.{15}/&#/' file

Insert '#' in position 15

Add / Remove users from AD groups with Powershell


For a users list:

1 - create a file (ex: add-users.ps1);
2 - paste the commands and change file name and group;
3 - the first line of users list must be UserName;
4 - Run the ps1 file with admin user.

Import-module ActiveDirectory
Import-CSV "C:\list_of_users.csv" | % {
Add-ADGroupMember -Identity GROUP -Members $_.UserName
}

pause


For add only one user

Add-ADGroupMember -Identity GROUP -Members USER


To remove users, change Add-ADGroupMember to Remove-ADGroupMember


APT install only security updates

Check security updates:

sudo unattended-upgrade --dry-run -d

If previous command show packages to update:

sudo apt-get -s dist-upgrade | grep "^Inst" | grep -i securi | awk -F " " {'print $2'} | xargs apt-get install

List AD group members from linux

List group members using samba 4 samba-tool:

samba-tool group listmembers <group> -H ldap://<servername> -d0



ESXi enable remote syslog

  esxcli system syslog config set --loghost=udp://10.20.0.27:514 esxcli network firewall ruleset set --ruleset-id=syslog --enabled=true  esx...

Mais vistos