Thursday, April 30, 2026

How to run a command on boot or startup in Ubuntu.


https://linuxvox.com/blog/automatically-run-a-program-on-startup-under-linux-ubuntu/

We start by creating a .sh file in /usr/bin/mycommand.sh
 
Enter the following text in it.

#!/bin/sh
sudo ip  route add 10.30.24.0/24 via  192.168.0.1 dev eth0 onlink

Creating a new service:
sudo nano /etc/systemd/system/mycommand.service # create new service file

Enter the following text in it.

[Unit]
Description=Add route command
After=network.target

[Service]
Type=oneshot
ExecStart=/bin/bash /usr/bin/mycommand.sh
User=root #running as root user
Restart=never # do not restart the service if it fails

[Install]
WantedBy=multi-user.target

Starting the service:
sudo systemctl daemon-reload # reload the system daemon
sudo systemctl start mycommand.service # to start without rebooting for testing
sudo systemctl status mycommand.service # to verify status of service.
sudo systemctl enable mycommand.service # enable the service to run at startup


Removing a systemdservice
Sudo systemctl stop mycommand.service # stop the service
Sudo systemctl disable mycommand.service # disable the service
Sudo rm /ect/systemd/system/mycommand.service

 

 

Tuesday, March 4, 2025

SQL SPN Powershell Commands

List User Account Spn:

 Get-ADUSer -Filter { ServicePrincipalName -ne "$null"} -Properties ServicePrincipalName | select 

SamAccountName, ServicePrincipalName

 

List Computer Account Spn
Get-ADComputer -Filter { ServicePrincipalName -ne "$null"} -Properties ServicePrincipalName | select SamAccountName, ServicePrincipalName | Out-String -Width 4096 

Setting SPN:


setSPN -A MSSQLsvc/sqlserver1.contoso.com:59302 contoso\serviceaccount

setSPN -A MSSQLsvc/sqlserver1:59302 contoso\serviceaccount


 

Tuesday, November 26, 2024

SQL error when connecting to server using servername\instance.

SQL error when connecting to server using servername\instance. 

Error:

A network-related or instance-specific error occurred when establishing a connection to SQL server. the server was not found or was not accessible.Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error:26 - Error Locating Server/Instance Specified) (Microsoft SQL Server)

 


 Solution:

The UDP port 1434  on destination server was being  blocked in  the firewall.