How do I install Sublime Text 2/3?

Install via the Package Manager(apt-get):

Simply add to your packages:

For Sublime-Text-2:

sudo add-apt-repository ppa:webupd8team/sublime-text-2
sudo apt-get update
sudo apt-get install sublime-text

For Sublime-Text-3:

sudo add-apt-repository ppa:webupd8team/sublime-text-3
sudo apt-get update
sudo apt-get install sublime-text-installer

Run Sublime-Text on terminal

subl

Install Manually via Terminal:

Download from the Sublime Site:

32-bit:

wget http://c758482.r82.cf2.rackcdn.com/Sublime\ Text\ 2.0.2.tar.bz2
tar vxjf Sublime\ Text\ 2.0.2.tar.bz2

64-bit:

wget http://c758482.r82.cf2.rackcdn.com/Sublime\ Text\ 2.0.2\ x64.tar.bz2
tar vxjf Sublime\ Text\ 2.0.2\ x64.tar.bz2

For Both:

sudo mv Sublime\ Text\ 2 /opt/
sudo ln -s /opt/Sublime\ Text\ 2/sublime_text /usr/bin/sublime

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!

#!/usr/bin/env bash
# Usage: {script} [ OPTIONS ] TARGET BUILD
# 
#   TARGET      Default target is "/usr/local".
#   BUILD       If not defined tries to get the build into the Sublime Text 3 website.
# 
# OPTIONS
#
#   -h, --help  Displays this help message.
#
# Report bugs to Henrique Moody <[email protected]>
#

set -e

if [[ "${1}" = '-h' ]] || [[ "${1}" = '--help' ]]; then
    sed -E 's/^#\s?(.*)/\1/g' "${0}" |
        sed -nE '/^Usage/,/^Report/p' |
        sed "s/{script}/$(basename "${0}")/g"
    exit
fi

declare URL
declare URL_FORMAT="http://c758482.r82.cf2.rackcdn.com/sublime_text_3_build_%d_x%d.tar.bz2"
declare TARGET="${1:-/usr/local}"
declare BUILD="${2}"
declare BITS

if [[ -z "${BUILD}" ]]; then
    BUILD=$(
        curl -Ls http://www.sublimetext.com/3 |
        grep '<h2>Build' |
        head -n1 |
        sed -E 's#<h2>Build ([0-9]+)</h2>#\1#g'
    )
fi

if [[ "$(uname -m)" = "x86_64" ]]; then
    BITS=64
else
    BITS=32
fi

URL=$(printf "${URL_FORMAT}" "${BUILD}" "${BITS}")

read -p "Do you really want to install Sublime Text 3 (Build ${BUILD}, x${BITS}) on \"${TARGET}\"? [Y/n]: " CONFIRM
CONFIRM=$(echo "${CONFIRM}" | tr [a-z] [A-Z])
if [[ "${CONFIRM}" = 'N' ]] || [[ "${CONFIRM}" = 'NO' ]]; then
    echo "Aborted!"
    exit
fi

echo "Downloading Sublime Text 3"
curl -L "${URL}" | tar -xjC ${TARGET}

echo "Creating shortcut file"
cat ${TARGET}/sublime_text_3/sublime_text.desktop |
    sed "s#/opt#${TARGET}#g" |
    cat > "/usr/share/applications/sublime_text.desktop"

echo "Creating binary file"
cat > ${TARGET}/bin/subl <<SCRIPT
#!/bin/sh
if [ \${1} == \"--help\" ]; then
    ${TARGET}/sublime_text_3/sublime_text --help
else
    ${TARGET}/sublime_text_3/sublime_text \$@ > /dev/null 2>&1 &
fi
SCRIPT

echo "Finish!"

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 symlink sublime_text executable into that directory:

mkdir ~/bin
ln -s ~/wherever/sublime/is/sublime_text ~/bin

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 by root now. You need to do something like

sudo chown -R yourusername:yourusername /home/yourusername/.config/sublime-text-2

to 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

sudo cp /usr/share/applications/defaults.list /usr/share/applications/defaults.list.bak && cat /usr/share/applications/defaults.list.bak | sed "s/sublime\.desktop/gedit.desktop/g" | sudo tee /usr/share/applications/defaults.list

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 sublime

4) 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.

[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=~/.local/Sublime\ Text\ 2/sublime_text
Terminal=false
Icon=~/.local/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=~/.local/Sublime\ Text\ 2/sublime_text -n
TargetEnvironment=Unity

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;

cd download_path
sudo dpkg -i package.deb

for example if my download for a 64 bit architecture is in the Downloads directory and is called sublime-text_build-3080_amd64.deb then I will run

cd ~/Downloads
sudo dpkg -i sublime-text_build-3080_amd64.deb

In my case it was sublime text 3, you can get for your sublime text 2 also