Select Page


Many text editors often come along with a command-line helper tool rhat allows those programs to be executed from right within a terminal emulator. Sublime Text is of no exception either. It has it’s very own command-line tool for starting the editor right from the command line. But how is that even more convenient than pressing the app icon from the Dock or the App Menu with your mouse? 

It’s because when you’re using the terminal for browsing folders and executing other commands on them, and have suddenly came across a very remote file that you’d like to open, it’d be quite cumbersome to open the editor from the Dock or the App Menu and then once again browsing for the specific folder in your disk to open that file from within Sublime Text.

This is where the subl command comes into play. It allows you to directly open the specific file from the terminal, without needing to waste any extra time. However, many people have reported that they are outputted with the following error message when they try to run the subl command:

$ subl: command not found

In this article, we’ll discuss how you can go about this issue and start running the subl command properly, both in a Linux machine and or in a MacOS one. 

Reinstall Sublime Text in Linux

If you’re using a Linux machine, then it’d be a good idea to try reinstalling Sublime Text entirely before trying out any other fix mentioned in this article, as it should hellp fix any broken dependencies or symlinks.

If you had previously installed Sublime Text by first add the repository to the sources list, (which you probably did), then run the following command through the terminal:

$ sudo apt reinstall sublime-text 

Now try running the subl command again. If you still see the same error appear, proceed to the very next section.

Fix the PATH Variable

in Linux

What I mean by fixing the PATH variable is not the same across the two operating systems (Linux and MacOS). In order to fix any issues regarding the PATH variable in Linux, there are two possibilities based on the method of installation you followed.

If you had installed the editor by using a package manager, then the subl command shown automatically be added under the /usr/bin directory, which by default, is listed under the path variable. If, however, you installed Sublime Text in Linux by using the provided tarball from their official website, you need to create a symlink for the command yourself. The process for creating a symlink is discussed in the next section. However, before you proceed, you should make sure that the /usr/local/bin directory is listed under the PATH variable, by running:

$ echo $PATH

If you don’t see the /usr/local/bin directory, then add the following line in your .bashrc (or .zshrc) file found in your home directory (hidden):

export $PATH=/usr/local/bin:$PATH

in MacOS

In MacOS, the ‘usr/local/bin‘ directory is not listed under the PATH variable. In fact, it is possible that the bin directory does not exist at all. First, run the following command to create the bin directory:

$ sudo mkdir -p /usr/local/bin

Once the bin directory is created, you now need to add this to the to the PATH variable of your system by following the same procedure as in Linux, which is to add the following line in your .zshrc file or .bashrc file (based on the shell you’re using):

export $PATH=/usr/local/bin:$PATH

Once the PATH variable has been fixed, you can now move on to creating the symlink.

Create a Symlink for the subl command

in Linux

When installed with the tarball zip in a Linux machine, you’d need to create a symlink, just like you’d need to on a MacOS machine. To do this, you’d want to run the following command in your terminal:

$ sudo ln -s /opt/sublime_text/sublime_text /usr/local/bin/subl

If you’ve installed Sublime Text in some other directory than the one shown here, you’d want to use that path instead of ‘/opt/sublime_text/sublime_text’

Once done, you should now be able to run the subl command from your terminal in Linux.

in MacOS

You probably installed Sublime Text in your MacOS machine by downloading the zip file from their website and then extracting it to the Applications folder. From here, if you right click on the app Icon and click on “Show Package Contents” from the context menu, you should be able to view the Contents folder. Inside the Contents folder, if you navigate to SharedSupport/bin sub-directory, you’ll find the subl utility:

This is the utility that you need to create a symlink for. Remember the /usr/local/bin folder we created earlier? Now is it’s time to come into play.

Now run the following line of command in your MacOS terminal emulator:

$ sudo ln -s “/Applications/Sublime” /usr/local/bin/subl

Et Voilà! The subl should now successfully be executable from your MacOS terminal.