Thursday, August 29, 2019

Resolve "sqlcmd: command not found" error Ubuntu command line



Even after installing SQL Server on Ubuntu you can’t run sqlcmd commands in Ubuntu without installing mssql-tools

First of all, make sure that mssql-tools installed. If you are not sure you can simply try to install Using following command 

$ sudo apt-get install mssql-tools


if mssql-tools already installed it will show the following 


Reading package lists... Done
Building dependency tree       
Reading state information... Done
mssql-tools is already the newest version (17.4.1.1-1).


If it not install command will install the mssql-tools into your ubuntu machine 


Even after install mssql-tools, if you get "sqlcmd: command not found" error it because you have no proper symlinks created in /user/bin directory.


Check you have sqlcmd in /opt/mssql-tools/bin/ directory 
run following command 

$ sudo ls /opt/mssql-tools/bin/sqlcmd*

After you get the name of the tool you can create a symlink by following command

$ sudo ln -sfn /opt/mssql-tools/bin/sqlcmd /usr/bin/sqlcmd

No comments:

Post a Comment