Prerequisites:

Operating System: Ubuntu >= 16.04 Version, with at least 2 GB RAM
Note, Ubuntu 16.04 is the official version supported by Microsoft. Other versions require some additional modifications to support SQL Server installation.

Commands to prepare system for Installation:

sudo apt-get update
sudo apt-get -y upgrade
sudo reboot

Commands to MS SQL Server Installation:

wget -qO- https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -

For SQL Server 2017

sudo add-apt-repository "$(wget -qO- https://packages.microsoft.com/config/ubuntu/16.04/mssql-server2017.list)"

For SQL Server 2019

sudo add-apt-repository "$(wget -qO- https://packages.microsoft.com/config/ubuntu/16.04/mssql-server2019.list)"
sudo apt-get update sudo apt install libcurl3 sudo apt-get install -y mssql-server

Run below if you see error, “mssql-server : Depends: openssl (<= 1.1.0) but 1.1.0g-2ubuntu4.1 is to be installed“

wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/openssl_1.0.2g-1ubuntu4_amd64.deb
sudo dpkg -i openssl_1.0.2g-1ubuntu4_amd64.deb
sudo apt-get -y install mssql-server
sudo /opt/mssql/bin/mssql-conf setup
systemctl status mssql-server --no-pager
sudo ufw allow 1433
sudo ufw allow 1434

Commands to SQL Server Command-line tools installation:

curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add –
curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list | sudo tee /etc/apt/sources.list.d/msprod.list
sudo apt-get update  sudo ACCEPT_EULA=Y apt-get -y install mssql-tools unixodbc-dev
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc source ~/.bashrc

Commands to Connect to SQL Server and Writing queries:

sqlcmd -S localhost -U SA -P 'Password'
CREATE DATABASE MyDB
GO
SELECT Name from sys.Databases
GO
QUIT

For detailed instructions, please refer below
https://docs.microsoft.com/en-us/sql/linux/quickstart-install-connect-ubuntu?view=sql-server-ver15