Shell get lines interval from a text file

 

cat file | head -n 16482 | tail -n 258

using sed:

sed -n '16224,16482p' in.sql > out.sql

using awk:

awk 'NR>=16224&&NR<=16482' in.sql > out.sql

Ubuntu 20.04 multipath syslog errors

Edit  /etc/multipath.conf 

and blacklist sda. Files contents which also blacklists common other devices like CDRom drives etc. that should never be checked for multipath configurations:

Code:

defaults {
    user_friendly_names yes
}
blacklist {
    devnode "^(ram|raw|loop|fd|md|dm-|sr|scd|st|sda)[0-9]*"
}



How to convert an executable to a Windows service

Windows runs services before opening any session. If we want to run a program even if there is no open session, this can be a solution, although it does not always work.

To create a Windows service from an executable (.exe), you need to use the sc.exe program (already included in Windows):
sc.exe create <new_service_name> binPath= "<path_to_the_service_executable>"

You must put quotes “” at the beginning and end of the path and a space after binPath=.

Example:
sc create IperiusBackup start= auto binPath= "C:\Program Files (x86)\Iperius Backup\IperiusService.exe" DisplayName= IperiusBackup

This freeware can also be used: http://nssm.cc/

Windows DHCP import/export


Export:

On the Windows 2003 DHCP server, navigate to a command prompt

Type the following Command: netsh

Type the following Command: DHCP

Type the following Command: server \\Name or IP Address

Type the following Command: export c:\DHCPdb all


Import:

Type the following Command: netsh

Type the following Command: DHCP

Type the following Command: server \\Name or IP Address

Type the following Command: import c:\DHCPdb

Close the command prompt when completed.

Return to DHCP located in the Server Manager dashboard.

Right click the designated DHCP server in the services pane, then select Restart.

Once the DHCP install has been completed, select DHCP located in the Server Manager dashboard

Right click the designated DHCP server in the services pane, then select Stop.

Delete the DHCP.mdb file under c:\windows\system32\DHCP folder.

Return to DHCP located in the Server Manager dashboard

Right click the designated DHCP server in the services pane, then select Start.


source:  https://docs.microsoft.com/en-us/archive/blogs/canitpro/step-by-step-migration-of-dhcp-from-windows-server-2003-to-windows-server-2012

ESXI enalbe SNMP

 Run through ssh (it's  all in one line)

esxcli system snmp set -r && esxcli system snmp set -c COMMUNITY && esxcli system snmp set -p 161 && esxcli system snmp set -C CONTACTA_MAIL && esxcli system snmp set -L "LOCATION" && esxcli system snmp set -e yes
 

Virtualbox expand disk size


Run vboxmanage.exe (c:\program files\oracle\virtualbox).
To expand disk to 50gb:
vboxmanage.exe modifyhd path_to_vdi --resize 50000

ex:
vboxmanage.exe modifyhd d:\vms\win7teste.vdi --resize 50000

Then use a live cd with partition tools, like gparted to resize disk partitions (gparted.sourceforge.net/download.php)


Mysql shell script without password exposure

Suppose your username is "db_user". Running from the shell prompt:

mysql_config_editor set --login-path=local --host=localhost --user=db_user --password

It prompts for the password. Once you enter it, the user/pass are saved encrypted in your home/system_username/.mylogin.cnf

write the password between "" if contains spacial character, like "#" or "." ex: "Passw#rd"

Of course, change "system_username" to your username on the server.

Change your bash script from this:

mysqldump -u db_user -pInsecurePassword my_database | gzip > db_backup.tar.gz

to this:

mysqldump --login-path=local my_database | gzip > db_backup.tar.gz


mysql --login-path=local -D DATABASE -e "SELECT * FROM table LIMIT 10"

Corrigir erro NATS no Segura

  ### erro Nats orbit nats stop orbit nats setup orbit services reload orbit services restart all ls -lh /var/orbini/system/incdt/ 

Mais vistos