Sublime Text is an awesome text editor. If you’ve never heard of it, you should check it out right now.
I’ve made this tutorial because there’s no installer for the Linux versions of Sublime Text. While that’s not a real problem, I feel there is a cleaner way to go around this. Also, this post will show you how to integrate Sublime Text to Unity (which, I’m glad to report, has now matured into a fully functional user interface).
So let’s get on with this. Here is my how to install Sublime Text on Ubuntu tutorial.
[This tutorial has been updated following feedback from AskUbuntu. Also, you need to do these steps using your login. Do not start by typing "sudo -s"!]
Step 1
Download the tarfile that suits you best and extract it. Here’s the command to extract tar.bz2 files:
tar xf Sublime\ Text\ 2.0.1\ x64.tar.bz2
You’ll notice that I got the 64-bit version. The reason is that it’s lightning fast. So, go for that if you can!
Step 2
You’ll get a “Sublime Text 2″ folder after extraction. This folder contains all the files that Sublime Text will need. So we have to move that folder somewhere more appropriate. Like the “/opt/” folder :
sudo mv Sublime\ Text\ 2 /opt/
Step 3
At some point you’d want to be able to call Sublime Text from the Terminal by just typing “sublime”. To do that, we’ll just create a symbolic link in “/usr/bin” like thus:
sudo ln -s /opt/Sublime\ Text\ 2/sublime_text /usr/bin/sublime
Step 4
Now that our files are at the right place, we need to create a launcher in Unity. To do this, we’re going to create a .desktop file in “/usr/share/applications”:
sudo sublime /usr/share/applications/sublime.desktop
And paste the following content:
[Desktop Entry] Version=1.0 Name=Sublime Text 2 # Only KDE 4 seems to use GenericName, so we reuse the KDE strings. # From Ubuntu's language-pack-kde-XX-base packages, version 9.04-20090413. GenericName=Text Editor Exec=sublime Terminal=false Icon=/opt/Sublime Text 2/Icon/48x48/sublime_text.png Type=Application Categories=TextEditor;IDE;Development X-Ayatana-Desktop-Shortcuts=NewWindow [NewWindow Shortcut Group] Name=New Window Exec=sublime -n TargetEnvironment=Unity
As you can see, these lines are quite straightforward. Go ahead and experiment a bit with them.
Step 5
Now you would probably want to open all text files with Sublime Text 2. The easiest way to do that is to open up the file associations list:
sudo sublime /usr/share/applications/defaults.list
And replace all occurrences of gedit.desktop with sublime.desktop.
Tada ! There you go. You now have Sublime Text 2 installed on Unity on Ubuntu 12.04, like a pro.
Here are some screenshots:


March 1, 2013 at 9:08 am
Thanks so much; very useful for Linux noobs!
March 6, 2013 at 1:03 pm
Great! Thanks for the detailed info.
March 8, 2013 at 2:12 am
Thanks for this tip!
March 10, 2013 at 4:23 pm
Thanks a lot, this was extremely useful!
March 11, 2013 at 2:44 am
Thank You!
March 11, 2013 at 10:33 pm
The file associations don’t work for me. I edited /usr/share/applications/defaults.list as recommended (except that the command is subl rather than sublime) , but when I click on a python file for example, it opens in gedit. Here is the line from /usr/share/applications/defaults.list:
text/x-python=subl.desktop
The word “gedit” appears nowhere in the file. If I type “subl” at the command prompt, sublime opens as you would expect.
I don’t even know where to look. Have you any suggestions?
Thanks.
March 12, 2013 at 12:37 am
I think I know what the problem is. When I put the sublime.desktop file in /usr/share/applications, no icon shows up on my desktop, so I put it in my Desktop directory instead, naming it subl.desktop. Apparently, the files referred to in /usr/share/applications/defaults.list won’t be found in my Desktop directory.
Have you any idea why the icon doesn’t show up? I do have other .desktop files in my Desktop directory.
March 12, 2013 at 7:07 am
Are you sure the path to your Sublime Text icon is correct ?
March 12, 2013 at 8:27 am
Yes. I even copied the path from the .desktop file and pasted it into the terminal to check. I did find some information on why the file associations didn’t work. According to Ask Ubuntu , at
http://askubuntu.com/questions/16580/where-are-file-associations-stored
you need to have MIME types in the .desktop file. Examples are given in the Sublime Forum at
http://www.sublimetext.com/forum/viewtopic.php?f=2&t=3457
March 13, 2013 at 12:56 pm
Thanks! This is totally awesome.
March 16, 2013 at 6:49 pm
That worked perfectly! Thank you!
March 16, 2013 at 7:44 pm
Errrr… one thing though: my icon on launchpad opens up to sublime.desktop instead of a new clean window. Any idea on how to make it work? Thanks!
March 16, 2013 at 7:49 pm
hey! nevermind i got it! it saves how it last shut to open just like it. thanks!
March 17, 2013 at 4:07 pm
Thanks a lot for this. Though I have an issue, everytime I open sublime it doesnt show me the last files I have opened but still shows the sublime.desktop and defaults.list files.
Anyone knows how to fix it?
March 17, 2013 at 4:12 pm
Honesta, before closing Sublime, try closing the separate tabs first. Re-open, see if it works.
March 17, 2013 at 5:32 pm
that didn’t work. What I did was to clear all items in ‘open recents’. that way now I have a clean ST every time I click the icon. Though now is another problem, that it doesn’t open the last opened file from the previous time. It is always blank.
March 29, 2013 at 3:14 pm
Hi, i have the same problem.
Have you found any solution?
April 13, 2013 at 7:03 am
hey guys, in case you didn’t see Jake’s link down below, read this for a solution:
http://askubuntu.com/questions/172698/how-do-i-install-sublime-text-2
March 17, 2013 at 5:52 pm
Thank you. Extremely helpful and straightforward =D
March 20, 2013 at 4:55 am
Awesome thanks for the simple guide!!! I didn’t know how to associate the icon
March 21, 2013 at 8:30 pm
Hey, thnks for share.
It’s works! ;D
March 21, 2013 at 8:37 pm
Oia,, I’ve added your tutorial to my tumblr. Could i ?
March 21, 2013 at 9:47 pm
Of course !
March 22, 2013 at 2:26 pm
Thank you very for the solution
Pingback: Sublime Text 2 on Ubuntu 12.10 | tobyw4n
March 23, 2013 at 10:38 am
This was very helpful. You are life savior. Thanks
March 26, 2013 at 2:57 am
Hi mate. Does it works only for the 64bit version? I need to install the 32bit one.
Anyway I run your code and this is what I get:
~$ tar xf Sublime\ Text\ 2.0.1\ x64.tar.bz2
tar: Sublime Text 2.0.1 x64.tar.bz2: No se puede open: No existe el archivo o el directorio
tar: Error is not recoverable: exiting now
~$
Any help? Thanks in advance!
Cheers!
March 26, 2013 at 3:00 am
*”No se puede open: No existe el archivo o el directorio” means “Can’t be opened: File or directory doesn’t exist”
Thanks!
April 1, 2013 at 2:07 pm
thanks! now i can use my favorite text editor without a problem.
April 5, 2013 at 2:22 am
This way of doing things is utterly and completely wrong.
For the correct method see this article:
http://askubuntu.com/questions/172698/how-do-i-install-sublime-text-2
Pingback: Instalar Sublime Text 2 en Ubuntu 12.04 utilizando Unity | Junior Developer [the blog]
April 6, 2013 at 8:52 pm
Thanks for the post! It’s very useful
April 6, 2013 at 11:47 pm
DO NOT FOLLOW THIS INSTRUCTIONS!
Use instead:
sudo add-apt-repository ppa:webupd8team/sublime-text-2
sudo apt-get update
sudo apt-get install sublime-text
Pingback: 在ubuntu12.04(Unity桌面)中安装Sublime Text 2 | Zhoutall
April 9, 2013 at 2:57 pm
Thanks, awesome tutorial. helped a lot. I was just wondering why can’t I install sublime with apt-get ?
April 9, 2013 at 8:14 pm
You can… In fact I strongly suggest you un-do everything the above tutorial told you to do and follow these instructions:
http://askubuntu.com/questions/172698/how-do-i-install-sublime-text-2
April 13, 2013 at 7:00 am
Thanks for this warning and link!
I had the exact same problem. My session was only being saved when run as sudo, and I wasn’t aware that modifying the /usr directory was inadvisable.
Pingback: Приложения по умолчанию в Ubuntu | nadyarnv
April 22, 2013 at 8:12 pm
you made my day! thanks a lot for sharing!
April 23, 2013 at 12:26 pm
Thanks, very helpful and informative
April 23, 2013 at 12:29 pm
Actually, I think the above comments are right about the correct way to do this, but this is still useful to see the manual steps.
April 26, 2013 at 1:42 pm
Nice One – It worked
April 30, 2013 at 8:55 pm
Clap – clap – clap – clap.
Thank you!
Pingback: How to install Sublime Text 2 On Ubuntu 12.04 Unity | aginanjarm
May 3, 2013 at 11:43 am
Thanks alot for this!
May 3, 2013 at 12:07 pm
Nice tutorial. One problem, though. If you start sublime the first time with sudo, the ownership in ~/.config will be set to root:root causing all sorts of problems.
So you might want to add that you have to open sublime atleast once as normal user before using sudo sublime.
May 7, 2013 at 5:12 pm
Not sure If I need to do step 4 or if I understand step 4. What do you mean by “Create a luancher in Unity”?
Thanks though, this worked,
Nick
May 9, 2013 at 8:40 am
Hey,
I did all the steps you taught and sublime is not appearing in the dash and when I run the command “sublime” sublime text opens but when I close the terminal sublime closes too.
I am using ubuntu 13.04. How do I reinstall?
May 9, 2013 at 9:19 am
wil this installation works for 32 bit ubuntu
May 9, 2013 at 9:20 am
will this works for 32 bit ubuntu
May 9, 2013 at 9:22 am
Never mind I fixed it. Villa, it should work in 32 bit Ubuntu just download the 32 bit for Linux:
http://www.sublimetext.com/2
May 10, 2013 at 7:40 pm
Is sublime text 2 free to use on Linux ? it says unregistered.
May 10, 2013 at 8:54 pm
Yes it is. However, every now and then it will prompt you to purchase it. Might seem annoying but it is so so worth it cos it is free. Paying for it is giving back to the developer and you might possibly get updates or something. But yea it is free.
May 11, 2013 at 10:05 pm
Lol, this is really pathetic, all those brainiacs working on linux and they cannot handle simple app installation without terminal and problems. Like typing bunch of command will make me smarter.
May 12, 2013 at 3:03 am
Lol who said we were brainiacs? I have heard no such boasting? Who said command line makes anyone smarter. Nub
Pingback: Установка Sublime Text 2 в Ubuntu Linux | zlovolsky blog
Pingback: A long weekend with Ubuntu - Colorblind Programming