I installed Sublime Text 2 on 12.04 as per this tutorial.
However I don't have adequate permissions when launching the program from the Unity launcher. For example I cannot install packages, or if I add a folder to the sidebar when I close Sublime and reopen, the folder is no longer listed. If I run sudo sublime
in the terminal all changes remain after closing.
I've tried chown-ing the Sublime Text 2 folder in usr/lib
sudo chown -R mylogin:mylogin /usr/lib/"Sublime Text 2"
but this seemed to have no effect.
Install via the Package Manager(apt-get):
Simply add to your packages:
For Sublime-Text-2:
For Sublime-Text-3:
Run Sublime-Text on terminal
Install Manually via Terminal:
Download from the Sublime Site:
32-bit:
64-bit:
For Both:
Source: http://www.tecmint.com/install-sublime-text-editor-in-linux/
Install Manually via Script:
Check out this nice script on Github("Install Sublime Text on Fedora.") that you can run, just make sure to edit the "*.tar.bz2" in the script to download the latest version of Sublime Text!
Source: https://gist.github.com/henriquemoody/3288681
This helped me and I hope it helps everyone else as well!
Basically, your problem is that you're using a wrong article :) If it was on an SE site I would down-vote it.
Manually copying stuff which does not come from Ubuntu repositories into
/usr
is WRONG. This directory is managed by Ubuntu's package manager and messing with it is going to cause you trouble at some point or another - for example, the next time you upgrade your system Sublime will likely be removed without a trace.Running the program as root is even wronger, especially in the case of SublimeText which has its own package manager which basically downloads stuff from Internet and lets it run on your computer. A simple typo in a plugin could destroy all data on your machine.
A proper solution, if you want to install the program system-wide, would be to find/build a .deb file and install it - this way package manager would be aware of the package. Webupd8 maintains a PPA for SublimeText2, so you can just use that.
However, there's a much lazier solution which I am personally using - just unpack SublimeText somewhere in your home directory, create a
bin
directory in your home directory and symlinksublime_text
executable into that directory:After which you'll be able to run Sublime Text by typing
sublime_text
in the console, from any directory. This does not require root privileges at all and the editor runs just fine.The article also does some shell integration, such as registering sublime_text as a default editor and adding an icon, and I was too lazy to do that - however, I'm sure that it can be done without messing with system-wide settings.
This does not explain, however, the problems with permissions you're having - SublimeText stores all its settings in your home folder anyway, so even if you installed it system-wide it should not have problems. What probably happened is that you started it the first time with superuser privileges (i.e. from the sudo shell), so the editor's config directory (in
~/.config/sublime-text-2
) is owned byroot
now. You need to do something liketo fix this.
Here is how to solve this.
1) undo all the steps in the linked webpage in reverse order.
1a) if you didn't save a copy of your original defaults.list then open a terminal and run
2) get the version of sublime you want and extract it to the current directory.
3) in bash
cd
to the directory where you extracted sublime4)
mv Sublime\ Text\ 2 ~/.local
4a) if you want to be able to run sublime from the command line then run
mkdir -p ~/bin && ln -s ~/.local/Sublime\ Text\ 2/sublime_text ~/bin/sublime
. The default.bashrc
will add ~/bin to your $PATH the next time your shell launches.5) Make a file called
sublime.desktop
in~/.local/share/applications/
and paste the following inside.6)
test -e ~/.local/share/applications/defaults.list -a 1$(grep -sc \[Default\ Applications\] ~/.local/share/applications/defaults.list) != 10 || echo "[Default Applications]" >> ~/.local/share/applications/defaults.list; grep gedit.desktop /usr/share/applications/defaults.list | sed "s/gedit\.desktop/sublime.desktop/g" >> ~/.local/share/applications/defaults.list
7) done.
It should now be installed locally in your home directory and you should have no more issues with permissions.
You can also also download the Debian package for your particular architecture from the sublime website
and then run the following;
for example if my download for a 64 bit architecture is in the
Downloads
directory and is calledsublime-text_build-3080_amd64.deb
then I will runIn my case it was sublime text 3, you can get for your sublime text 2 also
I think @Alex L. is completely right. I recommend never editting your
/usr
fs, add-on commercial software should be installed in either/opt
for multi-user or~/opt
for single user (see Linux Filesystem Hierarchy especially/opt
and/home
). Here are just a few more additions to make it really nice.You don't have to move your app to
.local
or/local
; I usually just leave them in~/opt
(n.b.: the tilde is your home directory or$HOME
).Make a symlink to sublime_text in
~/bin
, but call itsublime
; see step 4a in Alex L.'s answer above.Same as Alex L.'s step 5, make a file called
sublime.desktop
in~/.local/share/applications/
but add%f
aftersublime
in theExec
field so that you can open it from Nautilus, as described in this post. Also don't escape spaces for theIcon
field and use the full path, no tilde. Replace<user>
with your username.You shouldn't have to log off, but if it doesn't show up in your dash, right away maybe you do. Then look for a file to open in Nautilus, right-click and select Open With Other Applicaton ... then Show other applications button at the bottom, find Sublime Text 2 in the list, select it and hit Select. Your file should open in Sublime Text 2, and from now on for files of that type you will see Sublime Text 2 already listed as an option. You can also set it as the default from Nautilus by right-clicking, selecting Properties then Open With and finally Set as default button after highlighting Sublime Text 2. Of course you could have used Add to select Sublime Text 2 to open the file type from the Properties window as well.
Type the following commands in the terminal, for Sublime Text 2 :
For Sublime Text 3 :
Download the deb package from the official site.
Install the package by
$sudo dpkg -i path_to_the_file.deb
Start the program from
/opt/sublime_text/sublime_text
As mentioned by Leonard Kakande, you can install it from official repository. It works for Sublime Text 3 only, though.
Run the following commands in your terminal:
(1) Install the GPG key:
(2) Select the channel to use:
Stable
Dev
(3) Update apt sources and install Sublime Text
Installing Snap on Ubuntu
Installing Sublime text
Note: snapd is only works for ubuntu 16.04 or later versions
I recently made this for your convenience: https://github.com/TCattd/sublime-text-linux-installer
A Sublime Text 2 and Sublime Text 3 bash script installer. Just download one of the scripts, ST2 or ST2.
For ST2 is: st2install
Put ir in your home folder. Then form a terminal (and in the same home folder) run:
That will take care of all.
You can upgrade with that very same script too, in case a new ST2 version pop out. Same apply for installing/upgrading ST3.
And both versions, using those installers, can live together without conflicts.
Hope it helps ;)