CorpXeno

1 Nov 2025

SQL Server on Linux

SQL ServerLinux

RHEL & CentOS:

Ubuntu:

Unattended Installation:

Configuring the Firewall:

  • Linux systems use iptables - a rule based firewall that comes pre-installed
  • Uses concept of NAT and packet filtering
  • Default system firewall on RHEL and CentOS7 is FirewallD
  • It exposes iptables via an API and offers firewall-cmd for config
  • https://firewalld.org/
  • Ubuntu uses CLI tool UFW (uncomplicated firewall)
  • https://help.ubuntu.com/community/UFW
  • Configuring on CentOS:
  • Sudo systemctl status firewalld
  • Sudo firewall-cmd --zone-public --add-port=1433/tcp --permanent
  • Zone describes the trust level for a connection
  • Public zone signifies that you do not trust any other computers on the network
  • Only incoming traffic to TCP port 1433 will be allowed
  • Permanent parameter means the rule will be added on a permanent basis
  • Sudo firewall-cmd --reload
  • To take the change in effect
  • Sudo firewall-cmd --list-ports
  • Sudo firewall-cmd --list services
  • Sudo iptables -nL | grep 1433
  • Configuring F/W on Ubuntu:
  • Sudo systemctl status ufw
  • Sudo ufw status
  • Sudo ufw --force enable
  • UFW once enabled will block everything including SSH on port 22.
  • Sudo ufw allow 22/tcp
  • Sudo ufw allow 1433/tcp

Configuring SQL Server on Linux

  • Man mssql-conf
  • Sudo /opt/mssql/bin/mssql-conf list
  • Enabling SQL server Agent:
  • Sudo /opt/mssql/bin/mssql-conf set sqlagent.enabled true
  • Configuring Default Data & Log directory:
  • Default dir is /var/opt/mssql/data
  • Sudo mkdir /tmp/dbdata
  • Sudo chown mssql /tmp/dbdata
  • Sudo chgrp mssql /tmp/dbdata
  • Sudo /opt/mssql/bin/mssql-conf set filelocation.defaultdatadir /tmp/dbdata
  • Sudo /opt/mssql/bin/mssql-conf set filelocation.defaultlogdir /tmp/dbdata
  • Configuring default backup directory:
  • Default dir is /var/opt/mssql/data
  • Sudo mkdir /tmp/dbbackup
  • Sudo chown mssql /tmp/dbbackup
  • Sudo chgrp mssql /tmp/dbbackup
  • Sudo /opt/mssql/bin/mssql-conf set filelocation.defaultbackupdir /tmp/dbbackup
  • Enabling Trace flags:
  • Sudo /opt/mssql/bin/mssql-conf set traceflag 3226 on
  • This TF supresses every successful backup entry in SQL error logs and in system event log
  • As all these settings require SQL restart in order to come into effect
  • Sudo systemctl restart mssql-server
  • Viewing Instance level config settings:
  • Cat /var/opt/mssql/mssql.conf

Connect SQL via SSMS remotely:

sudo ufw --force enable

sudo ufw allow 22/tcp

sudo ufw allow 1433/tcp

If an Azure VM: