patternsqlModerate
Getting "sqlcmd sqlcmd: command not found" in Linux?
Viewed 0 times
gettingfoundsqlcmdlinuxcommandnot
Problem
Whenever I run
How can I resolve that?
sqlcmd I get "command not found"sqlcmd -S localhost -U SA -P ''
sqlcmd: command not foundHow can I resolve that?
Solution
First make sure you've installed
User-specific Method
You can use the tutorial's recommended method. The tutorial states the following:
Optional: Add
To make sqlcmd/bcp accessible from the bash shell for login sessions, modify your PATH in the ~/.bash_profile file with the following command:
To make sqlcmd/bcp accessible from the bash shell for interactive/non-login sessions, modify the PATH in the ~/.bashrc file with the following command:
This works, but it only affects that user's sessions, and only if they use bash.
System-wide Method
Link the MS SQL tools into a location accessible to all users:
This could be in their
Both methods are compliant with the File system Hierarchy Standard, which states:
Programs to be invoked by users must be located in the directory /opt//bin
mssql-tools. Assuming you've done that, there are two methods of resolving this.- User-specific method advocated in the manual: add the directory to the environmental variable
PATH.
- System-wide method: symlink the executable to a directory already in the path.
User-specific Method
You can use the tutorial's recommended method. The tutorial states the following:
Optional: Add
/opt/mssql-tools/bin/ to your PATH environment variable in a bash shell.To make sqlcmd/bcp accessible from the bash shell for login sessions, modify your PATH in the ~/.bash_profile file with the following command:
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profileTo make sqlcmd/bcp accessible from the bash shell for interactive/non-login sessions, modify the PATH in the ~/.bashrc file with the following command:
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrcThis works, but it only affects that user's sessions, and only if they use bash.
System-wide Method
Link the MS SQL tools into a location accessible to all users:
sudo ln -s /opt/mssql-tools/bin/* /usr/local/bin/This could be in their
postinst script, which would make sense for installing an optional package.Both methods are compliant with the File system Hierarchy Standard, which states:
Programs to be invoked by users must be located in the directory /opt//bin
Code Snippets
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profileecho 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrcsudo ln -s /opt/mssql-tools/bin/* /usr/local/bin/Context
StackExchange Database Administrators Q#174277, answer score: 16
Revisions (0)
No revisions yet.