Click here to Skip to main content
15,867,453 members
Articles / Editing

Install Sublime Text 3 (beta) on Linux Mint or Ubuntu

Rate me:
Please Sign up or sign in to vote.
5.00/5 (1 vote)
28 Jan 2015CPOL7 min read 82.8K   1   3
Install Sublime Text 3 (beta) on Linux Mint or Ubuntu.

LKeyboard240Surprisingly, one of my more popular articles last year was a short, very basic walk-thru detailing how to install Sublime Text 2 on Ubuntu-based machines (this includes Linux Mint).

Now that beta version of Sublime Text 3 has become more and more stable, I am going to post an updated walk-thru for the new version, since the commands differ in a few places, and I have learned a few things in the intervening months (slowly – baby steps here . . .).

Image by Nick Ares / Some Rights Reserved

As noted in the previous article regarding Sublime Text 2, Sublime Text 3 is not currently part of the Synaptic Package Management system on Linux Mint (or Ubuntu). Therefore, there is no magical apt-get install command as you might use to install other software on your Linux system, so we have to do a little more work.

In this article we will look at two different methods to install Sublime Text on your Ubuntu or Mint machine. First,  "The Hard Way"  and second, "The Better/Easier Way." The hard way requires a little more work, but if you are new to Linux, you will learn more. The easier way is much faster, but hides most of what is going on behind the Personal Package Archive system. 

Also, once you have installed Sublime Text, you may want to set Sublime Text as the default editor for use with Git.  

Installing Sublime Text on Linux Mint/Ubuntu from Tarball

You can manually download the latest build (Build 3059 as of this writing) of Sublime Text 3 for either 32 bit or 64 bit architectures from the Sublime Text 3 page, unpack, and locate in the directory of your choice. This can be done manually, or from the terminal as described below.

If you are less-than-familiar with the Bash command line, be sure to visit my previous posts. While these were originally part of a series on using Git for Windows developers, the basic Bash commands required for this install are clearly explained:

This method is described on the Sublime Text Site/Support/Linux/Installation page. Simply open a terminal in the directory you use for applications, and enter the following command (use the appropriate version for the architecture (23 or 64 bit) of your machine):

Note: As of this writing, Sublime Text 3 build 3059 is the most recent beta release. If the release is updated, the URL's in the links below will change, and you will need to copy the updated URL from the Sublime Text site. 

Download the Linux 32-Bit Version of Sublime Text 3: 
$ wget http://c758482.r82.cf2.rackcdn.com/sublime_text_3_build_3059_x32.tar.bz2
Download the Linux 64-Bit Version of Sublime Text 3:
$ wget http://c758482.r82.cf2.rackcdn.com/sublime_text_3_build_3059_x64.tar.bz2

Extract the sublime_text_3_build_3059_x32.tar.bz2  file

(or, sublime_text_3_build_3059_x64.tar.bz2 for the 64 bit version):

Extract the Sublime Text .tar file:
tar vxjf "sublime_text_3_build_3059_x32.tar.bz2"

It is common to locate 3rd-party applications in the /opt/ directory, so move the extracted files there:

Move Extracted Sublime Text 3 Files to Opt Directory:
$ sudo mv Sublime_text_3 /opt/

Creating a Bash Script to use Sublime Text 3 from the Terminal

Now that we have located the files in an appropriate directory, let's make a Bash script which will allow us to execute Sublime Text 3 with a simple command. To do this, we are going to stay in our terminal, and perform a very simple edit using vi.

First, change to the /opt/sublime_text_3/ directory:

Move into the Sublime Text 3 directory in /opt/
$ cd /opt/sublime_text_3

Next, open vi into a new file named subl3 (this is a convenient shortcut to use from the terminal):

Open Vi Into New File suble3:
$ vi subl3

If you are new to editing text from the terminal, don't panic, this is not too bad, and also is something you should learn how to do, if only for occasions like this). There are a few key things to know about vi:

  • vi opens in Command Mode – you cant type any text yet. To enter Insert Mode, type the asterisk character followed by capital I ( *I ). This will allow text entry on the current line.
  • To return to command mode, hit the <escape> key.
  • to save the current file, from command mode, type the Colon character, followed by lower-case w and lower case q, then hit enter ( :wq <enter> ).

Now, you should be looking at a blank screen in vi. Enter Insert Mode ( *I ) and type the following two lines:

Type Bash Script Into Vi that Creates an Alias for Sublime Text 3
Bash
#!/bin/sh 
exec /opt/sublime_text_3/sublime_text "$@" 

Then exit Insert Mode ( <esc> ) and save the file ( :qw ).

Congratulations. You have now created a Bash script. Now, let's make sure the access permissions on our script are appropriate. Set the access permissions as follows:

Set Access Permissions on new Bash Script:
$ sudo chmod 755 subl3

This allows anyone to read or execute the script, but only the owner can write to it.

Now, we need to move the script file to the /usr/bin/ directory, so that it can properly respond to Bash commands:

Move Script to Proper Directory:
$ sudo mv subl3 /usr/bin/ 

Now, having done all that, let's look at the easier way to accomplish all of the above steps.

 

Install Sublime Text 3 on Linux Mint /Ubuntu Using Personal Package Archive (PPA)

This is what I consider the better way to do this.

Canonical, the company which supports Ubuntu, has created the Launchpad.net site which, among other things, hosts a repository for Personal Package Archives (PPA's). Here, individuals and teams can upload their own software and installation packages, and it is possible to find deployment packages for software that is not included in the Ubuntu or Linux Mint Synaptic Package Manager for your specific distribution. It is also possible to add the PPA to your Synaptic catalog, so that you can then run apt-get install, apt-get update and the like to keep your package up to date.

Or, at least as up to date as the package maintainer at Launchpad keeps theirs.

The WebUpd8team at Launchpad has created (among other things) a PPA for Sublime Text 3 (currently still in beta as of this writing). To add Sublime Text 3 to your Synaptic catalog, and install according to the install script published with the PPA, follow these steps:

Add the Sublime Text 3 Repository to your Synaptic Package Manager:
sudo add-apt-repository ppa:webupd8team/sublime-text-3 
Update: 
sudo apt-get update

 Install Sublime Text:

sudo apt-get install sublime-text-installer

 Next, check the usr/bin directory. You should see a file named subl. This is the alias you can use to invoke Sublime Text 3 from the command line, just like we created manually above.

There you have it. You can now use Sublime Text 3 from you command line. Also, you should see it available in your GUI in the applications menu.

This has been a long post about a relatively simple operation. My goal has been to explain the concepts as fully as possible, under the assumption that there are those out there, like myself, new enough to Linux to need the extra handholding.

In addition, if you first followed the manual instructions, you may have learned a few more of the basics in working with Linux (and vi).

Thanks for reading!

Other Topics of Interest 

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer XIV Solutions
United States United States
My name is John Atten, and my username on many of my online accounts is xivSolutions. I am Fascinated by all things technology and software development. I work mostly with C#, Javascript/Node.js, Various flavors of databases, and anything else I find interesting. I am always looking for new information, and value your feedback (especially where I got something wrong!)

Comments and Discussions

 
SuggestionNo need for a shell script Pin
Andre Sanches (alvs)28-Jan-15 5:11
Andre Sanches (alvs)28-Jan-15 5:11 
QuestionWrong command in bash script (For Linux mint) Pin
Rahul Sagore28-Jan-15 0:06
professionalRahul Sagore28-Jan-15 0:06 
AnswerRe: Wrong command in bash script (For Linux mint) Pin
John Atten28-Jan-15 1:19
John Atten28-Jan-15 1:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.